internal static void AddTab(DetailsTemplatesSurface designSurface) { if (designSurface != null) { IDesignerHost designerHost = designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost; if (designerHost != null) { DesignerTransaction designerTransaction = null; try { designerTransaction = designerHost.CreateTransaction("TabControlAddTabPage" + designSurface.TemplateTab.Site.Name); Hashtable hashtable = new Hashtable(); hashtable["Parent"] = designSurface.TemplateTab; hashtable["TabPageIndex"] = designSurface.TemplateTab.SelectedIndex + 1; ToolboxItem toolboxItem = new ToolboxItem(typeof(CustomTabPage)); toolboxItem.CreateComponents(designerHost, hashtable); } finally { if (designerTransaction != null) { designerTransaction.Commit(); } } } } }
private void SaveTemplate(CancelEventArgs e) { TabControl templateTab = this.templatePage.TemplateSurface.TemplateTab; MultiValuedProperty <Page> multiValuedProperty = new MultiValuedProperty <Page>(); foreach (object obj in templateTab.TabPages) { CustomTabPage customTabPage = (CustomTabPage)obj; Page detailsTemplateTab = customTabPage.DetailsTemplateTab; detailsTemplateTab.Controls.Clear(); DetailsTemplatesSurface.SortControls(customTabPage, true); foreach (object obj2 in customTabPage.Controls) { Control control = (Control)obj2; DetailsTemplateControl detailsTemplateControl = (control as IDetailsTemplateControlBound).DetailsTemplateControl; detailsTemplateTab.Controls.Add(detailsTemplateControl); } DetailsTemplatesSurface.SortControls(customTabPage, false); multiValuedProperty.Add(detailsTemplateTab); } DetailsTemplate detailsTemplate = this.templatePage.BindingSource.DataSource as DetailsTemplate; detailsTemplate.Pages = multiValuedProperty; if (this.templatePage.DataHandler != null) { this.templatePage.DataHandler.SpecifyParameterNames("Pages"); } this.templatePage.Apply(e); this.RefreshOnFinish.Refresh(base.CreateProgress(Strings.Refreshing)); }
internal void LoadTemplate(DetailsTemplate currentTemplate) { IDesignerHost designerHost = base.GetService(typeof(IDesignerHost)) as IDesignerHost; Control control = designerHost.RootComponent as Control; CustomTabControl customTabControl = (CustomTabControl)DetailsTemplatesSurface.CreateComponent(typeof(CustomTabControl), designerHost); customTabControl.Parent = control; int num = 0; int num2 = 0; customTabControl.SuspendLayout(); customTabControl.TabPages.Clear(); if (currentTemplate.Pages != null) { foreach (Page page in currentTemplate.Pages) { CustomTabPage customTabPage = (CustomTabPage)DetailsTemplatesSurface.CreateComponent(typeof(CustomTabPage), designerHost); customTabPage.DetailsTemplateTab = page; foreach (DetailsTemplateControl detailsTemplateControl in page.Controls) { Type type = detailsTemplateControl.GetType(); Control control2 = (Control)DetailsTemplatesSurface.CreateComponent(DetailsTemplatesSurface.controlMapping[type], designerHost); control2.Location = DetailsTemplatesSurface.DialogUnitsToPixel(detailsTemplateControl.X, detailsTemplateControl.Y, this.ExchangeForm); control2.Size = new Size(DetailsTemplatesSurface.DialogUnitsToPixel(detailsTemplateControl.Width, detailsTemplateControl.Height, this.ExchangeForm)); customTabPage.Controls.Add(control2); (control2 as IDetailsTemplateControlBound).DetailsTemplateControl = detailsTemplateControl; int val = control2.Location.X + control2.Size.Width; int val2 = control2.Location.Y + control2.Size.Height; num = Math.Max(num, val); num2 = Math.Max(num2, val2); } customTabControl.TabPages.Add(customTabPage); DetailsTemplatesSurface.SortControls(customTabPage, false); } } num += 25; num2 += 50; num = Math.Max(num, 200); num2 = Math.Max(num2, 200); control.Size = new Size(num, num2); control.MinimumSize = new Size(200, 200); PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(customTabControl)["Size"]; propertyDescriptor.SetValue(customTabControl, new Size(num, num2)); this.templateTab = customTabControl; this.MonitorService(); this.templateTab.SelectedIndexChanged += this.selectionService_SelectionChanged; this.selectionService_SelectionChanged(null, null); this.templateTab.Resize += this.templateTab_Resize; }
private void StartDragEvent(string toolName) { if (toolName != null) { ToolboxItem toolboxItem = Toolbox.toolboxItemDictionary[toolName]; if (this.mouseClicks == 1) { DataObject data = this.SerializeToolboxItem(toolboxItem) as DataObject; base.DoDragDrop(data, DragDropEffects.Copy); DetailsTemplatesSurface.SortControls(this.designSurface.TemplateTab.SelectedTab, false); this.mouseClicks = 0; return; } if (this.mouseClicks == 2) { IDesignerHost designerHost = (IDesignerHost)this.designSurface.GetService(typeof(IDesignerHost)); ISelectionService selectionService = (designerHost == null) ? null : (designerHost.GetService(typeof(ISelectionService)) as ISelectionService); if (selectionService != null) { DesignerTransaction designerTransaction = null; try { designerTransaction = designerHost.CreateTransaction(toolboxItem.TypeName + this.designSurface.TemplateTab.Site.Name); Hashtable hashtable = new Hashtable(); hashtable["Parent"] = this.designSurface.TemplateTab.SelectedTab; ICollection collection = toolboxItem.CreateComponents(designerHost, hashtable); if (collection != null && collection.Count > 0) { selectionService.SetSelectedComponents(collection, SelectionTypes.Replace); } } finally { if (designerTransaction != null) { designerTransaction.Commit(); } } DetailsTemplatesSurface.SortControls(this.designSurface.TemplateTab.SelectedTab, false); } this.mouseClicks = 0; } } }
private static void RemoveTab(DetailsTemplatesSurface designSurface) { UIService uiservice = null; IDesignerHost designerHost = designSurface.GetService(typeof(IDesignerHost)) as IDesignerHost; if (designerHost != null) { uiservice = (designerHost.GetService(typeof(UIService)) as UIService); } if (uiservice != null) { if (designSurface.TemplateTab.Controls.Count <= 1) { uiservice.ShowMessage(Strings.CannotDeletePage); return; } TabPage selectedTab = designSurface.TemplateTab.SelectedTab; if (selectedTab != null) { DialogResult dialogResult = uiservice.ShowMessage(Strings.ConfirmDeleteTab(selectedTab.Text), UIService.DefaultCaption, MessageBoxButtons.OKCancel); if (dialogResult == DialogResult.OK) { DesignerTransaction designerTransaction = null; try { designerTransaction = designerHost.CreateTransaction("TabControlRemoveTabPage" + designSurface.TemplateTab.Site.Name); designerHost.DestroyComponent(selectedTab); } finally { if (designerTransaction != null) { designerTransaction.Commit(); } } designSurface.DataContext.IsDirty = true; } } } }
internal DetailsTemplatesMenuService(DetailsTemplatesSurface detailsTemplatesDesignSurface) : base(detailsTemplatesDesignSurface) { this.designSurface = detailsTemplatesDesignSurface; this.AddCommand(new MenuCommand(new EventHandler(this.ExecuteUndo), StandardCommands.Undo) { Enabled = false }); this.AddCommand(new MenuCommand(new EventHandler(this.ExecuteRedo), StandardCommands.Redo) { Enabled = false }); MenuCommand command = new MenuCommand(new EventHandler(this.AddNewTabPage), DetailsTemplatesMenuService.AddTabPageCommandId); this.AddCommand(command); MenuCommand command2 = new MenuCommand(new EventHandler(this.RemoveCurrentTabPage), DetailsTemplatesMenuService.RemoveTabPageCommandId); this.AddCommand(command2); MenuCommand command3 = new MenuCommand(new EventHandler(this.DoSelectNextControl), DetailsTemplatesMenuService.SelectNextControl); this.AddCommand(command3); this.readOnlyCommandList.Add(DetailsTemplatesMenuService.SelectNextControl); MenuCommand command4 = new MenuCommand(new EventHandler(this.DoSelectPreviousControl), DetailsTemplatesMenuService.SelectPreviousControl); this.AddCommand(command4); this.readOnlyCommandList.Add(DetailsTemplatesMenuService.SelectPreviousControl); MenuCommand command5 = new MenuCommand(new EventHandler(this.DoSwitchTabPage), DetailsTemplatesMenuService.SwitchTabPage); this.AddCommand(command5); this.readOnlyCommandList.Add(DetailsTemplatesMenuService.SwitchTabPage); MenuCommand command6 = new MenuCommand(new EventHandler(this.DoSelectAllInCurrentTab), DetailsTemplatesMenuService.SelectAllCommandId); this.AddCommand(command6); this.readOnlyCommandList.Add(DetailsTemplatesMenuService.SelectAllCommandId); this.selectionService = (base.GetService(typeof(ISelectionService)) as ISelectionService); if (this.selectionService != null) { this.selectionService.SelectionChanged += this.selectionService_SelectionChanged; } }
private void changeService_ComponentChanged(object sender, ComponentChangedEventArgs e) { this.needUpdatingPropertyGrid = true; Control control = e.Component as Control; if (control is IDetailsTemplateControlBound) { DetailsTemplateControl detailsTemplateControl = (control as IDetailsTemplateControlBound).DetailsTemplateControl; control.Location = new Point(Math.Max(control.Location.X, 0), Math.Max(control.Location.Y, 0)); Point point = DetailsTemplatesSurface.PixelToDialogUnits(control.Size.Width, control.Size.Height, this.ExchangeForm); Point point2 = DetailsTemplatesSurface.PixelToDialogUnits(control.Location.X, control.Location.Y, this.ExchangeForm); string name; if ((name = e.Member.Name) != null) { if (!(name == "Size") && !(name == "Width") && !(name == "Height")) { if (name == "Location") { detailsTemplateControl.X = point2.X; detailsTemplateControl.Y = point2.Y; } } else { detailsTemplateControl.Width = point.X; detailsTemplateControl.Height = point.Y; detailsTemplateControl.X = point2.X; detailsTemplateControl.Y = point2.Y; } } } if (!(e.Component is TabControl)) { this.DataContext.IsDirty = true; } }
public Toolbox(DetailsTemplatesSurface designSurface) { this.designSurface = designSurface; }
internal static IComponent CreateComponent(Type componentType, IDesignerHost host) { return(DetailsTemplatesSurface.CreateComponent(new ToolboxItem(componentType), host)); }