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 };
 }
      /// <summary>
      /// Creates a new instance of the NaviBar component with design time support
      /// </summary>
      /// <param name="host">The controls host</param>
      /// <returns>The newly created component</returns>
      protected override IComponent[] CreateComponentsCore(IDesignerHost host)
      {
         // Create the control
         NaviBar naviBarCtrl = (NaviBar)host.CreateComponent(typeof(NaviBar));
         NaviBand naviBandCtrl = (NaviBand)host.CreateComponent(typeof(NaviBand));

         // Add a new button
         naviBarCtrl.Controls.Add(naviBandCtrl);

         return new IComponent[] { naviBarCtrl };
      }
 public object CreateControlWithOneTabPage(IDesignerHost host, object parameter)
 {
     // Tab Page
     NeoTabPage tabPage = (NeoTabPage)host.CreateComponent(typeof(NeoTabPage));
     tabPage.BackColor = System.Drawing.Color.Transparent;
     // Tab Control
     NeoTabWindow tabControl = (NeoTabWindow)parameter;
     tabControl.Controls.Add(tabPage);
     ((ISupportInitialize)tabControl).EndInit();
     using (System.Windows.Forms.FolderBrowserDialog fdialog =
         new System.Windows.Forms.FolderBrowserDialog())
     {
         fdialog.RootFolder = Environment.SpecialFolder.MyComputer;
         fdialog.Description = "Select application directory for control rendering.";
         fdialog.ShowNewFolderButton = false;
         if (fdialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             string rootFolder = System.IO.Directory.GetCurrentDirectory();
             System.IO.Directory.SetCurrentDirectory(fdialog.SelectedPath);
             // Shows a add-in model dialog box.
             tabControl.ShowAddInRendererManager();
             System.IO.Directory.SetCurrentDirectory(rootFolder);
         }
     }
     return parameter;
 }
Esempio n. 4
0
        /// <summary>
        /// Event handler for the "Add Page" verb.
        /// </summary>
        /// <param name="dh"></param>
        /// <param name="panel"></param>
        private static void AddPage(IDesignerHost dh, MultiPanel panel)
        {
            DesignerTransaction dt = dh.CreateTransaction("Added new page");

            // Gets a free name
            int i = 1;
            while (panel.Controls.Cast<Control>().Any(x => x.Name == "Page" + i))
            {
                i++;
            }
            string name = "Page" + i;

            // Creates the page
            MultiPanelPage newPage = dh.CreateComponent(typeof(MultiPanelPage), name) as MultiPanelPage;
            if (newPage != null)
            {
                newPage.Text = name;
                panel.Controls.Add(newPage);

                // Update selection
                panel.SelectedPage = newPage;
            }

            dt.Commit();
        }
Esempio n. 5
0
        public WorkflowViewWrapper()
        {
            this.loader = new Loader();

            // Create a Workflow Design Surface
            this.surface = new DesignSurface();
            this.surface.BeginLoad(this.loader);

            // Get the Workflow Designer Host
            this.Host = this.surface.GetService(typeof(IDesignerHost)) as IDesignerHost;

            if (this.Host == null)
                return;

            // Create a Sequential Workflow by using the Workflow Designer Host
            SequentialWorkflow = (SequentialWorkflowActivity)Host.CreateComponent(typeof(SequentialWorkflowActivity));
            SequentialWorkflow.Name = "CustomOutlookWorkflow";

            // Create a Workflow View on the Workflow Design Surface
            this.workflowView = new WorkflowView(this.surface as IServiceProvider);

            // Add a message filter to the workflow view, to support panning
            MessageFilter filter = new MessageFilter(this.surface as IServiceProvider, this.workflowView);
            this.workflowView.AddDesignerMessageFilter(filter);

            // Activate the Workflow View
            this.Host.Activate();

            this.workflowView.Dock = DockStyle.Fill;
            this.Controls.Add(workflowView);
            this.Dock = DockStyle.Fill;
        }
 protected virtual IComponent[] CreateComponentsCore(IDesignerHost host)
 {
     ArrayList list = new ArrayList();
     Type componentClass = this.GetType(host, this.AssemblyName, this.TypeName, true);
     if (componentClass != null)
     {
         if (host != null)
         {
             list.Add(host.CreateComponent(componentClass));
         }
         else if (typeof(IComponent).IsAssignableFrom(componentClass))
         {
             list.Add(TypeDescriptor.CreateInstance(null, componentClass, null, null));
         }
     }
     IComponent[] array = new IComponent[list.Count];
     list.CopyTo(array, 0);
     return array;
 }
		// FIXME - get error handling logic correct
		protected virtual IComponent[] CreateComponentsCore (IDesignerHost host)
		{
			if (host == null)
				throw new ArgumentNullException("host");
			
			IComponent[] components;
			Type type = GetType(host, AssemblyName, TypeName, true);
			if (type == null)
				components = new IComponent[] { };
			else
				components = new IComponent[] { host.CreateComponent(type) };

			return components;
		}
Esempio n. 8
0
        private ToolStripItem CreatestripButton(IDesignerHost host, string buttonName, string buttonText)
        {
            Assembly assembly = this.Component.GetType().Assembly;
            ToolStripButton item = host.CreateComponent(typeof(ToolStripButton), buttonName) as ToolStripButton;
            Stream s = assembly.GetManifestResourceStream("FLTools.FLNavigator." + buttonText + ".png");
            if (s != null)
            {
                Bitmap bitmap = new Bitmap(s);
                bitmap.MakeTransparent(Color.Magenta);
                item.Image = bitmap;
                item.DisplayStyle = ToolStripItemDisplayStyle.Image;
            }
            else
            {
                item.DisplayStyle = ToolStripItemDisplayStyle.Text;
            }
            item.Text = buttonText;

            return item;
        }
 internal static object CreateInstance(System.Type itemType, IDesignerHost host, string name)
 {
     object obj2 = null;
     if (typeof(IComponent).IsAssignableFrom(itemType) && (host != null))
     {
         obj2 = host.CreateComponent(itemType, name);
         if (host != null)
         {
             IComponentInitializer designer = host.GetDesigner((IComponent) obj2) as IComponentInitializer;
             if (designer != null)
             {
                 designer.InitializeNewComponent(null);
             }
         }
     }
     if (obj2 == null)
     {
         obj2 = TypeDescriptor.CreateInstance(host, itemType, null, null);
     }
     return obj2;
 }
        private Dictionary<Component, Component> CreateComponents(Type componentType, object instance, IDesignerHost designerHost)
        {
            Dictionary<Component, Component> components = new Dictionary<Component, Component>();
            // get each field of type.
            foreach (FieldInfo field in componentType.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
            {
                // check if it is defined in the type that is being compiled, and not a field in some base class.
                if (field.DeclaringType.TypeHandle.Value == componentType.TypeHandle.Value) 
                {
                    if (field.FieldType.HasConstructor())
                    {
                        object obj = field.GetValue(instance);

                        // create the component.
                        Component component = designerHost.CreateComponent(field.FieldType, field.Name) as Component;
                        components.Add(field.GetValue(instance) as Component, component);
                    }
                }
            }
            return components;
        }
Esempio n. 11
0
        internal static void ConfigureGrid(ref Grid grid, ref IDesignerHost designerhost,
            ref IComponentChangeService componentChangeService,
            ref DesignerTransaction dt, GridTemplate template)
        {
            if (template == GridTemplate.None)
                return;

            switch (template)
            {
                case GridTemplate.ProductCatalog:
                    {
                        dt = designerhost.CreateTransaction(string.Format("Configure WebGrid as {0}", template));

                        grid.RecordsPerRow = 3;
                        grid.Width = Unit.Percentage(100);
                        grid.Title = "Product catalog";
                        grid.DefaultVisibility = Visibility.None;
                        grid.DisplayView = DisplayView.Grid;
                        grid.Columns.Clear();

                        Text producttitle = (Text) designerhost.CreateComponent(typeof (Text));
                        producttitle.ColumnId = "productTitle";
                        producttitle.Grid = grid;
                        producttitle.Title = "Title";
                        producttitle.Visibility = Visibility.Both;
                        producttitle.DisplayIndex = 10;

                        grid.Columns.Add(producttitle);

                        File productImageGrid = (File) designerhost.CreateComponent(typeof (File));
                        productImageGrid.ColumnId = "productImageGrid";
                        productImageGrid.Grid = grid;
                        productImageGrid.Title = "Grid image";
                        productImageGrid.HideDetailTitle = true;
                        productImageGrid.NewRowInGrid = true;
                        productImageGrid.Visibility = Visibility.Grid;
                        productImageGrid.DisplayIndex = 20;

                        grid.Columns.Add(productImageGrid);

                        File productImageEdit = (File) designerhost.CreateComponent(typeof (File));
                        productImageEdit.ColumnId = "productImageEdit";
                        productImageEdit.Title = "Edit image";
                        productImageEdit.Grid = grid;
                        productImageEdit.HideDetailTitle = true;
                        productImageEdit.NewRowInGrid = true;
                        productImageEdit.Visibility = Visibility.Detail;
                        productImageEdit.DisplayIndex = 20;

                        grid.Columns.Add(productImageEdit);

                        Text productGridDescription = (Text) designerhost.CreateComponent(typeof (Text));
                        productGridDescription.ColumnId = "productGridDescription";
                        productGridDescription.Title = "Grid description";
                        productGridDescription.Grid = grid;
                        productGridDescription.HideDetailTitle = true;
                        productGridDescription.Visibility = Visibility.Grid;
                        productGridDescription.IsHtml = true;
                        productGridDescription.DisplayIndex = 30;

                        grid.Columns.Add(productGridDescription);

                        Text productEditDescription = (Text) designerhost.CreateComponent(typeof (Text));
                        productEditDescription.ColumnId = "productGridDescription";
                        productEditDescription.Grid = grid;
                        productEditDescription.Title = "Edit description";
                        productEditDescription.HideDetailTitle = true;
                        productEditDescription.IsHtml = true;
                        productEditDescription.Visibility = Visibility.Detail;
                        productEditDescription.DisplayIndex = 30;

                        grid.Columns.Add(productEditDescription);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
                case GridTemplate.UserRegistration:
                    {
                        grid.Width = Unit.Pixel(500);
                        grid.Title = "User login";
                        grid.DefaultVisibility = Visibility.None;
                        grid.DisplayView = DisplayView.Detail;
                        grid.AllowCancel = false;
                        grid.AllowUpdate = true;
                        grid.RecordsPerRow = 1;

                        grid.Columns.Clear();

                        Text userloginID = (Text) designerhost.CreateComponent(typeof (Text));
                        userloginID.ColumnId = "LoginID";
                        userloginID.Title = "Login ID";
                        userloginID.Grid = grid;
                        userloginID.HideDetailTitle = true;
                        userloginID.Visibility = Visibility.Detail;
                        userloginID.DisplayIndex = 10;
                        userloginID.Required = true;
                        grid.Columns.Add(userloginID);

                        Text userpassword = (Text) designerhost.CreateComponent(typeof (Text));
                        userpassword.ColumnId = "LoginPassword";
                        userpassword.Title = "Login password";
                        userpassword.Grid = grid;
                        userpassword.IsPassword = true;
                        userpassword.Visibility = Visibility.Detail;
                        userpassword.DisplayIndex = 20;
                        userpassword.ValidExpression = "[RepeatPassword] != [LoginPassword]";
                        userpassword.Required = true;
                        userpassword.MinSize = 5;
                        userpassword.MaxSize = 15;
                        userpassword.SystemMessage = "Your passwords did not match.";

                        grid.Columns.Add(userpassword);

                        Text repeatuserpassword = (Text) designerhost.CreateComponent(typeof (Text));
                        repeatuserpassword.ColumnId = "RepeatPassword";
                        repeatuserpassword.Title = "Repeat password";
                        repeatuserpassword.NewRowInDetail = false;
                        repeatuserpassword.Grid = grid;
                        repeatuserpassword.IsPassword = true;
                        repeatuserpassword.Visibility = Visibility.Detail;
                        repeatuserpassword.DisplayIndex = 30;
                        repeatuserpassword.MinSize = 5;
                        repeatuserpassword.MaxSize = 15;
                        repeatuserpassword.Required = true;

                        grid.Columns.Add(repeatuserpassword);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
                case GridTemplate.RowSummary:
                    {
                        grid.Width = Unit.Percentage(100);
                        grid.Title = "Row summary";
                        grid.DefaultVisibility = Visibility.None;
                        grid.RecordsPerRow = 1;
                        grid.DisplayView = DisplayView.Grid;

                        grid.Columns.Clear();

                        Decimal productprice = (Decimal) designerhost.CreateComponent(typeof (Decimal));
                        productprice.ColumnId = "Price";
                        productprice.Title = "Price";
                        productprice.Grid = grid;
                        productprice.Visibility = Visibility.Both;
                        productprice.DisplayIndex = 10;

                        grid.Columns.Add(productprice);

                        Number productQuantity = (Number) designerhost.CreateComponent(typeof (Number));
                        productQuantity.ColumnId = "Quantity";
                        productQuantity.Title = "Quantity";
                        productQuantity.Grid = grid;
                        productQuantity.Visibility = Visibility.Both;
                        productQuantity.DisplayIndex = 20;

                        grid.Columns.Add(productQuantity);

                        Decimal productSubSum = (Decimal) designerhost.CreateComponent(typeof (Decimal));
                        productSubSum.ColumnId = "Total";
                        productSubSum.Title = "Sub total";
                        productSubSum.Grid = grid;
                        productSubSum.Visibility = Visibility.Grid;
                        productSubSum.DisplayIndex = 30;
                        productSubSum.DisplayTotalSummary = true;
                        productSubSum.Sum = "[Quantity]*[Price]";
                        grid.Columns.Add(productSubSum);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
                case GridTemplate.DocumentDatabase:
                    {
                        grid.Width = Unit.Percentage(100);
                        grid.Title = "Document database";
                        grid.DefaultVisibility = Visibility.None;
                        grid.RecordsPerRow = 1;
                        grid.DisplayView = DisplayView.Grid;

                        grid.Columns.Clear();

                        Text documenttitle = (Text) designerhost.CreateComponent(typeof (Text));
                        documenttitle.ColumnId = "TitleDocument";
                        documenttitle.Title = "Title";
                        documenttitle.Grid = grid;
                        documenttitle.Visibility = Visibility.Both;
                        documenttitle.DisplayIndex = 10;
                        documenttitle.Required = true;

                        grid.Columns.Add(documenttitle);

                        Text htmldocument = (Text) designerhost.CreateComponent(typeof (Text));
                        htmldocument.ColumnId = "htmlDocument";
                        htmldocument.Title = "Document";
                        htmldocument.Grid = grid;
                        htmldocument.IsHtml = true;
                        htmldocument.WidthEditableColumn = Unit.Percentage(90);
                        htmldocument.HeightEditableColumn = Unit.Pixel(300);
                        htmldocument.Visibility = Visibility.Detail;
                        htmldocument.DisplayIndex = 20;
                        htmldocument.Required = true;

                        grid.Columns.Add(htmldocument);

                        File fileattachment = (File) designerhost.CreateComponent(typeof (File));
                        fileattachment.ColumnId = "FileAttachment";
                        fileattachment.Title = "File Attachment";
                        fileattachment.Grid = grid;
                        fileattachment.Visibility = Visibility.Both;
                        fileattachment.DisplayIndex = 30;
                        fileattachment.Required = false;

                        grid.Columns.Add(fileattachment);

                        WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
                        return;
                    }
            }
        }
 private object Transaction_AddTab(IDesignerHost host, object parameter)
 {
     // Tab Page
     NeoTabPage tabPage = (NeoTabPage)host.CreateComponent(typeof(NeoTabPage));
     tabPage.BackColor = System.Drawing.Color.Transparent;
     // Tab Control
     NeoTabWindow tabControl = (NeoTabWindow)parameter;
     MemberDescriptor md = TypeDescriptor.GetProperties(tabControl)["Controls"];
     RaiseComponentChanging(md);
     tabControl.Controls.Add(tabPage);
     RaiseComponentChanged(md, null, null);
     return parameter;
 }
 protected override IComponent[] CreateComponentsCore(IDesignerHost host)
 {
     IComponent[] sourceArray = base.CreateComponentsCore(host);
     Control component = null;
     ControlDesigner parent = null;
     TabStrip strip = null;
     IComponentChangeService service = (IComponentChangeService) host.GetService(typeof(IComponentChangeService));
     if ((sourceArray.Length > 0) && (sourceArray[0] is TabStrip))
     {
         strip = sourceArray[0] as TabStrip;
         ITreeDesigner designer2 = host.GetDesigner(strip) as ITreeDesigner;
         parent = designer2.Parent as ControlDesigner;
         if (parent != null)
         {
             component = parent.Control;
         }
     }
     if (host != null)
     {
         TabPageSwitcher switcher = null;
         DesignerTransaction transaction = null;
         try
         {
             try
             {
                 transaction = host.CreateTransaction("add tabswitcher");
             }
             catch (CheckoutException exception)
             {
                 if (exception != CheckoutException.Canceled)
                 {
                     throw exception;
                 }
                 return sourceArray;
             }
             MemberDescriptor member = TypeDescriptor.GetProperties(parent)["Controls"];
             switcher = host.CreateComponent(typeof(TabPageSwitcher)) as TabPageSwitcher;
             if (service != null)
             {
                 service.OnComponentChanging(component, member);
                 service.OnComponentChanged(component, member, null, null);
             }
             Dictionary<string, object> properties = new Dictionary<string, object>();
             properties["Location"] = new Point(strip.Left, strip.Bottom + 3);
             properties["TabStrip"] = strip;
             this.SetProperties(switcher, properties, host);
         }
         finally
         {
             if (transaction != null)
             {
                 transaction.Commit();
             }
         }
         if (switcher != null)
         {
             IComponent[] destinationArray = new IComponent[sourceArray.Length + 1];
             Array.Copy(sourceArray, destinationArray, sourceArray.Length);
             destinationArray[destinationArray.Length - 1] = switcher;
             return destinationArray;
         }
     }
     return sourceArray;
 }
Esempio n. 14
0
 /// <include file='doc\ToolboxItem.uex' path='docs/doc[@for="ToolboxItem.CreateComponentsCore"]/*' />
 /// <devdoc>
 ///     Creates objects from the type contained in this toolbox item.  If designerHost is non-null
 ///     this will also add them to the designer.
 /// </devdoc>
 protected virtual IComponent[] CreateComponentsCore(IDesignerHost host) {
     ArrayList comps = new ArrayList();
     
     Type createType = GetType(host, AssemblyName, TypeName, true);
     if (createType != null) {
         if (host != null) {
             comps.Add(host.CreateComponent(createType));
         }
         else if (typeof(IComponent).IsAssignableFrom(createType)) {
             comps.Add(TypeDescriptor.CreateInstance(null, createType, null, null));
         }
     }
     
     IComponent[] temp = new IComponent[comps.Count];
     comps.CopyTo(temp, 0);
     return temp;
 }
Esempio n. 15
0
        internal static WizardPage CreateWelcomePage(Wizard parent, IDesignerHost dh, IComponentChangeService cc, ISelectionService ss, eWizardStyle style)
        {
            DesignerTransaction dt = dh.CreateTransaction();
            WizardPage page = null;
            try
            {
                page = dh.CreateComponent(typeof(WizardPage)) as WizardPage;

                if(style == eWizardStyle.Default)
                    ApplyDefaultWelcomePageStyle(page, null, null);
                else
                    ApplyOffice2007WelcomePageStyle(page, null, null);
                //TypeDescriptor.GetProperties(page)["InteriorPage"].SetValue(page, false);
                //TypeDescriptor.GetProperties(page)["BackColor"].SetValue(page, Color.White);
                //TypeDescriptor.GetProperties(page)["CanvasColor"].SetValue(page, Color.White);
                //TypeDescriptor.GetProperties(page.Style)["BackColor"].SetValue(page.Style, Color.White);
                //TypeDescriptor.GetProperties(page.Style)["BackgroundImage"].SetValue(page.Style, GetWelcomeImage(false));
                //TypeDescriptor.GetProperties(page.Style)["BackgroundImagePosition"].SetValue(page.Style, eStyleBackgroundImage.TopLeft);
                page.Size = new Size(534, 289);

                // Load labels onto the page, first Welcome to the Wizard...
                System.Windows.Forms.Label label = dh.CreateComponent(typeof(System.Windows.Forms.Label)) as System.Windows.Forms.Label;
                page.Controls.Add(label);
                label.Location = new Point(210, 18);
                label.Text = "Welcome to the <Wizard Name> Wizard";
                label.BackColor = Color.Transparent;
                try
                {
                    label.Font = new Font("Tahoma", 16);
                    TypeDescriptor.GetProperties(label)["AutoSize"].SetValue(label, false);
                }
                catch { }
                label.Size = new Size(310, 66);
                label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;

                // Wizard description label...
                label = dh.CreateComponent(typeof(System.Windows.Forms.Label)) as System.Windows.Forms.Label;
                page.Controls.Add(label);
                label.Location = new Point(210, 100);
                label.Text = "This wizard will guide you through the <Enter Process Name>.\r\n\r\n<Enter brief description of the process wizard is covering.>";
                label.BackColor = Color.Transparent;
                try
                {
                    TypeDescriptor.GetProperties(label)["AutoSize"].SetValue(label, false);
                }
                catch { }
                label.Size = new Size(309, 157);
                label.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;

                // Click Next to Continue label...
                label = dh.CreateComponent(typeof(System.Windows.Forms.Label)) as System.Windows.Forms.Label;
                page.Controls.Add(label);
                label.Location = new Point(210, 266);
                label.Text = "To continue, click Next.";
                label.Size = new Size(120, 13);
                label.Anchor = AnchorStyles.Left | AnchorStyles.Bottom;
                label.BackColor = Color.Transparent;
                
                if (cc != null)
                    cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["WizardPages"]);
                parent.WizardPages.Add(page);
                if (cc != null)
                    cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["WizardPages"], null, null);


                if (ss != null)
                    ss.SetSelectedComponents(new WizardPage[] { page }, SelectionTypes.Replace);

                TypeDescriptor.GetProperties(parent)["SelectedPageIndex"].SetValue(parent, parent.WizardPages.IndexOf(page));
            }
            catch
            {
                dt.Cancel();
            }
            finally
            {
                if (!dt.Canceled)
                    dt.Commit();
            }

            return page;
        }
Esempio n. 16
0
        internal static WizardPage CreatePage(Wizard parent, bool innerPage, IDesignerHost dh, IComponentChangeService cc, ISelectionService ss, eWizardStyle wizardStyle)
        {
            DesignerTransaction dt = dh.CreateTransaction();
            WizardPage page=null;
            try
            {
                page = dh.CreateComponent(typeof(WizardPage)) as WizardPage;
				
				page.AntiAlias=false;
                page.InteriorPage = innerPage;
                if (innerPage)
                {
                    page.PageTitle = "< Wizard step title >";
                    page.PageDescription = "< Wizard step description >";
                }
                if (wizardStyle == eWizardStyle.Default)
                    ApplyDefaultInnerPageStyle(page, dh, cc);
                else if (wizardStyle == eWizardStyle.Office2007)
                    ApplyOffice2007InnerPageStyle(page, dh, cc);
                //else
                //{
                //    TypeDescriptor.GetProperties(page.Style)["BackColor"].SetValue(page.Style, Color.White);
                //}

                if (cc != null)
                    cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["WizardPages"]);
                parent.WizardPages.Add(page);
                if (cc != null)
                    cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["WizardPages"], null, null);

                if (ss != null)
                    ss.SetSelectedComponents(new WizardPage[] { page }, SelectionTypes.Replace);

                TypeDescriptor.GetProperties(parent)["SelectedPageIndex"].SetValue(parent, parent.WizardPages.IndexOf(page));
            }
            catch
            {
                dt.Cancel();
            }
            finally
            {
                if (!dt.Canceled)
                    dt.Commit();
            }

            return page;
        }
Esempio n. 17
0
        private ButtonItem CreateMRUButton(IDesignerHost dh, string text)
        {
            ButtonItem button = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
            button.Text = text;

            return button;
        }
Esempio n. 18
0
        private ButtonItem CreateFileButton(IDesignerHost dh, string text, Image image)
        {
            ButtonItem button = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
            button.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.ImageAndText;
            button.Image = image;
            button.SubItemsExpandWidth = 24;
            button.Text = text;

            return button;
        }
Esempio n. 19
0
        internal static PageSliderPage CreatePage(PageSlider parent, IDesignerHost dh, IComponentChangeService cc, ISelectionService ss)
        {
            DesignerTransaction dt = dh.CreateTransaction();
            PageSliderPage page = null;
            try
            {
                page = dh.CreateComponent(typeof(PageSliderPage)) as PageSliderPage;

                if (cc != null)
                    cc.OnComponentChanging(parent, TypeDescriptor.GetProperties(parent)["Controls"]);
                parent.Controls.Add(page);
                if (cc != null)
                    cc.OnComponentChanged(parent, TypeDescriptor.GetProperties(parent)["Controls"], null, null);

                if (ss != null)
                    ss.SetSelectedComponents(new PageSliderPage[] { page }, SelectionTypes.Replace);

                TypeDescriptor.GetProperties(parent)["SelectedPage"].SetValue(parent, page);
            }
            catch
            {
                dt.Cancel();
            }
            finally
            {
                if (!dt.Canceled)
                    dt.Commit();
            }

            return page;
        }
Esempio n. 20
0
        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 IComponent[] CreateComponentsCore(IDesignerHost host)
 {
     IComponent[] componentArray = null;
     object references = this.GetReferences(host);
     if (references != null)
     {
         try
         {
             System.Runtime.InteropServices.ComTypes.TYPELIBATTR typeLibAttr = this.GetTypeLibAttr();
             object[] args = new object[] { "{" + typeLibAttr.guid.ToString() + "}", (int) typeLibAttr.wMajorVerNum, (int) typeLibAttr.wMinorVerNum, typeLibAttr.lcid, "" };
             references.GetType().InvokeMember("AddActiveX", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, references, args, CultureInfo.InvariantCulture);
             args[4] = "aximp";
             object reference = references.GetType().InvokeMember("AddActiveX", BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Instance, null, references, args, CultureInfo.InvariantCulture);
             this.axctlType = this.GetAxTypeFromReference(reference, host);
         }
         catch (TargetInvocationException exception)
         {
             throw exception.InnerException;
         }
         catch (Exception exception2)
         {
             throw exception2;
         }
     }
     if (this.axctlType == null)
     {
         IUIService service = (IUIService) host.GetService(typeof(IUIService));
         if (service == null)
         {
             System.Windows.Forms.Design.RTLAwareMessageBox.Show(null, System.Design.SR.GetString("AxImportFailed"), null, MessageBoxButtons.OK, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1, 0);
         }
         else
         {
             service.ShowError(System.Design.SR.GetString("AxImportFailed"));
         }
         return new IComponent[0];
     }
     componentArray = new IComponent[1];
     try
     {
         componentArray[0] = host.CreateComponent(this.axctlType);
     }
     catch (Exception exception3)
     {
         throw exception3;
     }
     return componentArray;
 }
Esempio n. 22
0
        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 };
        }
Esempio n. 23
0
        public Control CreateControl(Type controlType, Size controlSize, Point controlLocation)
        {
            try
            {
                //- step.1
                //- get the IDesignerHost
                //- if we are not able to get it
                //- then rollback (return without do nothing)
                IDesignerHost host = DesignerHost;
                if (null == host)
                {
                    return(null);
                }
                //- check if the root component has already been set
                //- if not so then rollback (return without do nothing)
                if (null == host.RootComponent)
                {
                    return(null);
                }
                //-
                //-
                //- step.2
                //- create a new component and initialize it via its designer
                //- if the component has not a designer
                //- then rollback (return without do nothing)
                //- else do the initialization
                IComponent newComp = host.CreateComponent(controlType);
                if (null == newComp)
                {
                    return(null);
                }
                IDesigner designer = host.GetDesigner(newComp);
                if (null == designer)
                {
                    return(null);
                }
                if (designer is IComponentInitializer)
                {
                    ((IComponentInitializer)designer).InitializeNewComponent(null);
                }
                //-
                //-
                //- step.3
                //- try to modify the Size/Location of the object just created
                PropertyDescriptorCollection pdc = TypeDescriptor.GetProperties(newComp);
                //- Sets a PropertyDescriptor to the specific property.
                PropertyDescriptor pdS = pdc.Find("Size", false);
                if (null != pdS)
                {
                    pdS.SetValue(newComp, controlSize);
                }
                PropertyDescriptor pdL = pdc.Find("Location", false);
                if (null != pdL)
                {
                    pdL.SetValue(newComp, controlLocation);
                }
                //-
                //-
                //- step.4
                //- commit the Creation Operation
                //- adding the control to the DesignSurface's root component
                //- and return the control just created to let further initializations
                ((Control)newComp).Parent = host.RootComponent as Control;
                return(newComp as Control);
            }//end_try
            catch (Exception exx)
            {
                Debug.WriteLine(exx.Message);
                if (null != exx.InnerException)
                {
                    Debug.WriteLine(exx.InnerException.Message);
                }

                throw;
            }//end_catch
        }
Esempio n. 24
0
        protected override IComponent[] CreateComponentsCore(IDesignerHost host)
        {
            IComponent[] components = base.CreateComponentsCore(host);

            Control parentControl = null;
            ControlDesigner parentControlDesigner = null;
            TabStrip tabStrip = null;
            IComponentChangeService changeSvc = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));

            // fish out the parent we're adding the TabStrip to.
            if (components.Length > 0 && components[0] is TabStrip) {
                tabStrip = components[0] as TabStrip;

                ITreeDesigner tabStripDesigner = host.GetDesigner(tabStrip) as ITreeDesigner;
                parentControlDesigner = tabStripDesigner.Parent as ControlDesigner;
                if (parentControlDesigner != null) {
                    parentControl = parentControlDesigner.Control;
                }
            }

            // Create a ControlSwitcher on the same parent.

            if (host != null) {
                TabPageSwitcher controlSwitcher = null;

                DesignerTransaction t = null;
                try {
                    try {
                        t = host.CreateTransaction("add tabswitcher");
                    }
                    catch (CheckoutException ex) {
                        if (ex == CheckoutException.Canceled) {
                            return components;
                        }
                        throw ex;
                    }
                    MemberDescriptor controlsMember = TypeDescriptor.GetProperties(parentControlDesigner)["Controls"];
                    controlSwitcher = host.CreateComponent(typeof(TabPageSwitcher)) as TabPageSwitcher;

                    if (changeSvc != null) {
                        changeSvc.OnComponentChanging(parentControl, controlsMember);
                        changeSvc.OnComponentChanged(parentControl, controlsMember, null, null);
                    }

                    Dictionary<string, object> propertyValues = new Dictionary<string, object>();
                    propertyValues["Location"] = new Point(tabStrip.Left, tabStrip.Bottom + 3);
                    propertyValues["TabStrip"] = tabStrip;

                    SetProperties(controlSwitcher, propertyValues, host);

                }
                finally {
                    if (t != null)
                        t.Commit();
                }

                if (controlSwitcher != null) {
                    IComponent[] newComponents = new IComponent[components.Length + 1];
                    Array.Copy(components, newComponents, components.Length);
                    newComponents[newComponents.Length - 1] = controlSwitcher;
                    return newComponents;
                }

            }

            return components;
        }
        private LabeledDataControl AddDataControl(IDesignerHost h, GridColumnInfo info)
        {
            //IDataControl dc = ControlFactory.GetDataControl(columnInfo);
            //Control control = dc as Control;
            //if (control == null)
            //{
            //    throw new ArgumentException("IDataControl should be System.Windows.Forms.Control!");
            //}
            //m_parentForm.Controls.Add(control);

            Control ic = null;
            foreach (string s in ControlsName.DataControlsTypeName)
            {
                if (s.LastIndexOf(info.DataControlType, StringComparison.OrdinalIgnoreCase) != -1)
                {
                    ic = (Control)h.CreateComponent(Feng.Utils.ReflectionHelper.GetTypeFromName(s));
                    break;
                }
            }

            if (ic == null)
            {
                throw new InvalidOperationException("Invalid ControlType of " + info.DataControlType);
            }
            LabeledDataControl control = (LabeledDataControl)h.CreateComponent(typeof(LabeledDataControl));

            MyLabel lbl = (MyLabel)h.CreateComponent(typeof(MyLabel));
            lbl.Text = info.Caption;

            control.Controls.Add(lbl);
            control.Controls.Add(ic);
            control.Label = lbl;
            control.Control = ic;

            IDataControl dc = control as IDataControl;
            dc.Caption = info.Caption;
            dc.PropertyName = info.PropertyName;
            dc.Navigator = info.Navigator;
            //dc.Index = info.SeqNo;
            dc.Name = info.GridColumnName;

            control.ResetLayout();

            m_parentForm.Controls.Add(control);

            return control;
        }
Esempio n. 26
0
        internal static void AddGridColumn(ref Grid grid, ref IDesignerHost designerhost,
            ref IComponentChangeService componentChangeService,
            ref DesignerTransaction dt, ColumnTemplates template)
        {
            if (template == ColumnTemplates.None)
                return;
            dt = designerhost.CreateTransaction(string.Format("Configure WebGrid as {0}", template));

            switch (template)
            {
                case ColumnTemplates.SelectRowColumn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "SelectColumn";
                        systemcolumn.Grid = grid;
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.SelectColumn;
                        systemcolumn.DisplayIndex = 5;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.EditRowColumn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "EditColumn";
                        systemcolumn.Grid = grid;
                        systemcolumn.Html = "Edit row";
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.EditColumn;
                        systemcolumn.DisplayIndex = 7;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.CopyRowColumnn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "CopyColumn";
                        systemcolumn.Grid = grid;
                        systemcolumn.Html = "Copy row";
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.CopyColumn;
                        systemcolumn.DisplayIndex = 2;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.UpdateGridRecordColumn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "UpdateRecord";
                        systemcolumn.Grid = grid;
                        systemcolumn.Html = "Update record";
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.UpdateGridRecordColumn;
                        systemcolumn.DisplayIndex = 9;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.UpdateGridRecordsColumn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "UpdateRecords";
                        systemcolumn.Grid = grid;
                        systemcolumn.Html = "Update all";
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.UpdateGridRecordsColumn;
                        systemcolumn.DisplayIndex = 9;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.DeleteRowColumn:
                    {
                        SystemColumn systemcolumn = (SystemColumn) designerhost.CreateComponent(typeof (SystemColumn));
                        systemcolumn.ColumnId = "DeleteRow";
                        systemcolumn.Html = "Delete row";
                        systemcolumn.Grid = grid;
                        systemcolumn.Title = string.Empty;
                        systemcolumn.Visibility = Visibility.Grid;
                        systemcolumn.SystemColumnType = Enums.SystemColumn.DeleteColumn;
                        grid.Columns.Add(systemcolumn);
                    }
                    break;
                case ColumnTemplates.HtmlEditorColumn:
                    {
                        Text htmlColumn = (Text) designerhost.CreateComponent(typeof (Text));
                        htmlColumn.ColumnId = "HtmlColumn";
                        htmlColumn.Title = "Html column";
                        htmlColumn.Grid = grid;
                        htmlColumn.IsHtml = true;
                        htmlColumn.WidthEditableColumn = Unit.Percentage(90);
                        htmlColumn.HeightEditableColumn = Unit.Pixel(300);
                        htmlColumn.Visibility = Visibility.Detail;
                        htmlColumn.Required = true;
                        grid.Columns.Add(htmlColumn);
                    }
                    break;
                case ColumnTemplates.EmailValidColumn:
                    {
                        Text emailcolumn = (Text) designerhost.CreateComponent(typeof (Text));
                        emailcolumn.ColumnId = "Emailcolumn";
                        emailcolumn.Title = "E-mail address";
                        emailcolumn.Grid = grid;
                        emailcolumn.Visibility = Visibility.Both;
                        emailcolumn.DisplayIndex = grid.Columns.Count*10;
                        emailcolumn.Required = true;
                        grid.Columns.Add(emailcolumn);
                    }
                    break;
            }
             WebGridDesignTime.SaveGridState(dt, grid, componentChangeService);
        }
Esempio n. 27
0
        public void mnuAddBand(object sender, EventArgs e)
        {
            RebarBand band = (RebarBand)_host.CreateComponent(typeof(RebarBand));

            _rebar.Bands.Add(band);
        }
Esempio n. 28
0
        /// <summary>
        /// Create new instance of specified type within the designer host, if provided.
        /// </summary>
        /// <param name="itemType">Type of the item to create.</param>
        /// <param name="host">Designer host used if provided.</param>
        /// <returns>Reference to new instance.</returns>
        public static object CreateInstance(Type itemType, IDesignerHost host)
        {
            object retObj = null;

            // Cannot use the designer host to create component unless the type implements IComponent
            if (typeof(IComponent).IsAssignableFrom(itemType) && (host != null))
            {
                // Ask host to create component for us
                retObj = host.CreateComponent(itemType, null);

                // If the new object has an associated designer then use that now to initialize the instance
                IComponentInitializer designer = host.GetDesigner((IComponent)retObj) as IComponentInitializer;
                if (designer != null)
                    designer.InitializeNewComponent(null);
            }
            else
            {
                // Cannot use host for creation, so do it the standard way instead
                retObj = TypeDescriptor.CreateInstance(host, itemType, null, null);
            }

            return retObj;
        }
        private void CreateDocumentDockPanel(object sender, EventArgs e)
        {
            IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost;

            //
            if (host == null)
            {
                return;
            }
            //
            if (this.m_DockPanelManager.DocumentArea == null)
            {
                DocumentDockArea documentAreaPanel = host.CreateComponent(typeof(DocumentDockArea)) as DocumentDockArea;
                if (documentAreaPanel == null)
                {
                    return;
                }
                documentAreaPanel.Dock = DockStyle.Fill;
                documentAreaPanel.Text = documentAreaPanel.Name;
                this.m_DockPanelManager.DocumentArea = documentAreaPanel;
                this.m_DockPanelManager.ParentForm.Controls.Add(documentAreaPanel);
                if (this.m_DockPanelManager.ParentForm.Controls.Count > 1)
                {
                    this.m_DockPanelManager.ParentForm.Controls.SetChildIndex(documentAreaPanel, 0);
                }
                //
                BasePanel basePanel = host.CreateComponent(typeof(BasePanel)) as BasePanel;
                DockPanel dockPanel = host.CreateComponent(typeof(DockPanel)) as DockPanel;
                if (basePanel == null || dockPanel == null)
                {
                    return;
                }
                basePanel.Dock = DockStyle.Fill;
                basePanel.Text = basePanel.Name;
                dockPanel.BasePanels.Add(basePanel);
                dockPanel.Dock = DockStyle.Fill;
                this.m_DockPanelManager.DocumentArea.Controls.Add(dockPanel);
                this.m_DockPanelManager.BasePanels.Add(basePanel);
                this.m_DockPanelManager.DockPanels.Add(dockPanel);
            }
            else if (this.m_DockPanelManager.DocumentArea is DocumentDockArea)
            {
                DockPanel dockPanel = ((DocumentDockArea)this.m_DockPanelManager.DocumentArea).GetDockPanel();
                if (dockPanel != null)
                {
                    BasePanel basePanel = host.CreateComponent(typeof(BasePanel)) as BasePanel;
                    if (basePanel == null)
                    {
                        return;
                    }
                    basePanel.Dock = DockStyle.Fill;
                    basePanel.Text = basePanel.Name;
                    dockPanel.BasePanels.Add(basePanel);
                    this.m_DockPanelManager.BasePanels.Add(basePanel);
                }
                else
                {
                    BasePanel basePanel = host.CreateComponent(typeof(BasePanel)) as BasePanel;
                    dockPanel = host.CreateComponent(typeof(DockPanel)) as DockPanel;
                    if (basePanel == null || dockPanel == null)
                    {
                        return;
                    }
                    basePanel.Dock = DockStyle.Fill;
                    basePanel.Text = basePanel.Name;
                    dockPanel.BasePanels.Add(basePanel);
                    dockPanel.Dock = DockStyle.Fill;
                    this.m_DockPanelManager.DocumentArea.Controls.Add(dockPanel);
                    this.m_DockPanelManager.BasePanels.Add(basePanel);
                    this.m_DockPanelManager.DockPanels.Add(dockPanel);
                }
            }
        }
 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;
 }
Esempio n. 31
0
        public static void GenDataSet(Project GlobalProject, ClientParam cParam, WinClientParam winParam, IDesignerHost FDesignerHost)
        {
            InfoDataSet FDataSet = FDesignerHost.CreateComponent(typeof(InfoDataSet), "id" + cParam.TableName) as InfoDataSet;
            FDataSet.RemoteName = cParam.ProviderName;
            FDataSet.Active = true;
            FDataSet.AlwaysClose = true;

            InfoBindingSource MainBindingSource = FDesignerHost.CreateComponent(typeof(InfoBindingSource), "ibs" + cParam.TableName) as InfoBindingSource;
            MainBindingSource.DataSource = FDataSet;
            MainBindingSource.DataMember = FDataSet.RealDataSet.Tables[0].TableName;

            WinCreateXSD(GlobalProject, FDataSet, cParam, winParam);
        }