internal void OpenFile(string filepath) { var fileName = Path.GetFileName(filepath); var extension = Path.GetExtension(filepath); if (this.FindDocument(fileName) != null) { MessageBox.Show("The document: " + fileName + " is already opened!"); return; } if (extension == "." + Main.StepBroFileExtension) { var docView = new StepBroScriptDocView(m_resourceUserObject) { Text = fileName }; this.ShowDocView(docView); try { docView.OpenFile(filepath); } catch (Exception exception) { docView.Close(); MessageBox.Show(exception.Message); } } else { var docView = new TextDocView { Text = fileName }; this.ShowDocView(docView); try { docView.OpenFile(filepath); } catch (Exception exception) { docView.Close(); MessageBox.Show(exception.Message); } } }
private IDockContent GetContentFromPersistString(string persistString) { var found = AppDomain.CurrentDomain.GetAssemblies(). SelectMany(a => a.GetExportedTypes()). Where(t => String.Equals(t.FullName, persistString, StringComparison.InvariantCulture)); if (persistString == typeof(FileExplorer).ToString()) { return(m_solutionExplorer); } else if (persistString == typeof(DummyPropertyWindow).ToString()) { return(m_propertyWindow); } else if (persistString == typeof(DummyToolbox).ToString()) { return(m_toolbox); } else if (persistString == typeof(OutputWindow).ToString()) { return(m_outputWindow); } else if (persistString == typeof(ErrorsWindow).ToString()) { return(m_errorListWindow); } else if (persistString == typeof(DummyTaskList).ToString()) { return(m_taskList); } else if (persistString == typeof(EditorPlayground).ToString()) { return(m_editorPlayground); } else { // DummyDoc overrides GetPersistString to add extra information into persistString. // Any DockContent may override this value to add any needed information for deserialization. string[] parsedStrings = persistString.Split(new char[] { ',' }); if (parsedStrings.Length != 3) { return(null); } if (parsedStrings[0] == typeof(TextDocView).ToString()) { TextDocView doc = new TextDocView(m_resourceUserObject); if (parsedStrings[1] != string.Empty) { if (!doc.OpenFile(parsedStrings[1])) { return(null); } } if (parsedStrings[2] != string.Empty) { doc.Text = parsedStrings[2]; } return(doc); } else if (parsedStrings[0] == typeof(StepBroScriptDocView).ToString()) { StepBroScriptDocView doc = new StepBroScriptDocView(m_resourceUserObject); if (parsedStrings[1] != string.Empty) { if (!doc.OpenFile(parsedStrings[1])) { return(null); } } if (parsedStrings[2] != string.Empty) { doc.Text = parsedStrings[2]; } return(doc); } else if (parsedStrings[0] == ObjectPanelDockWindow.PersistTitle) { var view = new ObjectPanelDockWindow(StepBroMain.ServiceManager); view.SetupFromLoadSpecification(parsedStrings.Skip(1).ToArray()); return(view); } else { return(null); } } }