private void Handler_RemovePage(object sender, EventArgs eevent) { MultiPaneControl aCtl = DesignedControl; if (aCtl == null) { return; } else if (aCtl.Controls.Count < 1) { return; } IDesignerHost aHost = (IDesignerHost)GetService(typeof(IDesignerHost)); if (aHost == null) { return; } myInTransaction = true; DesignerTransactionUtility.DoInTransaction ( aHost, "MultiPaneControlRemovePage", new TransactionAwareParammedMethod(Transaction_RemovePage), null ); myInTransaction = false; }
private object Transaction_RemovePage(IDesignerHost theHost, object theParam) { if (mySelectedPage == null) { return(null); } MultiPaneControl aCtl = DesignedControl; MemberDescriptor aMember_Controls = TypeDescriptor.GetProperties(aCtl)["Controls"]; RaiseComponentChanging(aMember_Controls); try { theHost.DestroyComponent(mySelectedPage); // NOTE: we don't process anything here because processing will // be performed in Handler_ComponentRemoving } catch { } RaiseComponentChanged(aMember_Controls, null, null); return(null); }
public object CreateControlWithOnePage(IDesignerHost theHost, object theParam) { MultiPaneControl control = (MultiPaneControl)theHost.CreateComponent(typeof(MultiPaneControl)); MultiPanePage page = (MultiPanePage)theHost.CreateComponent(typeof(MultiPanePage)); control.Controls.Add(page); return(new IComponent[] { control }); }
private object Transaction_SetSelectedPageAsConcrete(IDesignerHost theHost, object theParam) { MultiPaneControl designedControl = this.DesignedControl; MemberDescriptor member = TypeDescriptor.GetProperties(designedControl)["SelectedPage"]; base.RaiseComponentChanging(member); designedControl.SelectedPage = (MultiPanePage)theParam; base.RaiseComponentChanged(member, null, null); return(null); }
private void UpdateSidebar(MultiPaneControl sender, SidebarEntry[] entries) { // If the sub-sidebar is empty => there nothing to update, do nothing if (entries == null) { return; } // Will be used to update independently the entry's parents from the entrie // to avoid having its newly assigned status being overridden SidebarEntry ActiveEntry = null; // Will be used to go through the active entry's parents SidebarEntry ParentEntry; // Is the entry active? bool ActiveState; // Update every entry of the given sub-sidebar // (disclamer: we don't use a while loop there to disable every inactive state) foreach (SidebarEntry e in this.GoThroughEntries(entries)) { ActiveState = false; // if the sub-sidebar entry has attached page if (e.Target != null) { ActiveState = sender.SelectedPage == e.Target; // if the new page is same page than the attached one: // -> change its color to the active one // -> mark the entry has active // else: // -> put the inactive color // -> mark it as inactive if (ActiveState) { ActiveEntry = e; this.Text = this.BaseName + " - " + e.Text; } } ToggleEntryActive(e, ActiveState); } // Proceed the active entry and its parents (if there was one) if (ActiveEntry != null) { // Mark the parent as active as well ParentEntry = ActiveEntry.parent; while (ParentEntry != null) { ToggleEntryActive(ParentEntry, true); ParentEntry = ParentEntry.parent; } } }
private object Transaction_UpdateSelectedPage(IDesignerHost theHost, object theParam) { MultiPaneControl aCtl = DesignedControl; MultiPanePage aPgTemp = mySelectedPage; int aCurIndex = aCtl.Controls.IndexOf(mySelectedPage); if (mySelectedPage == aCtl.SelectedPage) //we also need to update the SelectedPage property { MemberDescriptor aMember_SelectedPage = TypeDescriptor.GetProperties(aCtl)["SelectedPage"]; RaiseComponentChanging(aMember_SelectedPage); if (aCtl.Controls.Count > 1) { // begin update current page if (aCurIndex == aCtl.Controls.Count - 1) // NOTE: after SelectedPage has { aCtl.SelectedPage = (MultiPanePage)aCtl.Controls[aCurIndex - 1]; // been updated, mySelectedPage } else // has also changed { aCtl.SelectedPage = (MultiPanePage)aCtl.Controls[aCurIndex + 1]; } // end update current page } else { aCtl.SelectedPage = null; } RaiseComponentChanged(aMember_SelectedPage, null, null); } else { if (aCtl.Controls.Count > 1) { if (aCurIndex == aCtl.Controls.Count - 1) { DesignerSelectedPage = (MultiPanePage)aCtl.Controls[aCurIndex - 1]; } else { DesignerSelectedPage = (MultiPanePage)aCtl.Controls[aCurIndex + 1]; } } else { DesignerSelectedPage = null; } } return(null); }
private object Transaction_AddPage(IDesignerHost theHost, object theParam) { MultiPaneControl designedControl = this.DesignedControl; MultiPanePage page = (MultiPanePage)theHost.CreateComponent(typeof(MultiPanePage)); MemberDescriptor member = TypeDescriptor.GetProperties(designedControl)["Controls"]; base.RaiseComponentChanging(member); designedControl.Controls.Add(page); this.DesignerSelectedPage = page; base.RaiseComponentChanged(member, null, null); return(null); }
private object Transaction_SetSelectedPageAsConcrete(IDesignerHost theHost, object theParam) { MultiPaneControl aCtl = DesignedControl; MemberDescriptor aMember_SelectedPage = TypeDescriptor.GetProperties(aCtl)["SelectedPage"]; RaiseComponentChanging(aMember_SelectedPage); aCtl.SelectedPage = (MultiPanePage)theParam; RaiseComponentChanged(aMember_SelectedPage, null, null); return(null); }
public object CreateControlWithOnePage(IDesignerHost theHost, object theParam) { // Control MultiPaneControl aCtl = (MultiPaneControl)theHost.CreateComponent(typeof(MultiPaneControl)); // Page 1 MultiPanePage aPg = (MultiPanePage)theHost.CreateComponent(typeof(MultiPanePage)); aCtl.Controls.Add(aPg); return(new IComponent[] { aCtl }); }
protected override void FillTreeWithData(ObjectSelectorEditor.Selector theSel, ITypeDescriptorContext theCtx, IServiceProvider theProvider) { base.FillTreeWithData(theSel, theCtx, theProvider); MultiPaneControl instance = (MultiPaneControl)theCtx.Instance; foreach (MultiPanePage page in instance.Controls) { ObjectSelectorEditor.SelectorNode node = new ObjectSelectorEditor.SelectorNode(page.Name, page); theSel.Nodes.Add(node); if (page == instance.SelectedPage) { theSel.SelectedNode = node; } } }
private void Handler_RemovePage(object sender, EventArgs eevent) { MultiPaneControl designedControl = this.DesignedControl; if ((designedControl != null) && (designedControl.Controls.Count >= 1)) { IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (service != null) { this.myInTransaction = true; DesignerTransactionUtility.DoInTransaction(service, "MultiPaneControlRemovePage", new TransactionAwareParammedMethod(this.Transaction_RemovePage), null); this.myInTransaction = false; } } }
private object Transaction_AddPage(IDesignerHost theHost, object theParam) { MultiPaneControl aCtl = DesignedControl; MultiPanePage aNewPage = (MultiPanePage)theHost.CreateComponent(typeof(MultiPanePage)); MemberDescriptor aMem_Controls = TypeDescriptor.GetProperties(aCtl)["Controls"]; RaiseComponentChanging(aMem_Controls); aCtl.Controls.Add(aNewPage); DesignerSelectedPage = aNewPage; RaiseComponentChanged(aMem_Controls, null, null); return(null); }
protected override void OnDragOver(DragEventArgs theDragEvents) { MultiPaneControl designedControl = this.DesignedControl; Point pt = designedControl.PointToClient(new Point(theDragEvents.X, theDragEvents.Y)); if (!designedControl.DisplayRectangle.Contains(pt)) { theDragEvents.Effect = DragDropEffects.None; } else { MultiPanePageDesigner selectedPageDesigner = this.GetSelectedPageDesigner(); if (selectedPageDesigner != null) { selectedPageDesigner.InternalOnDragOver(theDragEvents); } } }
protected override void OnDragOver(DragEventArgs theDragEvents) { MultiPaneControl aCtl = DesignedControl; Point pt = aCtl.PointToClient(new Point(theDragEvents.X, theDragEvents.Y)); if (!aCtl.DisplayRectangle.Contains(pt)) { theDragEvents.Effect = DragDropEffects.None; } else { MultiPanePageDesigner aDsgn_Sel = GetSelectedPageDesigner(); if (aDsgn_Sel != null) { aDsgn_Sel.InternalOnDragOver(theDragEvents); } } }
private object Transaction_UpdateSelectedPage(IDesignerHost theHost, object theParam) { MultiPaneControl designedControl = this.DesignedControl; MultiPanePage mySelectedPage = this.mySelectedPage; int index = designedControl.Controls.IndexOf(this.mySelectedPage); if (this.mySelectedPage == designedControl.SelectedPage) { MemberDescriptor member = TypeDescriptor.GetProperties(designedControl)["SelectedPage"]; base.RaiseComponentChanging(member); if (designedControl.Controls.Count > 1) { if (index == (designedControl.Controls.Count - 1)) { designedControl.SelectedPage = (MultiPanePage)designedControl.Controls[index - 1]; } else { designedControl.SelectedPage = (MultiPanePage)designedControl.Controls[index + 1]; } } else { designedControl.SelectedPage = null; } base.RaiseComponentChanged(member, null, null); } else if (designedControl.Controls.Count > 1) { if (index == (designedControl.Controls.Count - 1)) { this.DesignerSelectedPage = (MultiPanePage)designedControl.Controls[index - 1]; } else { this.DesignerSelectedPage = (MultiPanePage)designedControl.Controls[index + 1]; } } else { this.DesignerSelectedPage = null; } return(null); }
protected override void FillTreeWithData(Selector theSel, ITypeDescriptorContext theCtx, IServiceProvider theProvider) { base.FillTreeWithData(theSel, theCtx, theProvider); //clear the selection MultiPaneControl aCtl = (MultiPaneControl)theCtx.Instance; foreach (MultiPanePage aIt in aCtl.Controls) { SelectorNode aNd = new SelectorNode(aIt.Name, aIt); theSel.Nodes.Add(aNd); if (aIt == aCtl.SelectedPage) { theSel.SelectedNode = aNd; } } }
private void Handler_SelectionChanged(object sender, EventArgs e) { ISelectionService service = (ISelectionService)this.GetService(typeof(ISelectionService)); if (service != null) { ICollection selectedComponents = service.GetSelectedComponents(); MultiPaneControl designedControl = this.DesignedControl; foreach (object obj2 in selectedComponents) { MultiPanePage pageOfControl = GetPageOfControl(obj2); if ((pageOfControl != null) && (pageOfControl.Parent == designedControl)) { this.DesignerSelectedPage = pageOfControl; break; } } } }
private void ContentPanel_SelectedPageChanged(object _s, EventArgs _e) { MultiPaneControl sender = _s as MultiPaneControl; // if the page didn't change: do nothing if (sender.SelectedPage == null) { return; } // Update each sidebar is content foreach (SidebarEntry[] e in this.SidebarsRootEntries) { UpdateSidebar(sender, e); } // Update the form's title and force the repaint this.Refresh(); }
private void Handler_SelectionChanged(object sender, EventArgs e) { ISelectionService aSrv = (ISelectionService)GetService(typeof(ISelectionService)); if (aSrv == null) { return; } ICollection aSel = aSrv.GetSelectedComponents(); MultiPaneControl aCtl = DesignedControl; foreach (object aIt in aSel) { MultiPanePage aPage = GetPageOfControl(aIt); if ((aPage != null) && (aPage.Parent == aCtl)) { DesignerSelectedPage = aPage; break; } } }
private void Handler_ComponentRemoving(object theSender, ComponentEventArgs theArgs) { if (theArgs.Component is MultiPanePage) { MultiPaneControl designedControl = this.DesignedControl; MultiPanePage component = (MultiPanePage)theArgs.Component; if (designedControl.Controls.Contains(component)) { IDesignerHost service = (IDesignerHost)this.GetService(typeof(IDesignerHost)); if (!this.myInTransaction) { this.myInTransaction = true; DesignerTransactionUtility.DoInTransaction(service, "MultiPaneControlRemoveComponent", new TransactionAwareParammedMethod(this.Transaction_UpdateSelectedPage), null); this.myInTransaction = false; } else { this.Transaction_UpdateSelectedPage(service, null); } this.CheckVerbStatus(); } } }
private void Handler_ComponentRemoving(object theSender, ComponentEventArgs theArgs) { if (!(theArgs.Component is MultiPanePage)) { return; } MultiPaneControl aCtl = DesignedControl; MultiPanePage aPg = (MultiPanePage)theArgs.Component; if (!aCtl.Controls.Contains(aPg)) { return; } IDesignerHost aHost = (IDesignerHost)GetService(typeof(IDesignerHost)); if (!myInTransaction) { myInTransaction = true; DesignerTransactionUtility.DoInTransaction ( aHost, "MultiPaneControlRemoveComponent", new TransactionAwareParammedMethod(Transaction_UpdateSelectedPage), null ); myInTransaction = false; } else { Transaction_UpdateSelectedPage(aHost, null); } CheckVerbStatus(); }