public void treeView_SelectedNodeChanged(DynamicTreeView.DynamicTreeView obj) { if (treeView.SelectedNode != null) { foreach (var item in GolableInstance.PageList()) { if (item.PageName == treeView.SelectedNode.Text) { _activModel = item; } } activePanel(_activModel); //DockPanel panel = GolableInstance.GetDockPanel(); //foreach (var item in panel.Documents ) //{ // if (item is DesignWorkbench) // { // DesignWorkbench workbench = item as DesignWorkbench; // if (workbench.pageGuid==_activModel.PageGuid) // { // workbench.Activate(); // } // } //} } }
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(); }
public static PageMoel GetActiPage() { if (ActivePage == null) { lock (_lock) { if (ActivePage == null) { ActivePage = new PageMoel(); } } } return(ActivePage); }
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); } }
public MainForm() { InitializeComponent(); //this.dockPanel = GolableInstance.GetDockPanel(); AutoScaleMode = AutoScaleMode.Dpi; //SetSplashScreen(); CreateStandardControls(); showRightToLeft.Checked = (RightToLeft == RightToLeft.Yes); RightToLeftLayout = showRightToLeft.Checked; m_solutionExplorer.RightToLeftLayout = RightToLeftLayout; m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString); vsToolStripExtender1.DefaultRenderer = _toolStripProfessionalRenderer; SetSchema(this.menuItemSchemaVS2013Blue, null); ActivPage = GolableInstance.GetActiPage(); ToolBoxSelect(); }
internal Guid pageGuid;//与model的编号对应 public DesignWorkbench(string pageName) { InitializeComponent(); AutoScaleMode = AutoScaleMode.Dpi; PageMoel pm = new PageMoel(); _propertyGrid = new PropertyGrid { Dock = DockStyle.Fill }; pm.propertyGrid = _propertyGrid; pm.PageName = pageName; ServiceContainer serviceContainer = new ServiceContainer(); serviceContainer.AddService(typeof(System.ComponentModel.Design.IDesignerEventService), new DesignerEventService()); serviceContainer.AddService(typeof(System.ComponentModel.Design.Serialization.INameCreationService), new NameCreationService()); _toolboxService = new CustomToolboxService(); serviceContainer.AddService(typeof(IToolboxService), _toolboxService); surface = new DesignSurface(serviceContainer); _host = (IDesignerHost)surface.GetService(typeof(IDesignerHost)); serviceContainer.AddService(typeof(System.ComponentModel.Design.IEventBindingService), new Services.EventBindingService(surface)); _menuCommandService = new MenuCommandService(surface); serviceContainer.AddService(typeof(IMenuCommandService), _menuCommandService); //surface.BeginLoad(typeof(Form)); _CodeDomHostLoader = new Loader.CodeDomHostLoader(); surface.BeginLoad(_CodeDomHostLoader); Control designerContorl = (Control)surface.View; designerContorl.BackColor = Color.Aqua; designerContorl.Dock = DockStyle.Fill; //获取root组件 var designerHost = (IDesignerHost)this._host; if (designerHost != null) { rootComponent = (Form)designerHost.RootComponent; } rootComponent.FormBorderStyle = FormBorderStyle.None; #region 初始化窗体大小 //- set the Size PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(designerContorl); //- Sets a PropertyDescriptor to the specific property. PropertyDescriptor pdS = pdc.Find("Size", false); if (null != pdS) { pdS.SetValue(_host.RootComponent, new Size(800, 480)); } #endregion tpDesign.Controls.Add(designerContorl);//窗体 _textEditor = new TextEditorControl { IsReadOnly = true, Dock = DockStyle.Fill, Document = { HighlightingStrategy = HighlightingStrategyFactory.CreateHighlightingStrategy("C#") } }; //代码编辑器 tpCode.Controls.Add(_textEditor); _propertyGrid.SelectedObject = surface.ComponentContainer.Components[0]; _propertyGrid.Site = (new IDEContainer(_host)).CreateSite(_propertyGrid); _propertyGrid.PropertyTabs.AddTabType(typeof(System.Windows.Forms.Design.EventsTab), PropertyTabScope.Document); pm.serviceContainer = serviceContainer; pm.surFace = surface; pageGuid = Guid.NewGuid(); pm.PageGuid = pageGuid; List <PageMoel> pages = GolableInstance.PageList(); pages.Add(pm); //if (ChangeSur != null) ChangeSur(); }