Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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;
        }
Exemplo n.º 3
0
 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;
         }
     }
 }