/// <summary> /// Load state /// </summary> /// <param name="clear">clear the existing forms</param> /// <param name="formsFactory">forms factory</param> public void Load(bool clear, FormFactoryHandler formsFactory) { if (clear) { _container.Clear(); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(SavePath); _container.SuspendLayout(); DockableFormInfo selected = null; List <DockableFormInfo> autoHide = new List <DockableFormInfo>(); List <ControlSizeInfo> formsSize = LoadForms(xmlDocument, formsFactory, autoHide, out selected); RestoreSizes(formsSize); foreach (DockableFormInfo toAuto in autoHide) { _container.SetAutoHide(toAuto, true); } if (selected != null) { selected.IsSelected = true; } _container.ResumeLayout(true); }
public DockableFormInfo AddForm(Control c, zAllowedDock allowDock, string guid, Size size, string caption) { Form frm = CreateForm(size, c, caption); DockableFormInfo dfi = this.Add(frm, allowDock, new Guid(guid)); return(dfi); }
/// <summary> /// Load form /// </summary> /// <param name="xmlForm">xml form</param> /// <param name="formsFactory">forms factory</param> /// <param name="autoHide">list of autohide forms</param> /// <param name="selected">selected info</param> private ControlSizeInfo AddForm(XmlNode xmlForm, FormFactoryHandler formsFactory, List <DockableFormInfo> autoHide, out DockableFormInfo selected) { selected = null; XmlNode xmlGuid = xmlForm.SelectSingleNode(XmlTags.TagGuid); XmlNode xmlParentGuid = xmlForm.SelectSingleNode(XmlTags.TagParentGuid); XmlNode xmlAllowedDock = xmlForm.SelectSingleNode(XmlTags.TagAllowedDock); XmlNode xmlCurrentDock = xmlForm.SelectSingleNode(XmlTags.TagCurrentDock); XmlNode xmlCurrentMode = xmlForm.SelectSingleNode(XmlTags.TagCurrentMode); XmlNode xmlIsSelected = xmlForm.SelectSingleNode(XmlTags.TagIsSelected); XmlNode xmlIsAutoHide = xmlForm.SelectSingleNode(XmlTags.TagIsAutoHide); XmlNode xmlWidth = xmlForm.SelectSingleNode(XmlTags.TagWidth); XmlNode xmlHeight = xmlForm.SelectSingleNode(XmlTags.TagHeight); Guid identifier = new Guid(xmlGuid.InnerText); zAllowedDock allowedDock = (zAllowedDock)Enum.Parse(typeof(zAllowedDock), xmlAllowedDock.InnerText); Form form = formsFactory(identifier); int width = Convert.ToInt32(xmlWidth.InnerText); int height = Convert.ToInt32(xmlHeight.InnerText); form.Width = width; form.Height = height; DockableFormInfo info = _container.Add(form, allowedDock, identifier); if (PanelAdded != null) { PanelAdded(this, new PanelAddedEventArgs(info)); } if (Convert.ToBoolean(xmlIsSelected.InnerText)) { selected = info; } if (Convert.ToBoolean(xmlIsAutoHide.InnerText)) { autoHide.Add(info); } DockStyle currentDock = (DockStyle)Enum.Parse(typeof(DockStyle), xmlCurrentDock.InnerText); zDockMode currentMode = (zDockMode)Enum.Parse(typeof(zDockMode), xmlCurrentMode.InnerText); if (currentDock != DockStyle.None) { if (xmlParentGuid == null) { _container.DockForm(info, currentDock, currentMode); } else { Guid parentGuid = new Guid(xmlParentGuid.InnerText); DockableFormInfo parentInfo = _container.GetFormInfo(parentGuid); _container.DockForm(info, parentInfo, currentDock, currentMode); } } return(new ControlSizeInfo(form, width, height)); }
/// <summary> /// Set the height of a form docked: top or bottom or fill /// </summary> /// <param name="info">info identifing the form</param> /// <param name="newHeight">new height value</param> public void SetHeight(DockableFormInfo info, int newHeight) { int delta = newHeight - info.DockableForm.Height; if (delta == 0) { return; } DockableContainer container = HierarchyUtility.GetClosestDockableContainer(info.DockableForm); List <DockableContainer> hierarchy = new List <DockableContainer>(); List <int> modifiers = new List <int>(); hierarchy.Add(container); modifiers.Add(delta); DockableContainer containerParent = container.Parent as DockableContainer; while (containerParent != null) { hierarchy.Add(containerParent); modifiers.Add(containerParent.Height - container.Height + delta); container = containerParent; containerParent = containerParent.Parent as DockableContainer; } for (int index = hierarchy.Count - 1; index >= 0; index--) { hierarchy[index].Height += modifiers[index]; } }
/// <summary> /// Occurs when tab button is removed /// </summary> /// <param name="button">button removed</param> protected override void OnButtonRemoved(TabButton button) { Form page = (Form)button.Page; page.FormClosing -= OnPageClosing; page.FormClosed -= OnPageClosed; page.ParentChanged -= OnPageParentChanged; PagesPanel.Remove(page); DockableFormInfo info = null; for (int index = _cachedInfos.Count - 1; index >= 0; index--) { if (_cachedInfos[index].Button == button) { info = _cachedInfos[index]; _cachedInfos.RemoveAt(index); info.ExplicitDisposing -= OnInfoDisposing; info.SelectedChanged -= OnInfoSelectedChanged; break; } } EventHandler <FormEventArgs> handler = FormRemoved; if (handler != null) { FormEventArgs args = new FormEventArgs(page, info.Id); handler(this, args); } }
/// <summary> /// Add form to guider /// </summary> /// <param name="form">form to guide</param> /// <param name="allowedDock">allowed dock</param> /// <param name="formIdentifier">identifier of the form added</param> /// <returns>object that encapsulates relevant information for the guided form</returns> public DockableFormInfo Add(Form form, zAllowedDock allowedDock, Guid formIdentifier) { if (GetFormInfo(form) != null) { throw new ArgumentException("Err"); } // Should set the border as None to prevent Microsoft bug in TextBox: // TextBox on Form with TopLevel = False and FormBorderStyle != None doesn't process Click event form.FormBorderStyle = FormBorderStyle.None; Rectangle bounds = form.Bounds; DockableFormInfo info = new DockableFormInfo(form, allowedDock, formIdentifier); info.ExplicitDisposing += OnInfoDisposing; info.SelectedChanged += OnFormSelectedChanged; info.ShowAutoPanel += OnShowFormAutoPanel; _dockableForms.Add(info); FormsTabbedView view = CreateFormsTabbedView(bounds.Size, null); view.Add(info); _layout.CreateFloatingContainer(view, bounds); return(info); }
/// <summary> /// Add a new tab page /// </summary> /// <param name="pageInfo">tab page info</param> public void Add(DockableFormInfo pageInfo) { if (pageInfo.AllowedDock != AllowedDock && AllowedDock != zAllowedDock.Unknown) { throw new InvalidOperationException("Err"); } pageInfo.DockableForm.SetBounds(-15000, 0, PagesPanel.Width, PagesPanel.Height); pageInfo.DockableForm.Dock = DockStyle.None; PagesPanel.Add(pageInfo.DockableForm); _cachedInfos.Add(pageInfo); pageInfo.ExplicitDisposing += OnInfoDisposing; pageInfo.SelectedChanged += OnInfoSelectedChanged; pageInfo.HostContainerDock = HostContainerDock; pageInfo.DockableForm.FormClosing += OnPageClosing; pageInfo.DockableForm.FormClosed += OnPageClosed; pageInfo.DockableForm.ParentChanged += OnPageParentChanged; AddButton(pageInfo.Button); IsFocused = true; }
// MI 20100712 public void SetCaption(DockableFormInfo dfi, string caption) { FormsDecorator fd = HierarchyUtility.GetFormsDecorator(dfi.DockableForm); fd.TitleBarRenderer.Text = caption; fd.Invalidate(true); }
public void RemovePanel(string guid) { DockableFormInfo i = this.GetFormInfo(new Guid(guid)); Remove(i); Panels.Remove(guid); }
private void UpdatePanelDockInfo(DockableFormInfo info) { if (DockedItems.ContainsKey(info.Id.ToString())) { DockedItem item = DockedItems[info.Id.ToString()]; info.ShowCloseButton = item.ControlDfi.ShowCloseButton; } }
/// <summary> /// Occurs when info is selected /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">event arguments</param> private void OnInfoSelectedChanged(object sender, EventArgs e) { DockableFormInfo info = (DockableFormInfo)sender; if (info.IsSelected) { SelectedIndex = GetPageIndex(info.DockableForm); } }
/// <summary> /// Remove the form /// </summary> /// <param name="info">info about form to remove</param> public void Remove(DockableFormInfo info) { if (info == null) { return; } FormsTabbedView view = HierarchyUtility.GetTabbedView(info.DockableForm); if (view != null) { if (view.Count == 1 && view.IsDocked) { _layout.Undock(view); } if (view.Count == 1) { _host.Remove(view.Parent); DockableContainer container = HierarchyUtility.GetClosestDockableContainer(info.DockableForm); container.SetModeEmpty(); view.Remove(info); } else { if (view.Remove(info) == false) { if (SelectedFormInfo == info) { SelectedFormInfo = null; } return; } } } if (SelectedFormInfo == info) { SelectedFormInfo = null; } _dockableForms.Remove(info); info.SelectedChanged -= OnFormSelectedChanged; info.ShowAutoPanel -= OnShowFormAutoPanel; info.ExplicitDisposing -= OnInfoDisposing; if (info.IsAutoHideMode) { _autohide.ArrangeAutoButtonsPanels(); } info.Dispose(); }
/// <summary> /// Occurs when tab button is added /// </summary> /// <param name="button">button added</param> protected override void OnButtonAdded(TabButton button) { EventHandler <FormEventArgs> handler = FormAdded; if (handler != null) { DockableFormInfo info = GetPageInfo((Form)button.Page); FormEventArgs args = new FormEventArgs(info.DockableForm, info.Id); handler(this, args); } }
/// <summary> /// Occurs when pages context menu button was clicked /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">event arguments</param> private void OnPagesContextMenuClick(object sender, EventArgs e) { EventHandler <FormEventArgs> handler = ContextMenuClick; if (handler != null) { DockableFormInfo info = GetPageInfo(PagesPanel.GetFormAt(SelectedIndex)); FormEventArgs args = new FormEventArgs(info.DockableForm, info.Id); handler(this, args); } }
/// <summary> /// Set auto-hide mode /// </summary> /// <param name="info">info of the form to set</param> /// <param name="autoHide">flag indicating if should set auto-hide (true) or unset it</param> public void SetAutoHide(DockableFormInfo info, bool autoHide) { if (autoHide && info.IsAutoHideMode == false) { _autohide.SetAutoHideMode(HierarchyUtility.GetTabbedView(info.DockableForm)); } else if (autoHide == false && info.IsAutoHideMode) { _autohide.UnsetAutoHideMode(HierarchyUtility.GetTabbedView(info.DockableForm)); } }
private void UpdatePanelDockInfo(DockableFormInfo info) { if (Panels.ContainsKey(info.Id.ToString())) { DockPanel p = Panels[info.Id.ToString()]; p.DockInfo = info; SetPanel(p); } }
/// <summary> /// Dock a form previously added to guider over another form previously added to guider /// </summary> /// <param name="info">info about the form to dock</param> /// <param name="infoOver">info about form over which to dock</param> /// <param name="dock">how to dock</param> /// <param name="mode">were to dock</param> public void DockOver(DockableFormInfo info, DockableFormInfo infoOver, DockStyle dock, zDockMode mode) { DockableContainer containerToDock = HierarchyUtility.GetClosestDockableContainer(info.DockableForm); DockableContainer containerWhereToDock = null; if (infoOver != null) { containerWhereToDock = HierarchyUtility.GetClosestDockableContainer(infoOver.DockableForm); } _layout.DockControl(containerToDock, containerWhereToDock, dock, mode); }
/// <summary> /// Occurs after selected index was set /// </summary> /// <param name="e">event argument</param> protected override void OnSelectedIndexSet(EventArgs e) { DockableFormInfo info = GetPageInfoAt(SelectedIndex); if (info != null) { info.IsSelected = true; SelectedForm = info.DockableForm; } Invalidate(); base.OnSelectedIndexSet(e); }
/// <summary> /// Occurs when the page is closing /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">event argument</param> private void OnPageClosing(object sender, FormClosingEventArgs e) { EventHandler <DockableFormClosingEventArgs> handler = FormClosing; if (handler != null) { DockableFormInfo info = GetPageInfo((Form)sender); DockableFormClosingEventArgs args = new DockableFormClosingEventArgs(info.DockableForm, info.Id); args.Cancel = false; handler(this, args); e.Cancel = args.Cancel; } }
/// <summary> /// Save /// </summary> /// <param name="info">info</param> /// <param name="parentId">parent id identifier</param> /// <param name="xmlForms">forms</param> private void Save(DockableFormInfo info, Guid parentId, XmlNode xmlForms) { XmlDocument xmlDocument = xmlForms.OwnerDocument; XmlNode xmlForm = xmlForms.AppendChild(xmlDocument.CreateElement(XmlTags.TagForm)); XmlNode xmlGuid = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagGuid)); XmlNode xmlAllowedDock = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagAllowedDock)); XmlNode xmlCurrentDock = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagCurrentDock)); XmlNode xmlCurrentMode = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagCurrentMode)); XmlNode xmlIsSelected = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagIsSelected)); XmlNode xmlIsAutoHide = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagIsAutoHide)); XmlNode xmlWidth = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagWidth)); XmlNode xmlHeight = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagHeight)); if (parentId != Guid.Empty) { XmlNode xmlParentGuid = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagParentGuid)); xmlParentGuid.InnerText = parentId.ToString(); } xmlGuid.InnerText = info.Id.ToString(); xmlAllowedDock.InnerText = info.AllowedDock.ToString(); xmlCurrentMode.InnerText = info.DockMode.ToString(); xmlIsSelected.InnerText = info.IsSelected.ToString().ToLower(); xmlIsAutoHide.InnerText = info.IsAutoHideMode.ToString().ToLower(); DockableContainer container = HierarchyUtility.GetClosestDockableContainer(info.DockableForm); xmlWidth.InnerText = container.Width.ToString(); xmlHeight.InnerText = container.Height.ToString(); if (parentId == Guid.Empty) { if (info.IsAutoHideMode == false) { xmlCurrentDock.InnerText = info.HostContainerDock.ToString(); } else { xmlCurrentDock.InnerText = info.AutoHideSavedDock.ToString(); } } else { xmlCurrentDock.InnerText = info.Dock.ToString(); //xmlCurrentDock.InnerText = "Bottom"; //xmlCurrentMode.InnerText = "Inner"; } }
/// <summary> /// Check if this instance is equal with the obj instance /// </summary> /// <param name="obj">obj</param> /// <returns>true for equalty</returns> public override bool Equals(object obj) { ValidateNotDisposed(); DockableFormInfo dockable = obj as DockableFormInfo; if (dockable != (DockableFormInfo)null) { return(this == dockable); } Form form = obj as Form; return(DockableForm == form); }
private DockableFormInfo Add(Control c, DockableFormInfo infoOver, DockStyle dock, zDockMode mode, string guid) { DockableFormInfo info = Add(c, guid); //DockForm(info, infoOver, dock, mode); if (infoOver == null) { DockForm(info, dock, mode); } else { DockForm(info, infoOver, dock, mode); } return(info); }
public void TogglePanel(bool show, string guid) { if (show) { Create(Panels[guid]); } else { DockableFormInfo i = this.GetFormInfo(new Guid(guid)); Remove(i); Panels[guid].DockStyle = DockStyle.Bottom; Panels[guid].DockMode = zDockMode.Inner; } }
/// <summary> /// Apply select /// </summary> public override void Apply() { Hide(); if (SelectedIndex >= 0 && SelectedIndex < Forms.Length) { DockableFormInfo info = Forms[SelectedIndex]; info.IsSelected = true; if (info.IsAutoHideMode) { info.ShowFormAutoPanel(); } } }
/// <summary> /// Occurs when the page is closed /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">event argument</param> private void OnPageClosed(object sender, FormClosedEventArgs e) { DockableFormInfo info = GetPageInfo((Form)sender); Guid id = info.Id; Form form = info.DockableForm; TabButton button = GetButton(form); button.Dispose(); EventHandler <FormEventArgs> handler = FormClosed; if (handler != null) { FormEventArgs args = new FormEventArgs(form, id); handler(this, args); } }
/// <summary> /// Undock view /// </summary> /// <param name="view">view to undock</param> /// <param name="hintBounds">hint bounds</param> private void Undock(Form formToUndock, Rectangle hintBounds) { FormsTabbedView view = HierarchyUtility.GetTabbedView(formToUndock); if (view.Count == 1) { _layout.Undock(view, hintBounds); } else { DockableFormInfo info = GetFormInfo(formToUndock); FormsTabbedView newView = CreateFormsTabbedView(info.DockableForm.Size, null); newView.Add(info); _layout.CreateFloatingContainer(newView, hintBounds); } }
/// <summary> /// Load forms /// </summary> /// <param name="xmlDocument">document</param> /// <param name="formsFactory">forms factory</param> /// <returns>list of control size info</returns> /// <param name="autoHide">list of autohide forms</param> /// <param name="selected">selected info</param> private List <ControlSizeInfo> LoadForms(XmlDocument xmlDocument, FormFactoryHandler formsFactory, List <DockableFormInfo> autohide, out DockableFormInfo selected) { selected = null; List <ControlSizeInfo> formsSize = new List <ControlSizeInfo>(); XmlNodeList xmlForms = xmlDocument.SelectNodes("//" + XmlTags.TagForms + "/" + XmlTags.TagForm); for (int index = 0; index < xmlForms.Count; index++) { XmlNode xmlForm = xmlForms[index]; DockableFormInfo selectedForm = null; formsSize.Add(AddForm(xmlForm, formsFactory, autohide, out selectedForm)); if (selectedForm != null) { selected = selectedForm; } } return(formsSize); }
/// <summary> /// Move all the pages to given view /// </summary> /// <param name="view">view where to move the pages</param> /// <returns>moved pages</returns> public DockableFormInfo[] MovePagesTo(FormsTabbedView view) { List <DockableFormInfo> movedPages = new List <DockableFormInfo>(); if (view == this) { return(movedPages.ToArray()); } for (int index = _cachedInfos.Count - 1; index >= 0; index--) { DockableFormInfo info = _cachedInfos[index]; Remove(info); view.Add(info); movedPages.Add(info); } return(movedPages.ToArray()); }
/// <summary> /// Show forms selector /// </summary> /// <param name="containerScreenBounds">screen bounds of the container</param> /// <param name="forms">forms to select</param> public void Show(PreviewRenderer renderer, Rectangle containerScreenBounds, DockableFormInfo[] forms) { Renderer = renderer; _forms = forms; if (_forms == null) { _forms = new DockableFormInfo[0]; } for (int index = 0; index < _forms.Length; index++) { if (_forms[index].IsSelected) { SelectedIndex = index; break; } } _screenBounds = containerScreenBounds; ShowSelector(); }
/// <summary> /// Occurs when IsSelected property of a form is changed /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">event argument</param> private void OnFormSelectedChanged(object sender, EventArgs e) { DockableFormInfo info = (DockableFormInfo)sender; if (info.IsSelected) { SelectedFormInfo = info; } FormsTabbedView view = HierarchyUtility.GetTabbedView(info.DockableForm); if (view != null) { if (view.SelectedForm != null) { DockableFormInfo topFormInfo = GetFormInfo(view.SelectedForm); view.PagesPanel.ShowCloseButton = topFormInfo.ShowCloseButton; view.PagesPanel.ShowContextMenuButton = topFormInfo.ShowContextMenuButton; } } }
/// <summary> /// Save the view /// </summary> /// <param name="view">view to save</param> /// <param name="viewOwnerId">view owner identifier</param> /// <param name="xmlForms">forms node</param> /// <returns>identifier of the view</returns> private Guid SaveView(FormsTabbedView view, Guid viewOwnerId, XmlNode xmlForms) { Form firstDockedPage = null; for (int childIndex = 0; childIndex < view.Count; childIndex++) { DockableFormInfo childInfo = view.GetPageInfoAt(childIndex); if (childInfo.Dock != DockStyle.Fill) { firstDockedPage = childInfo.DockableForm; break; } } if (firstDockedPage == null) { firstDockedPage = view.GetPageAt(0); } DockableFormInfo info = _container.GetFormInfo(firstDockedPage); Save(info, viewOwnerId, xmlForms); for (int childIndex = 0; childIndex < view.Count; childIndex++) { DockableFormInfo siblingInfo = view.GetPageInfoAt(childIndex); if (siblingInfo == info) { continue; } Save(siblingInfo, info.Id, xmlForms); } return(info.Id); }
private bool IsDFIDisposed(DockableFormInfo dfi) { return (dfi.IsDisposed); }
/// <summary> /// Set the width of a form docked: left or right or fill /// </summary> /// <param name="info">info identifing the form</param> /// <param name="newWidth">new width value</param> public void SetWidth(DockableFormInfo info, int newWidth) { _docker.SetWidth(info, newWidth); }
/// <summary> /// Set auto-hide mode /// </summary> /// <param name="info">info of the form to set</param> /// <param name="autoHide">flag indicating if should set auto-hide (true) or unset it</param> public void SetAutoHide(DockableFormInfo info, bool autoHide) { _docker.SetAutoHide(info, autoHide); }
/// <summary> /// Dock a form previously added to guider over another form previously added to guider /// </summary> /// <param name="info">info about the form to dock</param> /// <param name="infoOver">info about form over which to dock</param> /// <param name="dock">how to dock</param> /// <param name="mode">were to dock</param> public void DockForm(DockableFormInfo info, DockableFormInfo infoOver, DockStyle dock, zDockMode mode) { _docker.DockOver(info, infoOver, dock, mode); }
public void ShowEntryListWindow() { if (mEntryListToolWindowInfo != null) { if (!mEntryListToolWindowInfo.IsDisposed) return; } EntryListToolWindow window = new EntryListToolWindow(this); mEntryListToolWindowInfo = AddToolWindow(window); mEntryListToolWindowInfo.ShowContextMenuButton = false; //if (mEntryListToolWindowInfo != null) { // if (!mEntryListToolWindowInfo.IsDisposed) { // mDockContainer.DockForm(mEntryListToolWindowInfo, DockStyle.Left, zDockMode.Outer); // } //} mDockContainer.DockForm(mEntryListToolWindowInfo, DockStyle.Left, zDockMode.Inner); }
/// <summary> /// Load forms /// </summary> /// <param name="xmlDocument">document</param> /// <param name="formsFactory">forms factory</param> /// <returns>list of control size info</returns> /// <param name="autoHide">list of autohide forms</param> /// <param name="selected">selected info</param> private List<ControlSizeInfo> LoadForms(XmlDocument xmlDocument, FormFactoryHandler formsFactory, List<DockableFormInfo> autohide, out DockableFormInfo selected) { selected = null; List<ControlSizeInfo> formsSize = new List<ControlSizeInfo>(); XmlNodeList xmlForms = xmlDocument.SelectNodes("//" + XmlTags.TagForms + "/" + XmlTags.TagForm); for (int index = 0; index < xmlForms.Count; index++) { XmlNode xmlForm = xmlForms[index]; DockableFormInfo selectedForm = null; formsSize.Add(AddForm(xmlForm, formsFactory, autohide, out selectedForm)); if (selectedForm != null) { selected = selectedForm; } } return formsSize; }
/// <summary> /// Remove the form /// </summary> /// <param name="info">info about form to remove</param> public void Remove(DockableFormInfo info) { if (SelectedFormInfo == info) { SelectedFormInfo = null; } FormsTabbedView view = HierarchyUtility.GetTabbedView(info.DockableForm); if (view != null) { if (view.Count == 1 && view.IsDocked) { _layout.Undock(view); } if (view.Count == 1) { _host.Remove(view.Parent); DockableContainer container = HierarchyUtility.GetClosestDockableContainer(info.DockableForm); container.SetModeEmpty(); view.Remove(info); } else { if (view.Remove(info) == false) { return; } } } _dockableForms.Remove(info); info.SelectedChanged -= OnFormSelectedChanged; info.ShowAutoPanel -= OnShowFormAutoPanel; info.ExplicitDisposing -= OnInfoDisposing; }
/// <summary> /// Remove an existing tab page /// </summary> /// <param name="pageInfo">page info to be removed</param> public bool Remove(DockableFormInfo pageInfo) { return RemoveButton(pageInfo.Button); }
/// <summary> /// Add a new tab page /// </summary> /// <param name="pageInfo">tab page info</param> public void Add(DockableFormInfo pageInfo) { if (pageInfo.AllowedDock != AllowedDock && AllowedDock != zAllowedDock.Unknown) { throw new InvalidOperationException("Err"); } pageInfo.DockableForm.SetBounds(-15000, 0, PagesPanel.Width, PagesPanel.Height); pageInfo.DockableForm.Dock = DockStyle.None; PagesPanel.Add(pageInfo.DockableForm); _cachedInfos.Add(pageInfo); pageInfo.HostContainerDock = HostContainerDock; AddButton(pageInfo.Button); }
/// <summary> /// Occurs when IsSelected property of a form is changed /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">event argument</param> private void OnFormSelectedChanged(object sender, EventArgs e) { DockableFormInfo info = (DockableFormInfo)sender; if (info.IsSelected) { SelectedFormInfo = info; } }
/// <summary> /// Occurs when control got focus /// </summary> /// <param name="sender">sender of the event</param> /// <param name="e">event argument</param> private void OnControlGotFocus(object sender, TemplateEventArgs<IntPtr> e) { Control control = Control.FromHandle(e.Data); while (control != null) { if (control as Form != null) { break; } if (control as FormsTabbedView != null) { control = ((FormsTabbedView)control).SelectedForm; break; } control = control.Parent; } Form focusedForm = control as Form; if (focusedForm != null) { foreach (DockableFormInfo info in _dockableForms) { if (info.DockableForm == focusedForm) { SelectedFormInfo = info; break; } } } return; }
/// <summary> /// Set the height of a form docked: top or bottom or fill /// </summary> /// <param name="info">info identifing the form</param> /// <param name="newHeight">new height value</param> public void SetHeight(DockableFormInfo info, int newHeight) { int delta = newHeight - info.DockableForm.Height; if (delta == 0) { return; } DockableContainer container = HierarchyUtility.GetClosestDockableContainer(info.DockableForm); List<DockableContainer> hierarchy = new List<DockableContainer>(); List<int> modifiers = new List<int>(); hierarchy.Add(container); modifiers.Add(delta); DockableContainer containerParent = container.Parent as DockableContainer; while (containerParent != null) { hierarchy.Add(containerParent); modifiers.Add(containerParent.Height - container.Height + delta); container = containerParent; containerParent = containerParent.Parent as DockableContainer; } for (int index = hierarchy.Count - 1; index >= 0; index--) { hierarchy[index].Height += modifiers[index]; } }
void Initialize() { // Start Page Form SPF = (StartPageForm)FormCreator(FormStyle.StartPage, 0, 0, 725, 390, this.BackColor, "Start Page"); DFI01 = DockContainer01Panel.Add(SPF, zAllowedDock.All, new Guid("a6402b80-2ebd-4fd3-8930-024a6201d001")); DFI01.ShowContextMenuButton = false; //DFI01.ShowCloseButton = false; DFI01.ShowFormAutoPanel(); DockContainer01Panel.DockForm(DFI01, DockStyle.Fill, zDockMode.Inner); //Details Form DF = (DetailsForm)FormCreator(FormStyle.Details, 0, 0, 300,300, this.BackColor, "Details View"); DFI03 = DockContainer01Panel.Add(DF, zAllowedDock.All, new Guid("096b52a7-5f4b-44ee-ab77-9830ec717002")); DFI03.ShowContextMenuButton = true; DockContainer01Panel.DockForm(DFI03, DockStyle.Right, zDockMode.Inner); //Histogram Form HF = (HistogramForm)FormCreator(FormStyle.Histogram, 0, 0, 300,300, Color.White, "Histogram View"); DFI02 = DockContainer01Panel.Add(HF, zAllowedDock.All, new Guid("a6402b80-2ebd-4fd3-8930-024a6201d001")); DFI02.ShowContextMenuButton = true; DockContainer01Panel.DockForm(DFI02, DFI03, DockStyle.Bottom, zDockMode.Outer); //Paint Handle Form //PHF = (PaintHandlerForm)FormCreator(FormStyle.PaintHandleForm, 0, 0, 725, 390, Color.FromArgb(45, 45, 48), "Untiteled"); //DFI04 = DockContainer01Panel.Add(PHF, zAllowedDock.All, new Guid("a6402b80-2ebd-4fd3-8930-024a6201d001")); //DFI04.ShowContextMenuButton = false; //DockContainer01Panel.DockForm(DFI04, DFI01, DockStyle.Fill, zDockMode.Inner); }
/// <summary> /// Load form /// </summary> /// <param name="xmlForm">xml form</param> /// <param name="formsFactory">forms factory</param> /// <param name="autoHide">list of autohide forms</param> /// <param name="selected">selected info</param> private ControlSizeInfo AddForm(XmlNode xmlForm, FormFactoryHandler formsFactory, List<DockableFormInfo> autoHide, out DockableFormInfo selected) { selected = null; XmlNode xmlGuid = xmlForm.SelectSingleNode(XmlTags.TagGuid); XmlNode xmlParentGuid = xmlForm.SelectSingleNode(XmlTags.TagParentGuid); XmlNode xmlAllowedDock = xmlForm.SelectSingleNode(XmlTags.TagAllowedDock); XmlNode xmlCurrentDock = xmlForm.SelectSingleNode(XmlTags.TagCurrentDock); XmlNode xmlCurrentMode = xmlForm.SelectSingleNode(XmlTags.TagCurrentMode); XmlNode xmlIsSelected = xmlForm.SelectSingleNode(XmlTags.TagIsSelected); XmlNode xmlIsAutoHide = xmlForm.SelectSingleNode(XmlTags.TagIsAutoHide); XmlNode xmlWidth = xmlForm.SelectSingleNode(XmlTags.TagWidth); XmlNode xmlHeight = xmlForm.SelectSingleNode(XmlTags.TagHeight); Guid identifier = new Guid(xmlGuid.InnerText); zAllowedDock allowedDock = (zAllowedDock)Enum.Parse(typeof(zAllowedDock), xmlAllowedDock.InnerText); Form form = formsFactory(identifier); int width = Convert.ToInt32(xmlWidth.InnerText); int height = Convert.ToInt32(xmlHeight.InnerText); form.Width = width; form.Height = height; DockableFormInfo info = _container.Add(form, allowedDock, identifier); if (Convert.ToBoolean(xmlIsSelected.InnerText)) { selected = info; } if (Convert.ToBoolean(xmlIsAutoHide.InnerText)) { autoHide.Add(info); } DockStyle currentDock = (DockStyle)Enum.Parse(typeof(DockStyle), xmlCurrentDock.InnerText); zDockMode currentMode = (zDockMode)Enum.Parse(typeof(zDockMode), xmlCurrentMode.InnerText); if (currentDock != DockStyle.None) { if (xmlParentGuid == null) { _container.DockForm(info, currentDock, currentMode); } else { Guid parentGuid = new Guid(xmlParentGuid.InnerText); DockableFormInfo parentInfo = _container.GetFormInfo(parentGuid); _container.DockForm(info, parentInfo, currentDock, currentMode); } } return new ControlSizeInfo(form, width, height); }
/// <summary> /// Dock a form previously added to guider /// </summary> /// <param name="info">info about the form to dock</param> /// <param name="dock">how to dock</param> /// <param name="mode">were to dock</param> public void Dock(DockableFormInfo info, DockStyle dock, zDockMode mode) { DockableContainer container = HierarchyUtility.GetClosestDockableContainer(info.DockableForm); _layout.DockControl(container, null, dock, mode); }
public void ShowPropertiesWindow() { if (mPropertiesToolWindowInfo != null) { if (!mPropertiesToolWindowInfo.IsDisposed) return; } PropertiesToolWindow window = new PropertiesToolWindow(this); mPropertiesToolWindowInfo = AddToolWindow(window); mPropertiesToolWindowInfo.ShowContextMenuButton = false; if (mPackExplorerToolWindowInfo != null) { if (!mPackExplorerToolWindowInfo.IsDisposed) { mDockContainer.DockForm(mPropertiesToolWindowInfo, mPackExplorerToolWindowInfo, DockStyle.Bottom, zDockMode.Inner); return; } } mDockContainer.DockForm(mPropertiesToolWindowInfo, DockStyle.Right, zDockMode.Inner); }
/// <summary> /// Add form to guider /// </summary> /// <param name="form">form to guide</param> /// <param name="allowedDock">allowed dock</param> /// <param name="formIdentifier">identifier of the form added</param> /// <returns>object that encapsulates relevant information for the guided form</returns> public DockableFormInfo Add(Form form, zAllowedDock allowedDock, Guid formIdentifier) { if (GetFormInfo(form) != null) { throw new ArgumentException("Err"); } Rectangle bounds = form.Bounds; // @matt - force right values form.FormBorderStyle = FormBorderStyle.SizableToolWindow; form.TopLevel = false; DockableFormInfo info = new DockableFormInfo(form, allowedDock, formIdentifier); info.ExplicitDisposing += OnInfoDisposing; info.SelectedChanged += OnFormSelectedChanged; info.ShowAutoPanel += OnShowFormAutoPanel; _dockableForms.Add(info); FormsTabbedView view = CreateFormsTabbedView(bounds.Size, null); view.Add(info); _layout.CreateFloatingContainer(view, bounds); return info; }
/// <summary> /// Remove the form /// </summary> /// <param name="info">info about form to remove</param> public void Remove(DockableFormInfo info) { _docker.Remove(info); }
private void Create_EditTable_Form(NavigationButtons.Navigation xnav) { if (m_EditTable_Form == null) { if (m_pTableDockingFormXml.m_EditTableFormXml == null) { m_pTableDockingFormXml.m_EditTableFormXml = new EditTableFormXml(); // m_pTableDockingFormXml.m_EditTableFormXml.wrect = Get_wRect(typeof(EditTable_Form), 0); } m_EditTable_Form = (EditTable_Form)CreateDockForm(new Guid(guid.gDocking_EditTable_Form.ToByteArray()), m_DBTables, m_tbl, this, m_pTableDockingFormXml.m_EditTableFormXml.wrect, null,xnav); info_EditTable_Form = _docker.Add(m_EditTable_Form, zAllowedDock.All, new Guid(guid.gDocking_EditTable_Form.ToByteArray())); _docker.DockForm(info_EditTable_Form, DockStyle.Left, zDockMode.Inner); } else { m_EditTable_Form.Activate(); } }
/// <summary> /// Set the height of a form docked: top or bottom or fill /// </summary> /// <param name="info">info identifing the form</param> /// <param name="newHeight">new height value</param> public void SetHeight(DockableFormInfo info, int newHeight) { _docker.SetHeight(info, newHeight); }
private void Create_DataTable_Form(NavigationButtons.Navigation xnav) { if (m_DataTable_Form == null) { if (m_pTableDockingFormXml.m_DataTableFormXml == null) { m_pTableDockingFormXml.m_DataTableFormXml = new DataTableFormXml(); } m_DataTable_Form = (DataTable_Form)CreateDockForm(new Guid(guid.gDocking_TableGrid_Form.ToByteArray()), m_DBTables, m_tbl, this, m_pTableDockingFormXml.m_DataTableFormXml.wrect, null,xnav); info_DataTable_Form = _docker.Add(m_DataTable_Form, zAllowedDock.All, new Guid(guid.gDocking_TableGrid_Form.ToByteArray())); _docker.DockForm(info_DataTable_Form, DockStyle.Right, zDockMode.Inner); } else { m_DataTable_Form.Activate(); } }
/// <summary> /// Undock form /// </summary> /// <param name="info">info about form to undock</param> /// <param name="hintBounds">hint bounds</param> public void Undock(DockableFormInfo info, Rectangle hintBounds) { _docker.Undock(info, hintBounds); }
private void Create_CreateView_Form(NavigationButtons.Navigation xnav) { if (m_CreateView_Form == null) { if (m_pTableDockingFormXml.m_CreateViewFormXml == null) { m_pTableDockingFormXml.m_CreateViewFormXml = new CreateViewFormXml(); } m_CreateView_Form = (CreateView_Form)CreateDockForm(new Guid(guid.gDocking_CreateView_Form.ToByteArray()), m_DBTables, m_tbl, this, m_pTableDockingFormXml.m_CreateViewFormXml.wrect, null,xnav); info_CreateView_Form = _docker.Add(m_CreateView_Form, zAllowedDock.All, new Guid(guid.gDocking_CreateView_Form.ToByteArray())); _docker.DockForm(info_CreateView_Form, DockStyle.Top, zDockMode.None); } else { m_CreateView_Form.Activate(); } }
void SetupDocking() { this.SuspendLayout(); dockhud = CreateFormAndGuid(dockContainer1, hud1, "fd_hud_guid"); DockableFormInfo dockmap = CreateFormAndGuid(dockContainer1, tableMap, "fd_map_guid"); DockableFormInfo dockquick = CreateFormAndGuid(dockContainer1, tabQuick, "fd_quick_guid"); DockableFormInfo dockactions = CreateFormAndGuid(dockContainer1, tabActions, "fd_actions_guid"); DockableFormInfo dockguages = CreateFormAndGuid(dockContainer1, tabGauges, "fd_guages_guid"); DockableFormInfo dockstatus = CreateFormAndGuid(dockContainer1, tabStatus, "fd_status_guid"); DockableFormInfo docktlogs = CreateFormAndGuid(dockContainer1, tabTLogs, "fd_tlogs_guid"); dockContainer1.DockForm(dockmap, DockStyle.Fill, zDockMode.Outer); dockContainer1.DockForm(dockquick, DockStyle.Right, zDockMode.Outer); dockContainer1.DockForm(dockhud, DockStyle.Left, zDockMode.Outer); dockContainer1.DockForm(dockactions, dockhud, DockStyle.Bottom, zDockMode.Outer); dockContainer1.DockForm(dockguages, dockactions, DockStyle.Fill, zDockMode.Inner); dockContainer1.DockForm(dockstatus, dockactions, DockStyle.Fill, zDockMode.Inner); dockContainer1.DockForm(docktlogs, dockactions, DockStyle.Fill, zDockMode.Inner); dockactions.IsSelected = true; if (MainV2.config["FlightSplitter"] != null) { dockContainer1.SetWidth(dockhud, int.Parse(MainV2.config["FlightSplitter"].ToString())); } dockContainer1.SetHeight(dockhud, hud1.Height); this.ResumeLayout(); }
/// <summary> /// Save /// </summary> /// <param name="info">info</param> /// <param name="parentId">parent id identifier</param> /// <param name="xmlForms">forms</param> private void Save(DockableFormInfo info, Guid parentId, XmlNode xmlForms) { XmlDocument xmlDocument = xmlForms.OwnerDocument; XmlNode xmlForm = xmlForms.AppendChild(xmlDocument.CreateElement(XmlTags.TagForm)); XmlNode xmlGuid = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagGuid)); XmlNode xmlAllowedDock = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagAllowedDock)); XmlNode xmlCurrentDock = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagCurrentDock)); XmlNode xmlCurrentMode = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagCurrentMode)); XmlNode xmlIsSelected = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagIsSelected)); XmlNode xmlIsAutoHide = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagIsAutoHide)); XmlNode xmlWidth = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagWidth)); XmlNode xmlHeight = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagHeight)); if (parentId != Guid.Empty) { XmlNode xmlParentGuid = xmlForm.AppendChild(xmlDocument.CreateElement(XmlTags.TagParentGuid)); xmlParentGuid.InnerText = parentId.ToString(); } xmlGuid.InnerText = info.Id.ToString(); xmlAllowedDock.InnerText = info.AllowedDock.ToString(); xmlCurrentMode.InnerText = info.DockMode.ToString(); xmlIsSelected.InnerText = info.IsSelected.ToString().ToLower(); xmlIsAutoHide.InnerText = info.IsAutoHideMode.ToString().ToLower(); DockableContainer container = HierarchyUtility.GetClosestDockableContainer(info.DockableForm); xmlWidth.InnerText = container.Width.ToString(); xmlHeight.InnerText = container.Height.ToString(); if (parentId == Guid.Empty) { if (info.IsAutoHideMode == false) { xmlCurrentDock.InnerText = info.HostContainerDock.ToString(); } else { xmlCurrentDock.InnerText = info.AutoHideSavedDock.ToString(); } } else { xmlCurrentDock.InnerText = info.Dock.ToString(); } }
/// <summary> /// Undock form /// </summary> /// <param name="info">info about form to undock</param> /// <param name="hintBounds">hint bounds</param> public void Undock(DockableFormInfo info, Rectangle hintBounds) { Undock(info.DockableForm, hintBounds); }