public void Open(string FileName, bool InNewInstance = false) { if (InNewInstance) { // open a new instance StartNewTEInstance("\"" + FileName + "\""); } else { if (TheDocument == null || TheDocument.TryDisposeFile()) { LoadFile(FileName); } } }
/* * /// <summary> * /// Tries to create a new file. Is the command parameter is not null, then a new instance of TikzEdt is opened. * /// If the current file is unsaved, the user has to be asked to save. * /// </summary> * public void NewCommandHandler(object sender, ExecutedRoutedEventArgs e) * { * CreateNewFile(e.Parameter != null); * } */ /// <summary> /// Tries to cretae a new File. /// (If the current file contains changes and the user rejects to discard/save them, no file is created). /// </summary> /// <param name="InNewInstance">Whether to open a new instance of TikzEdt.</param> public void CreateNewFile(bool InNewInstance = false) { if (InNewInstance) { // open a new instance (TODO: in the same folder...) StartNewTEInstance(); } else { if (TheDocument == null || TheDocument.TryDisposeFile()) { TheDocument = new TEDocumentVM <T>(this, Compiler); TheDocument.OnSaved += ((s, args) => GlobalUI.UI.RaiseRecentFileEvent(s, (s as TEDocumentVM <T>).FilePath, true)); } } }
/* /// <summary> * /// Tries to create a new file. Is the command parameter is true, then a new instance of TikzEdt is opened. * /// If the current file is unsaved, the user has to be asked to save. * /// </summary> * private void OpenCommandHandler(object sender, ExecutedRoutedEventArgs e) * { * Open(e.Parameter != null); * } */ /// <summary> /// Tries to open file (a file open dialog is displayed). Is the parameter is true, then a new instance of TikzEdt is opened. /// If the current file is unsaved, the user has to be asked to save. /// </summary> public void Open(bool InNewInstance = false) { string filename; if (InNewInstance) { if (GlobalUI.UI.ShowOpenFileDialog(out filename) == true) { // open a new instance StartNewTEInstance("\"" + filename + "\""); } } else { if (TheDocument == null || TheDocument.TryDisposeFile()) { if (GlobalUI.UI.ShowOpenFileDialog(out filename) == true) { LoadFile(filename); } } } }