示例#1
0
        internal void Close(DocumentViewModel fileToClose)
        {
            if (fileToClose.IsDirty)
              {
            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);
            }
              }

              _documents.Remove(fileToClose);
        }
示例#2
0
        internal void Save(DocumentViewModel fileToSave, bool saveAsFlag = false)
        {
            if (fileToSave.FilePath == null || saveAsFlag)
              {
            var dlg = new SaveFileDialog();
            if (dlg.ShowDialog().GetValueOrDefault())
              fileToSave.FilePath = dlg.SafeFileName;
              }

              if (fileToSave.FilePath != null)
            File.WriteAllText(fileToSave.FilePath, fileToSave.TextContent);
              ActiveDocument.IsDirty = false;
        }
示例#3
0
        public DocumentViewModel Open(string filepath)
        {
            var fileViewModel = _documents.FirstOrDefault(fm => fm.FilePath == filepath);
              if (fileViewModel != null)
            return fileViewModel;

              fileViewModel = new DocumentViewModel(filepath);
              _documents.Add(fileViewModel);
              return fileViewModel;
        }