private void dockPanel_ActiveDocumentChanged(object sender, EventArgs e) { DesignWorkbench workbench = dockPanel.ActiveContent as DesignWorkbench; if (workbench == null) { return; } foreach (var item in GolableInstance.PageList()) { if (item.PageGuid == workbench.pageGuid) { ActivPage = item; break; } } foreach (var item in m_solutionExplorer.treeView.Nodes.AllNodes) { if (item.Text == ActivPage.PageName) { m_solutionExplorer.treeView.SelectedNode = item; break; } } UpdateComboBox(); }
private DesignWorkbench CreateNewDocument(string text) { DesignWorkbench dummyDoc = new DesignWorkbench(text); dummyDoc.Text = text; return(dummyDoc); }
private IDockContent GetContentFromPersistString(string persistString) { if (persistString == typeof(DummySolutionExplorer).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(DummyOutputWindow).ToString()) { return(m_outputWindow); } else if (persistString == typeof(DummyTaskList).ToString()) { return(m_taskList); } 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(DesignWorkbench).ToString()) { return(null); } DesignWorkbench dummyDoc; if (parsedStrings[1] != string.Empty) { dummyDoc = new DesignWorkbench(parsedStrings[1]); dummyDoc.FileName = parsedStrings[1]; return(dummyDoc); } if (parsedStrings[2] != string.Empty) { dummyDoc = new DesignWorkbench(parsedStrings[2]); dummyDoc.Text = parsedStrings[2]; return(dummyDoc); } return(null); } }
private void SetPanelActive(PageMoel page) { foreach (var item in this.dockPanel.Documents) { if (item is DesignWorkbench) { DesignWorkbench workbench = item as DesignWorkbench; if (workbench.pageGuid == page.PageGuid) { workbench.Activate(); } } } }
private void CreateNewDocument() { pages = GolableInstance.PageList(); string text = string.Empty; AddPageDialog addPage = new AddPageDialog(); addPage.btnAdd.Click += (o, args) => { text = Regex.Replace(addPage.txtInput.Text, @"(?<!\\)\\f", "\f"); m_solutionExplorer.AddNode(text); addPage.Close(); }; addPage.ShowDialog(); addPage.txtInput.Select(); DesignWorkbench dummyDoc = new DesignWorkbench(text); ActivPage = pages[pages.Count - 1];//刚生成的页面作为活动页面 dummyDoc.Text = text; PropertyInit(); ActivPage.selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged); ActivPage.componentChangeService.ComponentAdded += ComponentListChanged; ActivPage.componentChangeService.ComponentRemoved += ComponentListChanged; ActivPage.componentChangeService.ComponentRename += ComponentListChanged; ActivPage.host.TransactionClosed += new DesignerTransactionCloseEventHandler(TransactionClosed); ++GolableInstance.Pagecount; UpdateComboBox(); if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi) { dummyDoc.MdiParent = this; dummyDoc.Show(); } else { dummyDoc.Show(dockPanel); } }
private void menuItemOpen_Click(object sender, System.EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.InitialDirectory = Application.ExecutablePath; openFile.Filter = "rtf files (*.rtf)|*.rtf|txt files (*.txt)|*.txt|All files (*.*)|*.*"; openFile.FilterIndex = 1; openFile.RestoreDirectory = true; if (openFile.ShowDialog() == DialogResult.OK) { string fullName = openFile.FileName; string fileName = Path.GetFileName(fullName); if (FindDocument(fileName) != null) { MessageBox.Show("该文档: " + fileName + " 已经打开"); return; } DesignWorkbench dummyDoc = new DesignWorkbench(fileName); dummyDoc.Text = fileName; if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi) { dummyDoc.MdiParent = this; dummyDoc.Show(); } else { dummyDoc.Show(dockPanel); } try { dummyDoc.FileName = fullName; } catch (Exception exception) { dummyDoc.Close(); MessageBox.Show(exception.Message); } } }