private void menuItemLayoutByCode_Click(object sender, EventArgs e) { dockPanel.SuspendLayout(true); CloseAllContents(); CreateStandardControls(); m_solutionExplorer.Show(dockPanel, DockState.DockRight); m_propertyWindow.Show(m_solutionExplorer.Pane, m_solutionExplorer); m_toolbox.Show(dockPanel, DockState.DockLeft); m_sortie.Show(dockPanel, DockState.DockBottom); Doc doc1 = CreateNewDocument("Document1"); Doc doc2 = CreateNewDocument("Document2"); Doc doc3 = CreateNewDocument("Document3"); Doc doc4 = CreateNewDocument("Document4"); doc1.Show(dockPanel, DockState.Document); doc2.Show(doc1.Pane, null); doc3.Show(doc1.Pane, DockAlignment.Bottom, 0.5); doc4.Show(doc3.Pane, DockAlignment.Right, 0.5); dockPanel.ResumeLayout(true, true); }
private Workbench() { // restore form location from last session FormLocationHelper.Apply(this, "StartupFormPosition", true); dockPanel = new WeifenLuo.WinFormsUI.Docking.DockPanel(); dockPanel.DocumentStyle = DocumentStyle.SystemMdi; var formOne = new FormOne(); formOne.Text = "测试1"; formOne.Dock = DockStyle.Fill; formOne.Show(dockPanel, DockState.DockLeft); var formTwo = new FormOne(); formTwo.Text = "测试2"; formTwo.Dock = DockStyle.Fill; formTwo.Show(dockPanel, DockState.DockRight); dockPanel.Dock = DockStyle.Fill; dockPanel.ResumeLayout(true, true); this.Controls.Add(dockPanel); Application.Idle += OnApplicationIdle; }
private void SetLayoutFromData(GR.Memory.ByteBuffer Data) { PanelMain.SuspendLayout(true); // need to clear all foreach (var toolEntry in Tools) { toolEntry.Value.Document.DockPanel = null; } Main.CloseAllDocuments(); //Debug.Log( Data.ToAsciiString() ); System.IO.MemoryStream memIn = new System.IO.MemoryStream(Data.Data(), false); try { PanelMain.LoadFromXml(memIn, m_deserializeDockContent); } catch (Exception ex) { Debug.Log("SetLayoutFromData: " + ex.Message); } memIn.Close(); memIn.Dispose(); PanelMain.ResumeLayout(true, true); }
private void Home_Load(object sender, EventArgs e) { dockPanel = new WeifenLuo.WinFormsUI.Docking.DockPanel(); dockPanel.Dock = System.Windows.Forms.DockStyle.Fill; dockPanel.DockBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(45)))), ((int)(((byte)(48))))); dockPanel.DockBottomPortion = 150D; dockPanel.DockLeftPortion = 200D; dockPanel.DockRightPortion = 200D; dockPanel.DockTopPortion = 150D; dockPanel.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(0))); dockPanel.Location = new System.Drawing.Point(0, 61); dockPanel.Name = "dockPanel"; dockPanel.Padding = new System.Windows.Forms.Padding(6); dockPanel.RightToLeftLayout = true; dockPanel.ShowAutoHideContentOnHover = false; dockPanel.Size = new System.Drawing.Size(810, 455); dockPanel.TabIndex = 12; dockPanel.Theme = this.vS2015DarkTheme1; this.panel1.Controls.Add(dockPanel); SetSchema(this.vS2015DarkTheme1, null); string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "OSMaker.config"); CloseAllContents(); CreateStandardControls(); m_propertyWindow.Show(dockPanel, DockState.DockRight); m_solutionExplorer.Show(m_propertyWindow.Pane, DockAlignment.Top, 0.5); m_propertyWindow.DockState = DockState.DockRightAutoHide; m_toolbox.Show(dockPanel, DockState.DockLeftAutoHide); dockPanel.ResumeLayout(true, true); Accueil MonAccueil = CreateNewAccueil(); if (dockPanel.DocumentStyle == DocumentStyle.SystemMdi) { MonAccueil.MdiParent = this; MonAccueil.Show(); } else { MonAccueil.Show(dockPanel); } m_sortie.Show(MonAccueil.PanelPane, DockAlignment.Left, 0.5); m_sortie.Text = "Output"; m_sortie.DockState = DockState.DockBottomAutoHide; }
public WindowManager(DockPanel dockPanel) { this.dockPanel = dockPanel; mruManager = new MRUManager(CommandManager.viewContext, this); //Create toolwindows dockPanel.SuspendLayout(); projectContentView = new ProjectContentView(); projectContentView.Show(dockPanel, DockState.DockLeft); projectContentView.OpenEntity += new ProjectContentView.OpenEntityHandler(OnOpenProjectEntity); logConsoleView = new LogConsoleView(); logConsoleView.Show(dockPanel, DockState.DockBottomAutoHide); dockPanel.ActiveAutoHideContent = null; projectContentView.Activate(); dockPanel.ResumeLayout(true); //Connect Windows Manager to heleper events dockPanel.ActiveDocumentChanged += new EventHandler(OnActiveDocumentChanged); Env.Current.ScriptManager.ScriptApplication.OpenEntity += new FreeSCADA.Common.Scripting.Application.OpenEntityHandler(OnOpenProjectEntity); }
protected override void OnEndDrag(bool abort) { DockPanel.SuspendLayout(true); Outline.Close(); Indicator.Close(); DragSource.BeforeEndDrag(); EndDrag(abort); // Queue a request to layout all children controls DockPanel.PerformMdiClientLayout(); DockPanel.ResumeLayout(true, true); DragSource.EndDrag(); DragSource = null; // Fire notification DockPanel.OnDocumentDragged(); }
public DockPane Float() { DockPanel.SuspendLayout(true); IDockContent activeContent = ActiveContent; DockPane floatPane = GetFloatPaneFromContents(); if (floatPane == null) { IDockContent firstContent = GetFirstContent(DockState.Float); if (firstContent == null) { DockPanel.ResumeLayout(true, true); return(null); } floatPane = DockPanel.DockPaneFactory.CreateDockPane(firstContent, DockState.Float, true); } SetVisibleContentsToPane(floatPane, activeContent); DockPanel.ResumeLayout(true, true); return(floatPane); }
private Workbench() { // restore form location from last session FormLocationHelper.Apply(this, "StartupFormPosition", true); dockPanel = new WeifenLuo.WinFormsUI.Docking.DockPanel(); dockPanel.DocumentStyle = DocumentStyle.SystemMdi; var formOne = new FormOne(); formOne.Text = "测试1"; formOne.Dock=DockStyle.Fill; formOne.Show(dockPanel, DockState.DockLeft); var formTwo = new FormOne(); formTwo.Text = "测试2"; formTwo.Dock = DockStyle.Fill; formTwo.Show(dockPanel, DockState.DockRight); dockPanel.Dock=DockStyle.Fill; dockPanel.ResumeLayout(true, true); this.Controls.Add(dockPanel); Application.Idle += OnApplicationIdle; }
public void Show(DockPanel dockPanel, Rectangle floatWindowBounds) { if (dockPanel == null) { throw(new ArgumentNullException(Strings.DockContentHandler_Show_NullDockPanel)); } dockPanel.SuspendLayout(true); DockPanel = dockPanel; if (FloatPane == null) { IsHidden = true; // to reduce the screen flicker FloatPane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.Float, false); FloatPane.FloatWindow.StartPosition = FormStartPosition.Manual; } FloatPane.FloatWindow.Bounds = floatWindowBounds; Show(dockPanel, DockState.Float); Activate(); dockPanel.ResumeLayout(true, true); }
internal void SetDockState(bool isHidden, DockState visibleState, DockPane oldPane) { if (IsSuspendSetDockState) { return; } if (DockPanel == null && visibleState != DockState.Unknown) { throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_NullPanel); } if (visibleState == DockState.Hidden || (visibleState != DockState.Unknown && !IsDockStateValid(visibleState))) { throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_InvalidState); } DockPanel dockPanel = DockPanel; if (dockPanel != null) { dockPanel.SuspendLayout(true); } SuspendSetDockState(); DockState oldDockState = DockState; if (m_isHidden != isHidden || oldDockState == DockState.Unknown) { m_isHidden = isHidden; } m_visibleState = visibleState; m_dockState = isHidden ? DockState.Hidden : visibleState; if (visibleState == DockState.Unknown) { Pane = null; } else { m_isFloat = (m_visibleState == DockState.Float); if (Pane == null) { Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, visibleState, true); } else if (Pane.DockState != visibleState) { if (Pane.Contents.Count == 1) { Pane.SetDockState(visibleState); } else { Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, visibleState, true); } } } if (Form.ContainsFocus) { if (DockState == DockState.Hidden || DockState == DockState.Unknown) { DockPanel.ContentFocusManager.GiveUpFocus(Content); } } SetPaneAndVisible(Pane); if (oldPane != null && !oldPane.IsDisposed && oldDockState == oldPane.DockState) { RefreshDockPane(oldPane); } if (Pane != null && DockState == Pane.DockState) { if ((Pane != oldPane) || (Pane == oldPane && oldDockState != oldPane.DockState)) { /* * Without this an early refresh can be triggered while the dimensions of the form * aren't calculated completely because the form could be still hidden although * isHidden says FALSE. */ //if (Pane.DockWindow == null || Pane.DockWindow.Visible || Pane.DockState == DockState.Document) RefreshDockPane(Pane); } } if (oldDockState != DockState) { if (DockState == DockState.Hidden || DockState == DockState.Unknown || DockHelper.IsDockStateAutoHide(DockState)) { DockPanel.ContentFocusManager.RemoveFromList(Content); } else { DockPanel.ContentFocusManager.AddToList(Content); } OnDockStateChanged(EventArgs.Empty); } ResumeSetDockState(); if (dockPanel != null) { dockPanel.ResumeLayout(true, true); } }
public void Show(DockPanel dockPanel, DockState dockState) { if (dockPanel == null) throw(new ArgumentNullException(Strings.DockContentHandler_Show_NullDockPanel)); if (dockState == DockState.Unknown || dockState == DockState.Hidden) throw(new ArgumentException(Strings.DockContentHandler_Show_InvalidDockState)); dockPanel.SuspendLayout(true); DockPanel = dockPanel; if (dockState == DockState.Float && FloatPane == null) Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.Float, true); else if (PanelPane == null) { DockPane paneExisting = null; foreach (DockPane pane in DockPanel.Panes) if (pane.DockState == dockState) { paneExisting = pane; break; } if (paneExisting == null) Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, dockState, true); else Pane = paneExisting; } DockState = dockState; dockPanel.ResumeLayout(true, true); //we'll resume the layout before activating to ensure that the position Activate(); //and size of the form are finally processed before the form is shown }
private void InternalConstruct(IDockContent content, DockState dockState, bool flagBounds, Rectangle floatWindowBounds, DockPane prevPane, DockAlignment alignment, double proportion, bool show) { if (dockState == DockState.Hidden || dockState == DockState.Unknown) { throw new ArgumentException(Strings.DockPane_SetDockState_InvalidState); } if (content == null) { throw new ArgumentNullException(Strings.DockPane_Constructor_NullContent); } if (content.DockHandler.DockPanel == null) { throw new ArgumentException(Strings.DockPane_Constructor_NullDockPanel); } SuspendLayout(); SetStyle(ControlStyles.Selectable, false); m_isFloat = (dockState == DockState.Float); m_contents = new DockContentCollection(); m_displayingContents = new DockContentCollection(this); m_dockPanel = content.DockHandler.DockPanel; m_dockPanel.AddPane(this); m_splitter = new SplitterControl(this); m_nestedDockingStatus = new NestedDockingStatus(this); m_captionControl = DockPanel.DockPaneCaptionFactory.CreateDockPaneCaption(this); m_tabStripControl = DockPanel.DockPaneStripFactory.CreateDockPaneStrip(this); Controls.AddRange(new Control[] { m_captionControl, m_tabStripControl }); DockPanel.SuspendLayout(true); if (flagBounds) { FloatWindow = DockPanel.FloatWindowFactory.CreateFloatWindow(DockPanel, this, floatWindowBounds); } else if (prevPane != null) { DockTo(prevPane.NestedPanesContainer, prevPane, alignment, proportion); } SetDockState(dockState); if (show) { content.DockHandler.Pane = this; } else if (this.IsFloat) { content.DockHandler.FloatPane = this; } else { content.DockHandler.PanelPane = this; } ResumeLayout(); DockPanel.ResumeLayout(true, true); }
private void ResumeRefreshStateChange() { m_countRefreshStateChange--; System.Diagnostics.Debug.Assert(m_countRefreshStateChange >= 0); DockPanel.ResumeLayout(true, true); }
internal void SetDockState(bool isHidden, DockState visibleState, DockPane oldPane) { if (this.IsSuspendSetDockState) { return; } if (this.DockPanel == null && visibleState != DockState.Unknown) { throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_NullPanel); } if (visibleState == DockState.Hidden || (visibleState != DockState.Unknown && !this.IsDockStateValid(visibleState))) { throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_InvalidState); } DockPanel dockPanel = this.DockPanel; if (dockPanel != null) { dockPanel.SuspendLayout(true); } this.SuspendSetDockState(); DockState oldDockState = this.DockState; if (this.m_isHidden != isHidden || oldDockState == DockState.Unknown) { this.m_isHidden = isHidden; } this.m_visibleState = visibleState; this.m_dockState = isHidden ? DockState.Hidden : visibleState; if (visibleState == DockState.Unknown) { this.Pane = null; } else { this.m_isFloat = (this.m_visibleState == DockState.Float); if (this.Pane == null) { this.Pane = this.DockPanel.DockPaneFactory.CreateDockPane(this.Content, visibleState, true); } else if (this.Pane.DockState != visibleState) { if (this.Pane.Contents.Count == 1) { this.Pane.SetDockState(visibleState); } else { this.Pane = this.DockPanel.DockPaneFactory.CreateDockPane(this.Content, visibleState, true); } } } if (this.Form.ContainsFocus) { if (this.DockState == DockState.Hidden || this.DockState == DockState.Unknown) { this.DockPanel.ContentFocusManager.GiveUpFocus(this.Content); } } this.SetPaneAndVisible(this.Pane); if (oldPane != null && !oldPane.IsDisposed && oldDockState == oldPane.DockState) { RefreshDockPane(oldPane); } if (this.Pane != null && this.DockState == this.Pane.DockState) { if ((this.Pane != oldPane) || (this.Pane == oldPane && oldDockState != oldPane.DockState)) { RefreshDockPane(this.Pane); } } if (oldDockState != this.DockState) { if (this.DockState == DockState.Hidden || this.DockState == DockState.Unknown || DockHelper.IsDockStateAutoHide(this.DockState)) { this.DockPanel.ContentFocusManager.RemoveFromList(this.Content); } else { this.DockPanel.ContentFocusManager.AddToList(this.Content); } this.OnDockStateChanged(EventArgs.Empty); } this.ResumeSetDockState(); if (dockPanel != null) { dockPanel.ResumeLayout(true, true); } }
public static void RestoreDockPanel(DockPanel dockPanel, XmlTextReader xmlIn, DockPanelExt.DeserializeDockContentDelegate deserializeDockContent) { if (xmlIn.Name != "DockPanel") throw new ArgumentException("Invalid Xml Format"); var dockPanelStruct = new DockPanelStruct(); dockPanelStruct.DockLeftPortion = Convert.ToDouble(xmlIn.GetAttribute("DockLeftPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockRightPortion = Convert.ToDouble(xmlIn.GetAttribute("DockRightPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockTopPortion = Convert.ToDouble(xmlIn.GetAttribute("DockTopPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockBottomPortion = Convert.ToDouble(xmlIn.GetAttribute("DockBottomPortion"), CultureInfo.InvariantCulture); dockPanelStruct.IndexActiveDocumentPane = Convert.ToInt32(xmlIn.GetAttribute("ActiveDocumentPane"), CultureInfo.InvariantCulture); dockPanelStruct.IndexActivePane = Convert.ToInt32(xmlIn.GetAttribute("ActivePane"), CultureInfo.InvariantCulture); // Load Contents MoveToNextElement(xmlIn); if (xmlIn.Name != "Contents") throw new ArgumentException("Invalid Xml Format"); ContentStruct[] contents = LoadAndCreateContents(dockPanel, xmlIn, deserializeDockContent); // Load Panes MoveToNextElement(xmlIn); if (xmlIn.Name != "Panes") throw new ArgumentException("Invalid Xml Format"); PaneStruct[] panes = LoadPanes(xmlIn); // Load DockWindows MoveToNextElement(xmlIn); if (xmlIn.Name != "DockWindows") throw new ArgumentException("Invalid Xml Format"); DockWindowStruct[] dockWindows = LoadDockWindows(xmlIn, dockPanel); // Load FloatWindows MoveToNextElement(xmlIn); if (xmlIn.Name != "FloatWindows") throw new ArgumentException("Invalid Xml Format"); FloatWindowStruct[] floatWindows = LoadFloatWindows(xmlIn); dockPanel.SuspendLayout(true); dockPanel.DockLeftPortion = dockPanelStruct.DockLeftPortion; dockPanel.DockRightPortion = dockPanelStruct.DockRightPortion; dockPanel.DockTopPortion = dockPanelStruct.DockTopPortion; dockPanel.DockBottomPortion = dockPanelStruct.DockBottomPortion; // Set DockWindow ZOrders int prevMaxDockWindowZOrder = int.MaxValue; for (int i = 0; i < dockWindows.Length; i++) { int maxDockWindowZOrder = -1; int index = -1; for (int j = 0; j < dockWindows.Length; j++) { if (dockWindows[j].ZOrderIndex > maxDockWindowZOrder && dockWindows[j].ZOrderIndex < prevMaxDockWindowZOrder) { maxDockWindowZOrder = dockWindows[j].ZOrderIndex; index = j; } } dockPanel.DockWindows[dockWindows[index].DockState].BringToFront(); prevMaxDockWindowZOrder = maxDockWindowZOrder; } // Create panes foreach (PaneStruct t in panes) { DockPane pane = null; for (int j = 0; j < t.IndexContents.Length; j++) { IDockContent content = dockPanel.Contents[t.IndexContents[j]]; if (j == 0) pane = dockPanel.DockPaneFactory.CreateDockPane(content, t.DockState, false); else if (t.DockState == DockState.Float) content.DockHandler.FloatPane = pane; else content.DockHandler.PanelPane = pane; } } // Assign Panes to DockWindows foreach (DockWindowStruct t in dockWindows) { for (int j = 0; j < t.NestedPanes.Length; j++) { DockWindow dw = dockPanel.DockWindows[t.DockState]; int indexPane = t.NestedPanes[j].IndexPane; DockPane pane = dockPanel.Panes[indexPane]; int indexPrevPane = t.NestedPanes[j].IndexPrevPane; DockPane prevPane = (indexPrevPane == -1) ? dw.NestedPanes.GetDefaultPreviousPane(pane) : dockPanel.Panes[indexPrevPane]; DockAlignment alignment = t.NestedPanes[j].Alignment; double proportion = t.NestedPanes[j].Proportion; pane.DockTo(dw, prevPane, alignment, proportion); if (panes[indexPane].DockState == dw.DockState) panes[indexPane].ZOrderIndex = t.ZOrderIndex; } } // Create float windows foreach (FloatWindowStruct t in floatWindows) { FloatWindow fw = null; for (int j = 0; j < t.NestedPanes.Length; j++) { int indexPane = t.NestedPanes[j].IndexPane; DockPane pane = dockPanel.Panes[indexPane]; if (j == 0) fw = dockPanel.FloatWindowFactory.CreateFloatWindow(dockPanel, pane, t.Bounds); else { int indexPrevPane = t.NestedPanes[j].IndexPrevPane; DockPane prevPane = indexPrevPane == -1 ? null : dockPanel.Panes[indexPrevPane]; DockAlignment alignment = t.NestedPanes[j].Alignment; double proportion = t.NestedPanes[j].Proportion; pane.DockTo(fw, prevPane, alignment, proportion); } if (panes[indexPane].DockState == fw.DockState) panes[indexPane].ZOrderIndex = t.ZOrderIndex; } } // sort IDockContent by its Pane's ZOrder int[] sortedContents = null; if (contents.Length > 0) { sortedContents = new int[contents.Length]; for (int i = 0; i < contents.Length; i++) sortedContents[i] = i; int lastDocument = contents.Length; for (int i = 0; i < contents.Length - 1; i++) { for (int j = i + 1; j < contents.Length; j++) { DockPane pane1 = dockPanel.Contents[sortedContents[i]].DockHandler.Pane; int ZOrderIndex1 = pane1 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane1)].ZOrderIndex; DockPane pane2 = dockPanel.Contents[sortedContents[j]].DockHandler.Pane; int ZOrderIndex2 = pane2 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane2)].ZOrderIndex; if (ZOrderIndex1 > ZOrderIndex2) { int temp = sortedContents[i]; sortedContents[i] = sortedContents[j]; sortedContents[j] = temp; } } } } // show non-document IDockContent first to avoid screen flickers for (int i = 0; i < contents.Length; i++) { IDockContent content = dockPanel.Contents[sortedContents[i]]; if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState != DockState.Document) content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden; } // after all non-document IDockContent, show document IDockContent for (int i = 0; i < contents.Length; i++) { IDockContent content = dockPanel.Contents[sortedContents[i]]; if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState == DockState.Document) content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden; } for (int i = 0; i < panes.Length; i++) dockPanel.Panes[i].ActiveContent = panes[i].IndexActiveContent == -1 ? null : dockPanel.Contents[panes[i].IndexActiveContent]; if (dockPanelStruct.IndexActiveDocumentPane != -1) dockPanel.Panes[dockPanelStruct.IndexActiveDocumentPane].Activate(); if (dockPanelStruct.IndexActivePane != -1) dockPanel.Panes[dockPanelStruct.IndexActivePane].Activate(); for (int i = dockPanel.Contents.Count - 1; i >= 0; i--) if (dockPanel.Contents[i] is DummyContent) dockPanel.Contents[i].DockHandler.Form.Close(); dockPanel.ResumeLayout(true, true); }
public void Show(DockPanel dockPanel, DockState dockState) { if (dockPanel == null) throw(new ArgumentNullException(Strings.DockContentHandler_Show_NullDockPanel)); if (dockState == DockState.Unknown || dockState == DockState.Hidden) throw(new ArgumentException(Strings.DockContentHandler_Show_InvalidDockState)); dockPanel.SuspendLayout(true); DockPanel = dockPanel; if (dockState == DockState.Float && FloatPane == null) Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.Float, true); else if (PanelPane == null) { DockPane paneExisting = null; foreach (DockPane pane in DockPanel.Panes) if (pane.DockState == dockState) { paneExisting = pane; break; } if (paneExisting == null) Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, dockState, true); else Pane = paneExisting; } DockState = dockState; Activate(); dockPanel.ResumeLayout(true, true); }
public static void LoadFromXml(DockPanel dockPanel, Stream stream, DeserializeDockContent deserializeContent, bool closeStream) { if (dockPanel.Contents.Count != 0) { throw new InvalidOperationException(Strings.DockPanel_LoadFromXml_AlreadyInitialized); } DockPanelStruct dockPanelStruct; ContentStruct[] contents; PaneStruct[] panes; DockWindowStruct[] dockWindows; FloatWindowStruct[] floatWindows; using (var xmlIn = new XmlTextReader(stream) { WhitespaceHandling = WhitespaceHandling.None }) { xmlIn.MoveToContent(); while (!xmlIn.Name.Equals("DockPanel")) { if (!MoveToNextElement(xmlIn)) { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } } string formatVersion = xmlIn.GetAttribute("FormatVersion"); if (!IsFormatVersionValid(formatVersion)) { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidFormatVersion); } dockPanelStruct = new DockPanelStruct(); dockPanelStruct.DockLeftPortion = Convert.ToDouble(xmlIn.GetAttribute("DockLeftPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockRightPortion = Convert.ToDouble(xmlIn.GetAttribute("DockRightPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockTopPortion = Convert.ToDouble(xmlIn.GetAttribute("DockTopPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockBottomPortion = Convert.ToDouble(xmlIn.GetAttribute("DockBottomPortion"), CultureInfo.InvariantCulture); dockPanelStruct.IndexActiveDocumentPane = Convert.ToInt32(xmlIn.GetAttribute("ActiveDocumentPane"), CultureInfo.InvariantCulture); dockPanelStruct.IndexActivePane = Convert.ToInt32(xmlIn.GetAttribute("ActivePane"), CultureInfo.InvariantCulture); // Load Contents MoveToNextElement(xmlIn); if (xmlIn.Name != "Contents") { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } contents = LoadContents(xmlIn); // Load Panes if (xmlIn.Name != "Panes") { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } panes = LoadPanes(xmlIn); // Load DockWindows if (xmlIn.Name != "DockWindows") { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } dockWindows = LoadDockWindows(xmlIn, dockPanel); // Load FloatWindows if (xmlIn.Name != "FloatWindows") { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } floatWindows = LoadFloatWindows(xmlIn); if (closeStream) { xmlIn.Close(); } } dockPanel.SuspendLayout(true); dockPanel.DockLeftPortion = dockPanelStruct.DockLeftPortion; dockPanel.DockRightPortion = dockPanelStruct.DockRightPortion; dockPanel.DockTopPortion = dockPanelStruct.DockTopPortion; dockPanel.DockBottomPortion = dockPanelStruct.DockBottomPortion; // Set DockWindow ZOrders int prevMaxDockWindowZOrder = int.MaxValue; for (int i = 0; i < dockWindows.Length; i++) { int maxDockWindowZOrder = -1; int index = -1; for (int j = 0; j < dockWindows.Length; j++) { if (dockWindows[j].ZOrderIndex > maxDockWindowZOrder && dockWindows[j].ZOrderIndex < prevMaxDockWindowZOrder) { maxDockWindowZOrder = dockWindows[j].ZOrderIndex; index = j; } } dockPanel.DockWindows[dockWindows[index].DockState].BringToFront(); prevMaxDockWindowZOrder = maxDockWindowZOrder; } // Create Contents for (int i = 0; i < contents.Length; i++) { IDockContent content = deserializeContent(contents[i].PersistString); if (content == null) { content = new DummyContent(); } content.DockHandler.DockPanel = dockPanel; content.DockHandler.AutoHidePortion = contents[i].AutoHidePortion; content.DockHandler.IsHidden = true; content.DockHandler.IsFloat = contents[i].IsFloat; } // Create panes for (int i = 0; i < panes.Length; i++) { DockPane pane = null; for (int j = 0; j < panes[i].IndexContents.Length; j++) { IDockContent content = dockPanel.Contents[panes[i].IndexContents[j]]; if (j == 0) { pane = dockPanel.Theme.Extender.DockPaneFactory.CreateDockPane(content, panes[i].DockState, false); } else if (panes[i].DockState == DockState.Float) { content.DockHandler.FloatPane = pane; } else { content.DockHandler.PanelPane = pane; } } } // Assign Panes to DockWindows for (int i = 0; i < dockWindows.Length; i++) { for (int j = 0; j < dockWindows[i].NestedPanes.Length; j++) { DockWindow dw = dockPanel.DockWindows[dockWindows[i].DockState]; int indexPane = dockWindows[i].NestedPanes[j].IndexPane; DockPane pane = dockPanel.Panes[indexPane]; int indexPrevPane = dockWindows[i].NestedPanes[j].IndexPrevPane; DockPane prevPane = (indexPrevPane == -1) ? dw.NestedPanes.GetDefaultPreviousPane(pane) : dockPanel.Panes[indexPrevPane]; DockAlignment alignment = dockWindows[i].NestedPanes[j].Alignment; double proportion = dockWindows[i].NestedPanes[j].Proportion; pane.DockTo(dw, prevPane, alignment, proportion); if (panes[indexPane].DockState == dw.DockState) { panes[indexPane].ZOrderIndex = dockWindows[i].ZOrderIndex; } } } // Create float windows for (int i = 0; i < floatWindows.Length; i++) { FloatWindow fw = null; for (int j = 0; j < floatWindows[i].NestedPanes.Length; j++) { int indexPane = floatWindows[i].NestedPanes[j].IndexPane; DockPane pane = dockPanel.Panes[indexPane]; if (j == 0) { fw = dockPanel.Theme.Extender.FloatWindowFactory.CreateFloatWindow(dockPanel, pane, floatWindows[i].Bounds); } else { int indexPrevPane = floatWindows[i].NestedPanes[j].IndexPrevPane; DockPane prevPane = indexPrevPane == -1 ? null : dockPanel.Panes[indexPrevPane]; DockAlignment alignment = floatWindows[i].NestedPanes[j].Alignment; double proportion = floatWindows[i].NestedPanes[j].Proportion; pane.DockTo(fw, prevPane, alignment, proportion); } if (panes[indexPane].DockState == fw.DockState) { panes[indexPane].ZOrderIndex = floatWindows[i].ZOrderIndex; } } } // sort IDockContent by its Pane's ZOrder int[] sortedContents = null; if (contents.Length > 0) { sortedContents = new int[contents.Length]; for (int i = 0; i < contents.Length; i++) { sortedContents[i] = i; } int lastDocument = contents.Length; for (int i = 0; i < contents.Length - 1; i++) { for (int j = i + 1; j < contents.Length; j++) { DockPane pane1 = dockPanel.Contents[sortedContents[i]].DockHandler.Pane; int ZOrderIndex1 = pane1 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane1)].ZOrderIndex; DockPane pane2 = dockPanel.Contents[sortedContents[j]].DockHandler.Pane; int ZOrderIndex2 = pane2 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane2)].ZOrderIndex; if (ZOrderIndex1 > ZOrderIndex2) { int temp = sortedContents[i]; sortedContents[i] = sortedContents[j]; sortedContents[j] = temp; } } } } // show non-document IDockContent first to avoid screen flickers for (int i = 0; i < contents.Length; i++) { IDockContent content = dockPanel.Contents[sortedContents[i]]; if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState != DockState.Document) { content.DockHandler.SuspendAutoHidePortionUpdates = true; content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden; content.DockHandler.SuspendAutoHidePortionUpdates = false; } } // after all non-document IDockContent, show document IDockContent for (int i = 0; i < contents.Length; i++) { IDockContent content = dockPanel.Contents[sortedContents[i]]; if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState == DockState.Document) { content.DockHandler.SuspendAutoHidePortionUpdates = true; content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden; content.DockHandler.SuspendAutoHidePortionUpdates = false; } } for (int i = 0; i < panes.Length; i++) { dockPanel.Panes[i].ActiveContent = panes[i].IndexActiveContent == -1 ? null : dockPanel.Contents[panes[i].IndexActiveContent]; } if (dockPanelStruct.IndexActiveDocumentPane >= 0 && dockPanel.Panes.Count > dockPanelStruct.IndexActiveDocumentPane) { dockPanel.Panes[dockPanelStruct.IndexActiveDocumentPane].Activate(); } if (dockPanelStruct.IndexActivePane >= 0 && dockPanel.Panes.Count > dockPanelStruct.IndexActivePane) { dockPanel.Panes[dockPanelStruct.IndexActivePane].Activate(); } for (int i = dockPanel.Contents.Count - 1; i >= 0; i--) { if (dockPanel.Contents[i] is DummyContent) { dockPanel.Contents[i].DockHandler.Form.Close(); } } dockPanel.ResumeLayout(true, true); }
public void Show(DockPanel dockPanel, DockState dockState) { if (dockPanel == null) { throw(new ArgumentNullException(Strings.DockContentHandler_Show_NullDockPanel)); } if (dockState == DockState.Unknown || dockState == DockState.Hidden) { throw(new ArgumentException(Strings.DockContentHandler_Show_InvalidDockState)); } dockPanel.SuspendLayout(true); DockPanel = dockPanel; if (dockState == DockState.Float) { if (FloatPane == null) { Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.Float, true); } } else if (PanelPane == null) { DockPane paneExisting = null; foreach (DockPane pane in DockPanel.Panes) { if (pane.DockState == dockState) { if (paneExisting == null || pane.IsActivated) { paneExisting = pane; } if (pane.IsActivated) { break; } } } if (paneExisting == null) { Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, dockState, true); } else { Pane = paneExisting; } } DockState = dockState; //we'll resume the layout before activating to ensure that the position //and size of the form are finally processed before the form is shown dockPanel.ResumeLayout(true, true); if (m_activateOnShow) { Activate(); } }
internal void SetDockState(bool isHidden, DockState visibleState, DockPane oldPane) { if (IsSuspendSetDockState) { return; } if (DockPanel == null && visibleState != DockState.Unknown) { throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_NullPanel); } if (visibleState == DockState.Hidden || (visibleState != DockState.Unknown && !IsDockStateValid(visibleState))) { throw new InvalidOperationException(Strings.DockContentHandler_SetDockState_InvalidState); } DockPanel dockPanel = DockPanel; if (dockPanel != null) { dockPanel.SuspendLayout(true); } SuspendSetDockState(); DockState oldDockState = DockState; if (m_isHidden != isHidden || oldDockState == DockState.Unknown) { m_isHidden = isHidden; } m_visibleState = visibleState; m_dockState = isHidden ? DockState.Hidden : visibleState; if (visibleState == DockState.Unknown) { Pane = null; } else { m_isFloat = (m_visibleState == DockState.Float); if (Pane == null) { Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, visibleState, true); } else if (Pane.DockState != visibleState) { if (Pane.Contents.Count == 1) { Pane.SetDockState(visibleState); } else { Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, visibleState, true); } } } if (Form.ContainsFocus) { if (DockState == DockState.Hidden || DockState == DockState.Unknown) { if (!Win32Helper.IsRunningOnMono) { DockPanel.ContentFocusManager.GiveUpFocus(Content); } } } SetPaneAndVisible(Pane); if (oldPane != null && !oldPane.IsDisposed && oldDockState == oldPane.DockState) { RefreshDockPane(oldPane); } if (Pane != null && DockState == Pane.DockState) { if ((Pane != oldPane) || (Pane == oldPane && oldDockState != oldPane.DockState)) { // Avoid early refresh of hidden AutoHide panes if ((Pane.DockWindow == null || Pane.DockWindow.Visible || Pane.IsHidden) && !Pane.IsAutoHide) { RefreshDockPane(Pane); } } } if (oldDockState != DockState) { if (DockState == DockState.Hidden || DockState == DockState.Unknown || DockHelper.IsDockStateAutoHide(DockState)) { if (!Win32Helper.IsRunningOnMono) { DockPanel.ContentFocusManager.RemoveFromList(Content); } } else if (!Win32Helper.IsRunningOnMono) { DockPanel.ContentFocusManager.AddToList(Content); } ResetAutoHidePortion(oldDockState, DockState); OnDockStateChanged(EventArgs.Empty); } ResumeSetDockState(); if (dockPanel != null) { dockPanel.ResumeLayout(true, true); } }
public static void LoadFromXml(DockPanel dockPanel, Stream stream, DeserializeDockContent deserializeContent, bool closeStream) { if (dockPanel.Contents.Count != 0) { throw new InvalidOperationException(Strings.DockPanel_LoadFromXml_AlreadyInitialized); } XmlTextReader xmlIn = new XmlTextReader(stream); xmlIn.WhitespaceHandling = WhitespaceHandling.None; xmlIn.MoveToContent(); while (!xmlIn.Name.Equals("DockPanel")) { if (!MoveToNextElement(xmlIn)) { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } } string formatVersion = xmlIn.GetAttribute("FormatVersion"); if (!IsFormatVersionValid(formatVersion)) { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidFormatVersion); } DockPanelStruct dockPanelStruct = new DockPanelStruct(); dockPanelStruct.DockLeftPortion = Convert.ToDouble(xmlIn.GetAttribute("DockLeftPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockRightPortion = Convert.ToDouble(xmlIn.GetAttribute("DockRightPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockTopPortion = Convert.ToDouble(xmlIn.GetAttribute("DockTopPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockBottomPortion = Convert.ToDouble(xmlIn.GetAttribute("DockBottomPortion"), CultureInfo.InvariantCulture); dockPanelStruct.IndexActiveDocumentPane = Convert.ToInt32(xmlIn.GetAttribute("ActiveDocumentPane"), CultureInfo.InvariantCulture); dockPanelStruct.IndexActivePane = Convert.ToInt32(xmlIn.GetAttribute("ActivePane"), CultureInfo.InvariantCulture); // Load Contents MoveToNextElement(xmlIn); if (xmlIn.Name != "Contents") { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } ContentStruct[] contents = LoadContents(xmlIn); // Load Panes if (xmlIn.Name != "Panes") { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } PaneStruct[] panes = LoadPanes(xmlIn); // Load DockWindows if (xmlIn.Name != "DockWindows") { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } DockWindowStruct[] dockWindows = LoadDockWindows(xmlIn, dockPanel); // Load FloatWindows if (xmlIn.Name != "FloatWindows") { throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } FloatWindowStruct[] floatWindows = LoadFloatWindows(xmlIn); if (closeStream) { xmlIn.Close(); } dockPanel.SuspendLayout(true); dockPanel.DockLeftPortion = dockPanelStruct.DockLeftPortion; dockPanel.DockRightPortion = dockPanelStruct.DockRightPortion; dockPanel.DockTopPortion = dockPanelStruct.DockTopPortion; dockPanel.DockBottomPortion = dockPanelStruct.DockBottomPortion; // Set DockWindow ZOrders int prevMaxDockWindowZOrder = int.MaxValue; for (int i = 0; i < dockWindows.Length; i++) { int maxDockWindowZOrder = -1; int index = -1; for (int j = 0; j < dockWindows.Length; j++) { if (dockWindows[j].ZOrderIndex > maxDockWindowZOrder && dockWindows[j].ZOrderIndex < prevMaxDockWindowZOrder) { maxDockWindowZOrder = dockWindows[j].ZOrderIndex; index = j; } } dockPanel.DockWindows[dockWindows[index].DockState].BringToFront(); prevMaxDockWindowZOrder = maxDockWindowZOrder; } // Create Contents for (int i = 0; i < contents.Length; i++) { IDockContent content = deserializeContent(contents[i].PersistString); if (content == null) { content = new DummyContent(); } content.DockHandler.DockPanel = dockPanel; content.DockHandler.AutoHidePortion = contents[i].AutoHidePortion; // "avoiding flickering" will cause "exception" at DockPane.cs:153 that I screened // and global failure of LoadXml() //content.DockHandler.IsHidden = true; content.DockHandler.IsHidden = false; content.DockHandler.IsFloat = contents[i].IsFloat; } // Create panes for (int i = 0; i < panes.Length; i++) { DockPane pane = null; PaneStruct paneStruct = panes[i]; for (int j = 0; j < paneStruct.IndexContents.Length; j++) { try { int idx = paneStruct.IndexContents[j]; IDockContent content = dockPanel.Contents[idx]; if (content == null || content.DockHandler == null) { string msg = "avoiding exception"; continue; } if (j == 0) { pane = dockPanel.DockPaneFactory.CreateDockPane(content, paneStruct.DockState, false); } else if (paneStruct.DockState == DockState.Float) { content.DockHandler.FloatPane = pane; } else { content.DockHandler.PanelPane = pane; } } catch (Exception e) { continue; } } } // Assign Panes to DockWindows for (int i = 0; i < dockWindows.Length; i++) { for (int j = 0; j < dockWindows[i].NestedPanes.Length; j++) { DockWindow dw = dockPanel.DockWindows[dockWindows[i].DockState]; int indexPane = dockWindows[i].NestedPanes[j].IndexPane; DockPane pane = dockPanel.Panes[indexPane]; int indexPrevPane = dockWindows[i].NestedPanes[j].IndexPrevPane; DockPane prevPane = (indexPrevPane == -1) ? dw.NestedPanes.GetDefaultPreviousPane(pane) : dockPanel.Panes[indexPrevPane]; DockAlignment alignment = dockWindows[i].NestedPanes[j].Alignment; double proportion = dockWindows[i].NestedPanes[j].Proportion; pane.DockTo(dw, prevPane, alignment, proportion); if (panes[indexPane].DockState == dw.DockState) { panes[indexPane].ZOrderIndex = dockWindows[i].ZOrderIndex; } } } // Create float windows for (int i = 0; i < floatWindows.Length; i++) { FloatWindow fw = null; for (int j = 0; j < floatWindows[i].NestedPanes.Length; j++) { int indexPane = floatWindows[i].NestedPanes[j].IndexPane; DockPane pane = dockPanel.Panes[indexPane]; if (j == 0) { fw = dockPanel.FloatWindowFactory.CreateFloatWindow(dockPanel, pane, floatWindows[i].Bounds); } else { int indexPrevPane = floatWindows[i].NestedPanes[j].IndexPrevPane; DockPane prevPane = indexPrevPane == -1 ? null : dockPanel.Panes[indexPrevPane]; DockAlignment alignment = floatWindows[i].NestedPanes[j].Alignment; double proportion = floatWindows[i].NestedPanes[j].Proportion; pane.DockTo(fw, prevPane, alignment, proportion); } if (panes[indexPane].DockState == fw.DockState) { panes[indexPane].ZOrderIndex = floatWindows[i].ZOrderIndex; } } } // sort IDockContent by its Pane's ZOrder int[] sortedContents = null; if (contents.Length > 0) { sortedContents = new int[contents.Length]; for (int i = 0; i < contents.Length; i++) { sortedContents[i] = i; } int lastDocument = contents.Length; for (int i = 0; i < contents.Length - 1; i++) { int sorted_i = sortedContents[i]; for (int j = i + 1; j < contents.Length; j++) { int sorted_j = sortedContents[j]; try { if (sorted_i >= dockPanel.Contents.Count) { string msg = "slow pointer went beyond the array length"; } if (sorted_j >= dockPanel.Contents.Count) { string msg = "fast pointer went beyond the array length"; } if (dockPanel.Contents[sorted_j].DockHandler == null) { string msg = "where is my handler?..."; } DockPane pane1 = dockPanel.Contents[sorted_i].DockHandler.Pane; int ZOrderIndex1 = pane1 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane1)].ZOrderIndex; DockPane pane2 = dockPanel.Contents[sorted_j].DockHandler.Pane; int ZOrderIndex2 = pane2 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane2)].ZOrderIndex; if (ZOrderIndex1 > ZOrderIndex2) { int temp = sorted_i; sortedContents[i] = sorted_j; sortedContents[j] = temp; } } catch (Exception ex) { continue; } } } } // show non-document IDockContent first to avoid screen flickers for (int i = 0; i < contents.Length; i++) { int sorted_i = sortedContents[i]; if (sorted_i >= dockPanel.Contents.Count) { string msg = "Huston we have a problem"; } IDockContent content = dockPanel.Contents[sorted_i]; if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState != DockState.Document) { // floating windows should not be marked IsHidden in Layout.xml... //if they are, that will cause "ActiveContent must be one of the visible contents"" content.DockHandler.IsHidden = contents[sorted_i].IsHidden; //content.DockHandler.IsHidden = false; } } // after all non-document IDockContent, show document IDockContent for (int i = 0; i < contents.Length; i++) { int sorted_i = sortedContents[i]; IDockContent content = dockPanel.Contents[sorted_i]; if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState == DockState.Document) { // but here I don't want to hide panes which are unserialized as hidden!! // minimized ExceptionForm will disappear and that will make hidden: ChartForm and corresponding EditorForm // hm it looks okay, I don't know what healed ExceptionForm... content.DockHandler.IsHidden = contents[sorted_i].IsHidden; //content.DockHandler.IsHidden = false; } } for (int i = 0; i < panes.Length; i++) { PaneStruct pane_i = panes[i]; DockPane destination = dockPanel.Panes[i]; int paneActiveContentIndex = pane_i.IndexActiveContent; //try { // destination.ActiveContent = paneActiveContentIndex == -1 // ? null : dockPanel.Contents[paneActiveContentIndex]; //} catch (Exception ex) { // int a = 1; //} if (paneActiveContentIndex != -1) { destination.ActiveContent = dockPanel.Contents[paneActiveContentIndex]; } } if (dockPanelStruct.IndexActiveDocumentPane != -1) { dockPanel.Panes[dockPanelStruct.IndexActiveDocumentPane].Activate(); } if (dockPanelStruct.IndexActivePane != -1) { dockPanel.Panes[dockPanelStruct.IndexActivePane].Activate(); } for (int i = dockPanel.Contents.Count - 1; i >= 0; i--) { if (dockPanel.Contents[i] is DummyContent) { dockPanel.Contents[i].DockHandler.Form.Close(); } } dockPanel.ResumeLayout(true, true); }
public static void LoadFromXml(DockPanel dockPanel, Stream stream, DeserializeDockContent deserializeContent, bool closeStream) { if (dockPanel.Contents.Count != 0) throw new InvalidOperationException(Strings.DockPanel_LoadFromXml_AlreadyInitialized); XmlTextReader xmlIn = new XmlTextReader(stream); xmlIn.WhitespaceHandling = WhitespaceHandling.None; xmlIn.MoveToContent(); while (!xmlIn.Name.Equals("DockPanel")) { if (!MoveToNextElement(xmlIn)) throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } string formatVersion = xmlIn.GetAttribute("FormatVersion"); if (!IsFormatVersionValid(formatVersion)) throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidFormatVersion); DockPanelStruct dockPanelStruct = new DockPanelStruct(); dockPanelStruct.DockLeftPortion = Convert.ToDouble(xmlIn.GetAttribute("DockLeftPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockRightPortion = Convert.ToDouble(xmlIn.GetAttribute("DockRightPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockTopPortion = Convert.ToDouble(xmlIn.GetAttribute("DockTopPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockBottomPortion = Convert.ToDouble(xmlIn.GetAttribute("DockBottomPortion"), CultureInfo.InvariantCulture); dockPanelStruct.IndexActiveDocumentPane = Convert.ToInt32(xmlIn.GetAttribute("ActiveDocumentPane"), CultureInfo.InvariantCulture); dockPanelStruct.IndexActivePane = Convert.ToInt32(xmlIn.GetAttribute("ActivePane"), CultureInfo.InvariantCulture); // Load Contents MoveToNextElement(xmlIn); if (xmlIn.Name != "Contents") throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); ContentStruct[] contents = LoadContents(xmlIn); // Load Panes if (xmlIn.Name != "Panes") throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); PaneStruct[] panes = LoadPanes(xmlIn); // Load DockWindows if (xmlIn.Name != "DockWindows") throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); DockWindowStruct[] dockWindows = LoadDockWindows(xmlIn, dockPanel); // Load FloatWindows if (xmlIn.Name != "FloatWindows") throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); FloatWindowStruct[] floatWindows = LoadFloatWindows(xmlIn); if (closeStream) xmlIn.Close(); dockPanel.SuspendLayout(true); dockPanel.DockLeftPortion = dockPanelStruct.DockLeftPortion; dockPanel.DockRightPortion = dockPanelStruct.DockRightPortion; dockPanel.DockTopPortion = dockPanelStruct.DockTopPortion; dockPanel.DockBottomPortion = dockPanelStruct.DockBottomPortion; // Set DockWindow ZOrders int prevMaxDockWindowZOrder = int.MaxValue; for (int i = 0; i < dockWindows.Length; i++) { int maxDockWindowZOrder = -1; int index = -1; for (int j = 0; j < dockWindows.Length; j++) { if (dockWindows[j].ZOrderIndex > maxDockWindowZOrder && dockWindows[j].ZOrderIndex < prevMaxDockWindowZOrder) { maxDockWindowZOrder = dockWindows[j].ZOrderIndex; index = j; } } dockPanel.DockWindows[dockWindows[index].DockState].BringToFront(); prevMaxDockWindowZOrder = maxDockWindowZOrder; } // Create Contents for (int i = 0; i < contents.Length; i++) { IDockContent content = deserializeContent(contents[i].PersistString); if (content == null) content = new DummyContent(); content.DockHandler.DockPanel = dockPanel; content.DockHandler.AutoHidePortion = contents[i].AutoHidePortion; content.DockHandler.IsHidden = true; content.DockHandler.IsFloat = contents[i].IsFloat; } // Create panes for (int i = 0; i < panes.Length; i++) { DockPane pane = null; for (int j = 0; j < panes[i].IndexContents.Length; j++) { IDockContent content = dockPanel.Contents[panes[i].IndexContents[j]]; if (j == 0) pane = dockPanel.DockPaneFactory.CreateDockPane(content, panes[i].DockState, false); else if (panes[i].DockState == DockState.Float) content.DockHandler.FloatPane = pane; else content.DockHandler.PanelPane = pane; } } // Assign Panes to DockWindows for (int i = 0; i < dockWindows.Length; i++) { for (int j = 0; j < dockWindows[i].NestedPanes.Length; j++) { DockWindow dw = dockPanel.DockWindows[dockWindows[i].DockState]; int indexPane = dockWindows[i].NestedPanes[j].IndexPane; DockPane pane = dockPanel.Panes[indexPane]; int indexPrevPane = dockWindows[i].NestedPanes[j].IndexPrevPane; DockPane prevPane = (indexPrevPane == -1) ? dw.NestedPanes.GetDefaultPreviousPane(pane) : dockPanel.Panes[indexPrevPane]; DockAlignment alignment = dockWindows[i].NestedPanes[j].Alignment; double proportion = dockWindows[i].NestedPanes[j].Proportion; pane.DockTo(dw, prevPane, alignment, proportion); if (panes[indexPane].DockState == dw.DockState) panes[indexPane].ZOrderIndex = dockWindows[i].ZOrderIndex; } } // Create float windows for (int i = 0; i < floatWindows.Length; i++) { FloatWindow fw = null; for (int j = 0; j < floatWindows[i].NestedPanes.Length; j++) { int indexPane = floatWindows[i].NestedPanes[j].IndexPane; DockPane pane = dockPanel.Panes[indexPane]; if (j == 0) fw = dockPanel.FloatWindowFactory.CreateFloatWindow(dockPanel, pane, floatWindows[i].Bounds); else { int indexPrevPane = floatWindows[i].NestedPanes[j].IndexPrevPane; DockPane prevPane = indexPrevPane == -1 ? null : dockPanel.Panes[indexPrevPane]; DockAlignment alignment = floatWindows[i].NestedPanes[j].Alignment; double proportion = floatWindows[i].NestedPanes[j].Proportion; pane.DockTo(fw, prevPane, alignment, proportion); } if (panes[indexPane].DockState == fw.DockState) panes[indexPane].ZOrderIndex = floatWindows[i].ZOrderIndex; } } // sort IDockContent by its Pane's ZOrder int[] sortedContents = null; if (contents.Length > 0) { sortedContents = new int[contents.Length]; for (int i = 0; i < contents.Length; i++) sortedContents[i] = i; int lastDocument = contents.Length; for (int i = 0; i < contents.Length - 1; i++) { for (int j = i + 1; j < contents.Length; j++) { DockPane pane1 = dockPanel.Contents[sortedContents[i]].DockHandler.Pane; int ZOrderIndex1 = pane1 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane1)].ZOrderIndex; DockPane pane2 = dockPanel.Contents[sortedContents[j]].DockHandler.Pane; int ZOrderIndex2 = pane2 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane2)].ZOrderIndex; if (ZOrderIndex1 > ZOrderIndex2) { int temp = sortedContents[i]; sortedContents[i] = sortedContents[j]; sortedContents[j] = temp; } } } } // show non-document IDockContent first to avoid screen flickers for (int i = 0; i < contents.Length; i++) { IDockContent content = dockPanel.Contents[sortedContents[i]]; if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState != DockState.Document) content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden; } // after all non-document IDockContent, show document IDockContent for (int i = 0; i < contents.Length; i++) { IDockContent content = dockPanel.Contents[sortedContents[i]]; if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState == DockState.Document) content.DockHandler.IsHidden = contents[sortedContents[i]].IsHidden; } for (int i = 0; i < panes.Length; i++) dockPanel.Panes[i].ActiveContent = panes[i].IndexActiveContent == -1 ? null : dockPanel.Contents[panes[i].IndexActiveContent]; if (dockPanelStruct.IndexActiveDocumentPane != -1) dockPanel.Panes[dockPanelStruct.IndexActiveDocumentPane].Activate(); if (dockPanelStruct.IndexActivePane != -1) dockPanel.Panes[dockPanelStruct.IndexActivePane].Activate(); for (int i = dockPanel.Contents.Count - 1; i >= 0; i--) if (dockPanel.Contents[i] is DummyContent) dockPanel.Contents[i].DockHandler.Form.Close(); dockPanel.ResumeLayout(true, true); }
public static void LoadFromXml(DockPanel dockPanel, Stream stream, DeserializeDockContent deserializeContent, bool closeStream) { if (dockPanel.Contents.Count != 0) throw new InvalidOperationException(Strings.DockPanel_LoadFromXml_AlreadyInitialized); XmlTextReader xmlIn = new XmlTextReader(stream); xmlIn.WhitespaceHandling = WhitespaceHandling.None; xmlIn.MoveToContent(); while (!xmlIn.Name.Equals("DockPanel")) { if (!MoveToNextElement(xmlIn)) throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); } string formatVersion = xmlIn.GetAttribute("FormatVersion"); if (!IsFormatVersionValid(formatVersion)) throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidFormatVersion); DockPanelStruct dockPanelStruct = new DockPanelStruct(); dockPanelStruct.DockLeftPortion = Convert.ToDouble(xmlIn.GetAttribute("DockLeftPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockRightPortion = Convert.ToDouble(xmlIn.GetAttribute("DockRightPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockTopPortion = Convert.ToDouble(xmlIn.GetAttribute("DockTopPortion"), CultureInfo.InvariantCulture); dockPanelStruct.DockBottomPortion = Convert.ToDouble(xmlIn.GetAttribute("DockBottomPortion"), CultureInfo.InvariantCulture); dockPanelStruct.IndexActiveDocumentPane = Convert.ToInt32(xmlIn.GetAttribute("ActiveDocumentPane"), CultureInfo.InvariantCulture); dockPanelStruct.IndexActivePane = Convert.ToInt32(xmlIn.GetAttribute("ActivePane"), CultureInfo.InvariantCulture); // Load Contents MoveToNextElement(xmlIn); if (xmlIn.Name != "Contents") throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); ContentStruct[] contents = LoadContents(xmlIn); // Load Panes if (xmlIn.Name != "Panes") throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); PaneStruct[] panes = LoadPanes(xmlIn); // Load DockWindows if (xmlIn.Name != "DockWindows") throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); DockWindowStruct[] dockWindows = LoadDockWindows(xmlIn, dockPanel); // Load FloatWindows if (xmlIn.Name != "FloatWindows") throw new ArgumentException(Strings.DockPanel_LoadFromXml_InvalidXmlFormat); FloatWindowStruct[] floatWindows = LoadFloatWindows(xmlIn); if (closeStream) xmlIn.Close(); dockPanel.SuspendLayout(true); dockPanel.DockLeftPortion = dockPanelStruct.DockLeftPortion; dockPanel.DockRightPortion = dockPanelStruct.DockRightPortion; dockPanel.DockTopPortion = dockPanelStruct.DockTopPortion; dockPanel.DockBottomPortion = dockPanelStruct.DockBottomPortion; // Set DockWindow ZOrders int prevMaxDockWindowZOrder = int.MaxValue; for (int i = 0; i < dockWindows.Length; i++) { int maxDockWindowZOrder = -1; int index = -1; for (int j = 0; j < dockWindows.Length; j++) { if (dockWindows[j].ZOrderIndex > maxDockWindowZOrder && dockWindows[j].ZOrderIndex < prevMaxDockWindowZOrder) { maxDockWindowZOrder = dockWindows[j].ZOrderIndex; index = j; } } dockPanel.DockWindows[dockWindows[index].DockState].BringToFront(); prevMaxDockWindowZOrder = maxDockWindowZOrder; } // Create Contents for (int i = 0; i < contents.Length; i++) { IDockContent content = deserializeContent(contents[i].PersistString); if (content == null) content = new DummyContent(); content.DockHandler.DockPanel = dockPanel; content.DockHandler.AutoHidePortion = contents[i].AutoHidePortion; // "avoiding flickering" will cause "exception" at DockPane.cs:153 that I screened // and global failure of LoadXml() //content.DockHandler.IsHidden = true; content.DockHandler.IsHidden = false; content.DockHandler.IsFloat = contents[i].IsFloat; } // Create panes for (int i = 0; i < panes.Length; i++) { DockPane pane = null; PaneStruct paneStruct = panes[i]; for (int j = 0; j < paneStruct.IndexContents.Length; j++) { try { int idx = paneStruct.IndexContents[j]; IDockContent content = dockPanel.Contents[idx]; if (content == null || content.DockHandler == null) { string msg = "avoiding exception"; continue; } if (j == 0) pane = dockPanel.DockPaneFactory.CreateDockPane(content, paneStruct.DockState, false); else if (paneStruct.DockState == DockState.Float) content.DockHandler.FloatPane = pane; else content.DockHandler.PanelPane = pane; } catch (Exception e) { continue; } } } // Assign Panes to DockWindows for (int i = 0; i < dockWindows.Length; i++) { for (int j = 0; j < dockWindows[i].NestedPanes.Length; j++) { DockWindow dw = dockPanel.DockWindows[dockWindows[i].DockState]; int indexPane = dockWindows[i].NestedPanes[j].IndexPane; DockPane pane = dockPanel.Panes[indexPane]; int indexPrevPane = dockWindows[i].NestedPanes[j].IndexPrevPane; DockPane prevPane = (indexPrevPane == -1) ? dw.NestedPanes.GetDefaultPreviousPane(pane) : dockPanel.Panes[indexPrevPane]; DockAlignment alignment = dockWindows[i].NestedPanes[j].Alignment; double proportion = dockWindows[i].NestedPanes[j].Proportion; pane.DockTo(dw, prevPane, alignment, proportion); if (panes[indexPane].DockState == dw.DockState) panes[indexPane].ZOrderIndex = dockWindows[i].ZOrderIndex; } } // Create float windows for (int i = 0; i < floatWindows.Length; i++) { FloatWindow fw = null; for (int j = 0; j < floatWindows[i].NestedPanes.Length; j++) { int indexPane = floatWindows[i].NestedPanes[j].IndexPane; DockPane pane = dockPanel.Panes[indexPane]; if (j == 0) fw = dockPanel.FloatWindowFactory.CreateFloatWindow(dockPanel, pane, floatWindows[i].Bounds); else { int indexPrevPane = floatWindows[i].NestedPanes[j].IndexPrevPane; DockPane prevPane = indexPrevPane == -1 ? null : dockPanel.Panes[indexPrevPane]; DockAlignment alignment = floatWindows[i].NestedPanes[j].Alignment; double proportion = floatWindows[i].NestedPanes[j].Proportion; pane.DockTo(fw, prevPane, alignment, proportion); } if (panes[indexPane].DockState == fw.DockState) panes[indexPane].ZOrderIndex = floatWindows[i].ZOrderIndex; } } // sort IDockContent by its Pane's ZOrder int[] sortedContents = null; if (contents.Length > 0) { sortedContents = new int[contents.Length]; for (int i = 0; i < contents.Length; i++) sortedContents[i] = i; int lastDocument = contents.Length; for (int i = 0; i < contents.Length - 1; i++) { int sorted_i = sortedContents[i]; for (int j = i + 1; j < contents.Length; j++) { int sorted_j = sortedContents[j]; try { if (sorted_i >= dockPanel.Contents.Count) { string msg = "slow pointer went beyond the array length"; } if (sorted_j >= dockPanel.Contents.Count) { string msg = "fast pointer went beyond the array length"; } if (dockPanel.Contents[sorted_j].DockHandler == null) { string msg = "where is my handler?..."; } DockPane pane1 = dockPanel.Contents[sorted_i].DockHandler.Pane; int ZOrderIndex1 = pane1 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane1)].ZOrderIndex; DockPane pane2 = dockPanel.Contents[sorted_j].DockHandler.Pane; int ZOrderIndex2 = pane2 == null ? 0 : panes[dockPanel.Panes.IndexOf(pane2)].ZOrderIndex; if (ZOrderIndex1 > ZOrderIndex2) { int temp = sorted_i; sortedContents[i] = sorted_j; sortedContents[j] = temp; } } catch (Exception ex) { continue; } } } } // show non-document IDockContent first to avoid screen flickers for (int i = 0; i < contents.Length; i++) { int sorted_i = sortedContents[i]; if (sorted_i >= dockPanel.Contents.Count) { string msg = "Huston we have a problem"; } IDockContent content = dockPanel.Contents[sorted_i]; if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState != DockState.Document) { // floating windows should not be marked IsHidden in Layout.xml... //if they are, that will cause "ActiveContent must be one of the visible contents"" content.DockHandler.IsHidden = contents[sorted_i].IsHidden; //content.DockHandler.IsHidden = false; } } // after all non-document IDockContent, show document IDockContent for (int i = 0; i < contents.Length; i++) { int sorted_i = sortedContents[i]; IDockContent content = dockPanel.Contents[sorted_i]; if (content.DockHandler.Pane != null && content.DockHandler.Pane.DockState == DockState.Document) { // but here I don't want to hide panes which are unserialized as hidden!! // minimized ExceptionForm will disappear and that will make hidden: ChartForm and corresponding EditorForm // hm it looks okay, I don't know what healed ExceptionForm... content.DockHandler.IsHidden = contents[sorted_i].IsHidden; //content.DockHandler.IsHidden = false; } } for (int i = 0; i < panes.Length; i++) { PaneStruct pane_i = panes[i]; DockPane destination = dockPanel.Panes[i]; int paneActiveContentIndex = pane_i.IndexActiveContent; //try { // destination.ActiveContent = paneActiveContentIndex == -1 // ? null : dockPanel.Contents[paneActiveContentIndex]; //} catch (Exception ex) { // int a = 1; //} if (paneActiveContentIndex != -1) { destination.ActiveContent = dockPanel.Contents[paneActiveContentIndex]; } } if (dockPanelStruct.IndexActiveDocumentPane != -1) dockPanel.Panes[dockPanelStruct.IndexActiveDocumentPane].Activate(); if (dockPanelStruct.IndexActivePane != -1) dockPanel.Panes[dockPanelStruct.IndexActivePane].Activate(); for (int i = dockPanel.Contents.Count - 1; i >= 0; i--) if (dockPanel.Contents[i] is DummyContent) dockPanel.Contents[i].DockHandler.Form.Close(); dockPanel.ResumeLayout(true, true); }
private void RefreshStateChange(INestedPanesContainer oldContainer, DockState oldDockState) { lock (this) { if (IsRefreshStateChangeSuspended) { return; } SuspendRefreshStateChange(); } DockPanel.SuspendLayout(true); IDockContent contentFocused = GetFocusedContent(); if (contentFocused != null) { DockPanel.SaveFocus(); } SetParent(); if (ActiveContent != null) { ActiveContent.DockHandler.SetDockState(ActiveContent.DockHandler.IsHidden, DockState, ActiveContent.DockHandler.Pane); } foreach (IDockContent content in Contents) { if (content.DockHandler.Pane == this) { content.DockHandler.SetDockState(content.DockHandler.IsHidden, DockState, content.DockHandler.Pane); } } if (oldContainer != null) { Control oldContainerControl = (Control)oldContainer; if (oldContainer.DockState == oldDockState && !oldContainerControl.IsDisposed) { oldContainerControl.PerformLayout(); } } if (DockHelper.IsDockStateAutoHide(oldDockState)) { DockPanel.RefreshActiveAutoHideContent(); } if (NestedPanesContainer.DockState == DockState) { ((Control)NestedPanesContainer).PerformLayout(); } if (DockHelper.IsDockStateAutoHide(DockState)) { DockPanel.RefreshActiveAutoHideContent(); } if (DockHelper.IsDockStateAutoHide(oldDockState) || DockHelper.IsDockStateAutoHide(DockState)) { DockPanel.RefreshAutoHideStrip(); DockPanel.PerformLayout(); } ResumeRefreshStateChange(); if (contentFocused != null) { contentFocused.DockHandler.Activate(); } DockPanel.ResumeLayout(true, true); if (oldDockState != DockState) { OnDockStateChanged(EventArgs.Empty); } }
public void Show(DockPanel dockPanel, DockState dockState) { if (dockPanel == null) throw (new ArgumentNullException(Strings.DockContentHandler_Show_NullDockPanel)); if (dockState == DockState.Unknown || dockState == DockState.Hidden) throw (new ArgumentException(Strings.DockContentHandler_Show_InvalidDockState)); dockPanel.SuspendLayout(true); DockPanel = dockPanel; DockPane paneExisting = null; foreach (DockPane pane in DockPanel.Panes) { if (pane.DockState != dockState) continue; // I want BarDataRangePopup, BarScaleInterval, PositionSizePopup to open in their own floating windows // without continue, the second popup is opened in the floating window of the first // and window size for 2nd = size of 1st despite it was set upstack as Float.Bounds if (pane.Contents.Contains(this.Content) == false) continue; if (paneExisting == null || pane.IsActivated) paneExisting = pane; if (pane.IsActivated) break; } if (dockState == DockState.Float) { if (FloatPane == null) { this.Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, dockState, true); } else { // I don't understand "Activated"/Hidden" but I've found a // deserialized restored (hidden) Pane for BarDataRangePopup, BarScaleInterval, PositionSizePopup this.Pane = FloatPane; //this.Pane = (paneExisting != null) ? paneExisting // : DockPanel.DockPaneFactory.CreateDockPane(Content, dockState, true); } } else if (PanelPane == null) { this.Pane = (paneExisting != null) ? paneExisting : DockPanel.DockPaneFactory.CreateDockPane(Content, dockState, true); } DockState = dockState; dockPanel.ResumeLayout(true, true); //we'll resume the layout before activating to ensure that the position Activate(); //and size of the form are finally processed before the form is shown }
protected override void WndProc(ref Message m) { switch (m.Msg) { case (int)Win32.Msgs.WM_NCLBUTTONDOWN: { if (IsDisposed) { return; } uint result = Win32Helper.IsRunningOnMono ? 0 : NativeMethods.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam); if (result == 2 && DockPanel.AllowEndUserDocking && this.AllowEndUserDocking) // HITTEST_CAPTION { Activate(); m_dockPanel.BeginDrag(this); } else { base.WndProc(ref m); } return; } case (int)Win32.Msgs.WM_NCRBUTTONDOWN: { uint result = Win32Helper.IsRunningOnMono ? 0 : NativeMethods.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam); if (result == 2) // HITTEST_CAPTION { DockPane theOnlyPane = (VisibleNestedPanes.Count == 1) ? VisibleNestedPanes[0] : null; if (theOnlyPane != null && theOnlyPane.ActiveContent != null) { theOnlyPane.ShowTabPageContextMenu(this, PointToClient(Control.MousePosition)); return; } } base.WndProc(ref m); return; } case (int)Win32.Msgs.WM_CLOSE: if (NestedPanes.Count == 0) { base.WndProc(ref m); return; } for (int i = NestedPanes.Count - 1; i >= 0; i--) { DockContentCollection contents = NestedPanes[i].Contents; for (int j = contents.Count - 1; j >= 0; j--) { IDockContent content = contents[j]; if (content.DockHandler.DockState != DockState.Float) { continue; } if (!content.DockHandler.CloseButton) { continue; } if (content.DockHandler.HideOnClose) { content.DockHandler.Hide(); } else { content.DockHandler.Close(); } } } return; case (int)Win32.Msgs.WM_NCLBUTTONDBLCLK: { uint result = !DoubleClickTitleBarToDock || Win32Helper.IsRunningOnMono ? 0 : NativeMethods.SendMessage(this.Handle, (int)Win32.Msgs.WM_NCHITTEST, 0, (uint)m.LParam); if (result != 2) // HITTEST_CAPTION { base.WndProc(ref m); return; } DockPanel.SuspendLayout(true); // Restore to panel foreach (DockPane pane in NestedPanes) { if (pane.DockState != DockState.Float) { continue; } pane.RestoreToPanel(); } DockPanel.ResumeLayout(true, true); return; } case WM_CHECKDISPOSE: if (NestedPanes.Count == 0) { Dispose(); } return; } base.WndProc(ref m); }
// 初始化 public bool Initialize(DockPanel dockPanel) { // 加载配置界面 String applicationPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; String configFile = Path.Combine(Path.GetDirectoryName(applicationPath), "WorldEditor.DockPanel.config"); if (File.Exists(configFile)) { DeserializeDockContent mDeserializeDockContent = new DeserializeDockContent(GetDockContentFromPersistString); dockPanel.LoadFromXml(configFile, mDeserializeDockContent); } else { dockPanel.SuspendLayout(true); this.mMainForm.Show(dockPanel, DockState.Document); this.mWorldForm.Show(dockPanel, DockState.DockRight); this.mSceneForm.Show(dockPanel, DockState.DockRight); this.mEntityForm.Show(dockPanel, DockState.DockRight); this.mTerrainForm.Show(dockPanel, DockState.DockRight); this.mSettingForm.Show(dockPanel, DockState.DockRight); this.mPropertyForm.Show(dockPanel, DockState.DockRight); this.mOutputForm.Show(dockPanel, DockState.DockBottom); dockPanel.ResumeLayout(true, true); } // 初始化操作接口 this.mWorldEditor = new WorldEditorFramework.MWorldEditor(); this.mWorldEditor.Initialize(this.mMainForm.Handle); //*********** // 场景加载 this.mTerrainForm.OnSceneLoad(); this.mSettingForm.OnSceneLoad(); this.mSceneForm.OnSceneLoad(); //*********** return true; }
public void Show(DockPanel dockPanel, Rectangle floatWindowBounds) { if (dockPanel == null) throw(new ArgumentNullException(Strings.DockContentHandler_Show_NullDockPanel)); dockPanel.SuspendLayout(true); DockPanel = dockPanel; if (FloatPane == null) { IsHidden = true; // to reduce the screen flicker FloatPane = DockPanel.DockPaneFactory.CreateDockPane(Content, DockState.Float, false); FloatPane.FloatWindow.StartPosition = FormStartPosition.Manual; } FloatPane.FloatWindow.Bounds = floatWindowBounds; Show(dockPanel, DockState.Float); Activate(); dockPanel.ResumeLayout(true, true); }
public void Show(DockPanel dockPanel, DockState dockState) { if (dockPanel == null) { throw (new ArgumentNullException(Strings.DockContentHandler_Show_NullDockPanel)); } if (dockState == DockState.Unknown || dockState == DockState.Hidden) { throw (new ArgumentException(Strings.DockContentHandler_Show_InvalidDockState)); } dockPanel.SuspendLayout(true); DockPanel = dockPanel; DockPane paneExisting = null; foreach (DockPane pane in DockPanel.Panes) { if (pane.DockState != dockState) { continue; } // I want BarDataRangePopup, BarScaleInterval, PositionSizePopup to open in their own floating windows // without continue, the second popup is opened in the floating window of the first // and window size for 2nd = size of 1st despite it was set upstack as Float.Bounds if (pane.Contents.Contains(this.Content) == false) { continue; } if (paneExisting == null || pane.IsActivated) { paneExisting = pane; } if (pane.IsActivated) { break; } } if (dockState == DockState.Float) { if (FloatPane == null) { this.Pane = DockPanel.DockPaneFactory.CreateDockPane(Content, dockState, true); } else { // I don't understand "Activated"/Hidden" but I've found a // deserialized restored (hidden) Pane for BarDataRangePopup, BarScaleInterval, PositionSizePopup this.Pane = FloatPane; //this.Pane = (paneExisting != null) ? paneExisting // : DockPanel.DockPaneFactory.CreateDockPane(Content, dockState, true); } } else if (PanelPane == null) { this.Pane = (paneExisting != null) ? paneExisting : DockPanel.DockPaneFactory.CreateDockPane(Content, dockState, true); } DockState = dockState; dockPanel.ResumeLayout(true, true); //we'll resume the layout before activating to ensure that the position Activate(); //and size of the form are finally processed before the form is shown }