Beispiel #1
0
        public FileViewModel Open(string filepath)
        {
            var fileViewModel = _files.FirstOrDefault(fm => fm.FilePath == filepath);
            if (fileViewModel != null)
                return fileViewModel;

            fileViewModel = new FileViewModel(filepath);
            _files.Add(fileViewModel);
            return fileViewModel;
        }
Beispiel #2
0
 internal void Save(FileViewModel fileToSave, bool saveAsFlag = false)
 {
     if (fileToSave.FilePath == null || saveAsFlag)
     {
         var dlg = new SaveFileDialog();
         if (dlg.ShowDialog().GetValueOrDefault())
         {
             fileToSave.Save(dlg.FileName);
         }
     }
     else
     {
         fileToSave.Save();
     }
 }
Beispiel #3
0
 internal void Close(FileViewModel fileToClose)
 {
     if (fileToClose.IsModified)
     {
         var res = MessageBox.Show(string.Format("Save changes for file '{0}'?", fileToClose.FileName), "AvalonDock Test App", MessageBoxButton.YesNoCancel);
         if (res == MessageBoxResult.Cancel)
             return;
         if (res == MessageBoxResult.Yes)
         {
             Save(fileToClose);
         }
     }
     bool replaceActive = fileToClose == ActiveDocument;
     _files.Remove(fileToClose);
     if (replaceActive)
     {
         if (_files.Count > 0)
         {
             ActiveDocument = _files.Last();
         }
         else {
             ActiveDocument = null;
         }
     }
 }
Beispiel #4
0
 internal void Execute(FileViewModel fileToClose)
 {
 }
Beispiel #5
0
 internal void Execute(FileViewModel fileToClose)
 {
 }