private void OnInsertPage(object sender, EventArgs e) { VisualTabControl _parentalControl = (VisualTabControl)Control; Control.ControlCollection _controlCollection = _parentalControl.Controls; int _index = _parentalControl.SelectedIndex; RaiseComponentChanging(TypeDescriptor.GetProperties(_parentalControl)["TabPages"]); VisualTabPage _tabPage = (VisualTabPage)DesignerHost.CreateComponent(typeof(VisualTabPage)); _tabPage.Text = _tabPage.Name; var _tabPageCollection = new VisualTabPage[_parentalControl.TabCount]; // Starting at our Insert Position, store and remove all the tab pages. for (int i = _index; i <= _tabPageCollection.Length - 1; i++) { _tabPageCollection[i] = (VisualTabPage)_parentalControl.TabPages[_index]; _parentalControl.TabPages.Remove(_parentalControl.TabPages[_index]); } // add the tab page to be inserted. _parentalControl.TabPages.Add(_tabPage); // then re-add the original tab pages. for (int i = _index; i <= _tabPageCollection.Length - 1; i++) { _parentalControl.TabPages.Add(_tabPageCollection[i]); } RaiseComponentChanged(TypeDescriptor.GetProperties(_parentalControl)["TabPages"], _controlCollection, _parentalControl.TabPages); _parentalControl.SelectedTab = _tabPage; SetVerbs(); }
void OnInsertPage(Object sender, EventArgs e) { EbTabControl ParentControl = (EbTabControl)Control; Control.ControlCollection oldTabs = ParentControl.Controls; int Index = ParentControl.SelectedIndex; RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); EbTabPage P = (EbTabPage)(DesignerHost.CreateComponent(typeof(EbTabPage))); P.Text = P.Name; EbTabPage[] tpc = new EbTabPage[ParentControl.TabCount]; //Starting at our Insert Position, store and remove all the tabpages. for (int i = Index; i <= tpc.Length - 1; i++) { tpc[i] = (EbTabPage)ParentControl.TabPages[Index]; ParentControl.TabPages.Remove(ParentControl.TabPages[Index]); } //add the tabpage to be inserted. ParentControl.TabPages.Add(P); //then re-add the original tabpages. for (int i = Index; i <= tpc.Length - 1; i++) { ParentControl.TabPages.Add(tpc[i]); } RaiseComponentChanged(TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages); ParentControl.SelectedTab = P; SetVerbs(); }
public void AddTab() { TabPage page = (TabPage)DesignerHost.CreateComponent(typeof(TabPage)); page.Text = page.Name; this.KryptonTabControl.TabPages.Add(page); this.KryptonTabControl.SelectedTab = page; }
private void AddPage(object sender, System.EventArgs e) { if (DesignerHost != null) { IComponent c = DesignerHost.CreateComponent(typeof(ComponentsNET.cnTabPage)); TabControl.TabPages.Add(c as cnTabPage); verbRemovePage.Enabled = true; } }
public override void OnSetComponentDefaults() { HostControl.ManagedPanels.Add((ManagedPanel)DesignerHost.CreateComponent(typeof(ManagedPanel))); HostControl.ManagedPanels.Add((ManagedPanel)DesignerHost.CreateComponent(typeof(ManagedPanel))); PanelManager pm = (PanelManager)Control; pm.ManagedPanels[0].Text = pm.ManagedPanels[0].Name; pm.ManagedPanels[1].Text = pm.ManagedPanels[1].Name; HostControl.SelectedIndex = 0; }
public override void InitializeNewComponent(IDictionary defaultValues) { base.InitializeNewComponent(defaultValues); HostControl.ManagedPanels.Add((Controls.ManagedPanel)DesignerHost.CreateComponent(typeof(Controls.ManagedPanel))); HostControl.ManagedPanels.Add((Controls.ManagedPanel)DesignerHost.CreateComponent(typeof(Controls.ManagedPanel))); Controls.PanelManager pm = (Controls.PanelManager) this.Control; pm.ManagedPanels[0].Text = pm.ManagedPanels[0].Name; pm.ManagedPanels[1].Text = pm.ManagedPanels[1].Name; HostControl.SelectedIndex = 0; }
public override void InitializeNewComponent(IDictionary defaultValues) { base.InitializeNewComponent(defaultValues); VisualTabPage _tabPage1 = (VisualTabPage)DesignerHost.CreateComponent(typeof(VisualTabPage)); VisualTabPage _tabPage2 = (VisualTabPage)DesignerHost.CreateComponent(typeof(VisualTabPage)); _tabPage1.Text = _tabPage1.Name; _tabPage2.Text = _tabPage2.Name; Control.Controls.Add(_tabPage1); Control.Controls.Add(_tabPage2); }
/// <summary> /// Adds a tab to the designed control. /// </summary> public void AddTab() { if (DesignerHost != null) { Tab tab = (Tab)DesignerHost.CreateComponent(typeof(Tab)); PropertyDescriptor nameProp = TypeDescriptor.GetProperties(tab)["Name"]; string name = (string)nameProp.GetValue(tab); PropertyDescriptor textProp = TypeDescriptor.GetProperties(tab)["Text"]; textProp.SetValue(tab, name); Control.Tabs.Add(tab); Control.SelectedTab = tab; } }
private void OnAddPanel(Object sender, EventArgs e) { Control.ControlCollection oldManagedPanels = HostControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(HostControl)["ManagedPanels"]); Controls.ManagedPanel P = (Controls.ManagedPanel)DesignerHost.CreateComponent(typeof(Controls.ManagedPanel)); P.Text = P.Name; HostControl.ManagedPanels.Add(P); RaiseComponentChanged(TypeDescriptor.GetProperties(HostControl)["ManagedPanels"], oldManagedPanels, HostControl.ManagedPanels); HostControl.SelectedPanel = P; SetVerbs(); }
/// <summary> /// Adds a new page. /// </summary> protected void AddPageHandler(object sender, EventArgs e) { if (DesignerHost != null) { Page page = (Page)DesignerHost.CreateComponent(typeof(Page)); page.Text = string.Format("Page {0}", Control.Pages.Count + 1); Control.Pages.Add(page); Control.SelectedPage = page; if (SelectionService != null) { SelectionService.SetSelectedComponents(new Component[] { Control.SelectedPage }); } } }
private void OnAddPage(object sender, EventArgs e) { VisualTabControl _parentalControl = (VisualTabControl)Control; Control.ControlCollection _controlCollection = _parentalControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(_parentalControl)["TabPages"]); VisualTabPage _tabPage = (VisualTabPage)DesignerHost.CreateComponent(typeof(VisualTabPage)); _tabPage.Text = _tabPage.Name; _parentalControl.TabPages.Add(_tabPage); RaiseComponentChanged(TypeDescriptor.GetProperties(_parentalControl)["TabPages"], _controlCollection, _parentalControl.TabPages); _parentalControl.SelectedTab = _tabPage; SetVerbs(); }
private void OnAddPage(Object sender, EventArgs e) { var parentControl = (MTabControl)Control; var oldTabs = parentControl.Pages; RaiseComponentChanging(TypeDescriptor.GetProperties(parentControl)["Pages"]); var p = (DTabPage)(DesignerHost.CreateComponent(typeof(DTabPage))); p.Text = "选项卡"; parentControl.Pages.Add(p); RaiseComponentChanged(TypeDescriptor.GetProperties(parentControl)["Pages"], oldTabs, parentControl.Pages); parentControl.SelectedIndex = p.Index; }
private void OnAddPage(Object sender, EventArgs e) { var parentControl = (MSideBar)Control; var oldTabs = parentControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(parentControl)["Controls"]); var p = (MSideBarMenu)(DesignerHost.CreateComponent(typeof(MSideBarMenu))); p.Text = p.Name; p.Width = parentControl.Width; parentControl.Controls.Add(p); RaiseComponentChanged(TypeDescriptor.GetProperties(parentControl)["Controls"], oldTabs, parentControl.Controls); parentControl.SelectedMenu = p; }
/// <summary> /// Adds default tag pages to a new <see cref="VerticalTabControl"/>. /// </summary> /// <param name="defaultValues">The values with which to instantiate the control.</param> public override void InitializeNewComponent(IDictionary defaultValues) { base.InitializeNewComponent(defaultValues); VerticalTabPage tpgPage = (VerticalTabPage)DesignerHost.CreateComponent(typeof(VerticalTabPage)); tpgPage.Text = tpgPage.Name; tpgPage.BackColor = Color.FromKnownColor(KnownColor.Control); DesignedTabControl.TabPages.Add(tpgPage); tpgPage = (VerticalTabPage)DesignerHost.CreateComponent(typeof(VerticalTabPage)); tpgPage.Text = tpgPage.Name; tpgPage.BackColor = Color.FromKnownColor(KnownColor.Control); DesignedTabControl.TabPages.Add(tpgPage); DesignedTabControl.SelectedIndex = 0; }
/// <summary> /// The event handler for the "Add Tab Page" verb. /// </summary> /// <remarks> /// Adds a new tab page to the control. /// </remarks> /// <param name="sender">The object that triggered the event.</param> /// <param name="e">An <see cref="EventArgs"/> describing the event arguments.</param> private void AddTabPage(object sender, EventArgs e) { VerticalTabControl.TabPageCollection tpcOldPages = DesignedTabControl.TabPages; RaiseComponentChanging(TypeDescriptor.GetProperties(DesignedTabControl)["TabPages"]); VerticalTabPage tpgPage = (VerticalTabPage)DesignerHost.CreateComponent(typeof(VerticalTabPage)); tpgPage.Text = tpgPage.Name; tpgPage.BackColor = Color.FromKnownColor(KnownColor.Control); DesignedTabControl.TabPages.Add(tpgPage); RaiseComponentChanged(TypeDescriptor.GetProperties(DesignedTabControl)["TabPages"], tpcOldPages, DesignedTabControl.TabPages); DesignedTabControl.SelectedTabPage = tpgPage; EnableVerbs(); }
private void OnAddPage(Object sender, EventArgs e) { var parentControl = (AntTopMenu)Control; var oldTabs = parentControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(parentControl)["TabPages"]); var p = (MenuPage)(DesignerHost.CreateComponent(typeof(MenuPage))); p.Text = p.Name; parentControl.TabPages.Add(p); RaiseComponentChanged(TypeDescriptor.GetProperties(parentControl)["TabPages"], oldTabs, parentControl.TabPages); parentControl.SelectedTab = p; SetVerbs(); }
void OnAddPage(Object sender, EventArgs e) { EbTabControl ParentControl = (EbTabControl)Control; Control.ControlCollection oldTabs = ParentControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); EbTabPage P = (EbTabPage)(DesignerHost.CreateComponent(typeof(EbTabPage))); P.Text = P.Name; ParentControl.TabPages.Add(P); RaiseComponentChanged(TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages); ParentControl.SelectedTab = P; SetVerbs(); }
/// <summary> /// Adds a new tab. /// </summary> protected void AddTabHandler(object sender, EventArgs e) { if (DesignerHost != null) { MemberDescriptor member = TypeDescriptor.GetProperties(Component)["Controls"]; RaiseComponentChanging(member); Tab tab = (Tab)DesignerHost.CreateComponent(typeof(Tab)); PropertyDescriptor nameProp = TypeDescriptor.GetProperties(tab)["Name"]; string name = (string)nameProp.GetValue(tab); PropertyDescriptor textProp = TypeDescriptor.GetProperties(tab)["Text"]; textProp.SetValue(tab, name); Control.Tabs.Add(tab); Control.SelectedTab = tab; RaiseComponentChanged(member, null, null); } }
public override void InitializeNewComponent(System.Collections.IDictionary defaultValues) { /* Creating my own TabPage class * http://social.msdn.microsoft.com/Forums/en/winformsdesigner/thread/2d9ea42c-f29b-49b2-ba2b-0964975fad17 */ base.InitializeNewComponent(defaultValues); KryptonTabPage page1 = (KryptonTabPage)DesignerHost.CreateComponent(typeof(KryptonTabPage)); page1.Text = page1.Name; KryptonTabPage page2 = (KryptonTabPage)DesignerHost.CreateComponent(typeof(KryptonTabPage)); page2.Text = page2.Name; this.KryptonTabControl.Size = new Size(300, 200); this.KryptonTabControl.TabPages.AddRange(new KryptonTabPage[] { page1, page2 }); }
/// <summary> /// Handles the <see cref="E:AddPage" /> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param> void OnAddPage(Object sender, EventArgs e) { ZeroitPastezTab ParentControl = (ZeroitPastezTab)Control; System.Windows.Forms.Control.ControlCollection oldTabs = ParentControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); System.Windows.Forms.TabPage P = (System.Windows.Forms.TabPage)(DesignerHost.CreateComponent(typeof(ZeroitPastezTabPage))); P.Text = P.Name; ParentControl.TabPages.Add(P); RaiseComponentChanged(TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages); ParentControl.SelectedTab = P; SetVerbs(); }
/// <summary> /// Handles the <see cref="E:AddTabPage" /> event. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> private void OnAdd_TabPage(object sender, System.EventArgs e) { ZeroitAyensuTab ParentControl = (ZeroitAyensuTab)this.Control; System.Windows.Forms.Control.ControlCollection oldTabs = ParentControl.Controls; RaiseComponentChanging(TypeDescriptor.GetProperties(ParentControl)["TabPages"]); string newTab_Name = "Page" + (ParentControl.TabCount + 1).ToString(); System.Windows.Forms.TabPage newTab = (System.Windows.Forms.TabPage)DesignerHost.CreateComponent( typeof(System.Windows.Forms.TabPage) ); #region Commented out -- alternate creation of the new TabPage // This signature supplies the actual name of the control being created ... however, if there // is already a control by that name (this can easily happen if a TabPage is added and then // removed from the collection), an exception is thrown. So, it's better to instead allow // the default name to be generated/used. //System.Windows.Forms.TabPage newTab = // (System.Windows.Forms.TabPage)DesignerHost.CreateComponent( // typeof(System.Windows.Forms.TabPage), // newTab_Name // ); #endregion //newTab.Text = newTab.Name; // Set .Text to the auto-generated name newTab.Text = newTab_Name; ParentControl.TabPages.Add(newTab); RaiseComponentChanged( System.ComponentModel.TypeDescriptor.GetProperties(ParentControl)["TabPages"], oldTabs, ParentControl.TabPages ); ParentControl.SelectedTab = newTab; Verbs_Set(); }
public TComponent CreateComponent <TComponent>() where TComponent : IComponent { return((TComponent)DesignerHost.CreateComponent(typeof(TComponent))); }
private void Initialize() { IDesignerHost host; Form form; IRootDesigner rootDesigner; Control view; // Initialise service container and designer host serviceContainer = new ServiceContainer(); serviceContainer.AddService(typeof(INameCreationService), new NameCreationService()); serviceContainer.AddService(typeof(IUIService), new UIService(this)); host = new DesignerHost(serviceContainer); // Add toolbox service serviceContainer.AddService(typeof(IToolboxService), lstToolbox); lstToolbox.designPanel = pnlViewHost; PopulateToolbox(lstToolbox); // Add menu command service menuService = new MenuCommandService(); serviceContainer.AddService(typeof(IMenuCommandService), menuService); // Start the designer host off with a Form to design form = (Form)host.CreateComponent(typeof(Form)); form.TopLevel = false; form.Text = "Form1"; // Get the root designer for the form and add its design view to this form rootDesigner = (IRootDesigner)host.GetDesigner(form); view = (Control)rootDesigner.GetView(ViewTechnology.WindowsForms); view.Dock = DockStyle.Fill; pnlViewHost.Controls.Add(view); // Subscribe to the selectionchanged event and activate the designer ISelectionService s = (ISelectionService)serviceContainer.GetService(typeof(ISelectionService)); s.SelectionChanged += new EventHandler(OnSelectionChanged); host.Activate(); }