public void SaveFile(bool saveas) { _textBoxHelper.SaveState(); string _selectedfile = CurrentFile; if (string.IsNullOrEmpty(_selectedfile)) { saveas = true; } if (saveas == true) { SaveFileDialog d = new SaveFileDialog { Filter = "json Files (*.json)|*.json|All Files (*.*)|*.*" }; DialogResult dr = d.ShowDialog(); if (dr == DialogResult.Cancel) { return; } _selectedfile = d.FileName; } StopWatch _watch = new StopWatch(); _watch.Start(); if (IsOverwritingNewerFile(_selectedfile)) { FormOverwrite f = new FormOverwrite(); f.ShowDialog(); switch (f.DlgResult) { case OverwriteMode.Cancel: return; case OverwriteMode.Overwrite: break; case OverwriteMode.Reload: Reload(); return; } } CurrentFile = _selectedfile; _lastOpenedDate = DateTime.Now; SetTitle(); CodeSnippetCollection _collection = new CodeSnippetCollection { LastSaved = _lastOpenedDate }; FormToCodeCollection(_treeViewLibrary.Nodes); if (_treeViewLibrary.SelectedNode != null) { _collection.LastSelected = _treeViewLibrary.SelectedNode.FullPath; } _mainform.SaveEditor(); CodeLib.Instance.Save(_collection); BackupHelper backupHelper = new BackupHelper(CurrentFile); backupHelper.Backup(); Save(_collection, _selectedfile); }
public void SaveEditor() => _textboxHelper.SaveState();