private void dockPanel_ActiveDocumentChanged(object sender, EventArgs e) { if (this.dockPanel.ActiveDocument != null) { Editor editor = (Editor)this.dockPanel.ActiveDocument.DockHandler.Form; CEManager.SetActiveDocument(editor); StatusManager.SetLineColumn(CEManager.ActiveDocument.codeEditor.TextArea.Caret.Line, CEManager.ActiveDocument.codeEditor.TextArea.Caret.Column); this.saveToolStripMenuItem.Text = string.Format(LanguageManager.GetText(LanguageEnum.MainMenuItemFileSave), Path.GetFileName(editor.FilePath)); this.savesAsToolStripMenuItem.Text = string.Format(LanguageManager.GetText(LanguageEnum.MainMenuItemFileSaveAs), Path.GetFileName(editor.FilePath)); this.SetMenuStatus(true, false); } else { CEManager.SetActiveDocument(null); this.SetMenuStatus(false, false); StatusManager.SetLineColumn(0, 0); this.saveToolStripMenuItem.Text = string.Format(LanguageManager.GetText(LanguageEnum.MainMenuItemFileSave), "Selected Item"); this.savesAsToolStripMenuItem.Text = string.Format(LanguageManager.GetText(LanguageEnum.MainMenuItemFileSaveAs), "Selected Item"); } }
private void projectFiles_DoubleClick(object sender, EventArgs e) { if (File.Exists(this.projectFiles.SelectedNode.Name) == true) { CEManager.Open(this.projectFiles.SelectedNode.Name, true); } CEManager.SetActiveDocument(this.projectFiles.SelectedNode.Name, true); }
/// <summary> /// Open a project. /// </summary> /// <param name="projectPath">Path to the project file.</param> /// <returns>Returns true if the project was opened with success, false otherwise.</returns> public static bool Open(string projectPath) { if (projectPath == null || System.IO.Path.GetExtension(projectPath) != Extension) { return(false); } xmlPath = projectPath; bool isActive = false; string filePath = string.Empty, activeFile = string.Empty; using (XmlTextReader projectReader = new XmlTextReader(projectPath)) { while (projectReader.Read()) { switch (projectReader.Name.ToString()) { case "Name": { Name = projectReader.ReadString(); break; } case "File": { try { isActive = Convert.ToBoolean(Convert.ToInt32(projectReader.GetAttribute("Active"))); // Get the attribute first. filePath = projectReader.ReadString(); if (isActive == true) { activeFile = filePath; } CEManager.Open(filePath, true); } catch (Exception) { // File dosen't exist. // TODO: Write the exception to log file. } break; } } } } if (activeFile != string.Empty) { CEManager.SetActiveDocument(activeFile, true); } Path = System.IO.Path.GetDirectoryName(projectPath); // Set the project path. LoadDirectory(Path); IsOpen = true; return(true); }