コード例 #1
0
	protected virtual IComponent[] CreateToolCore(ToolboxItem tool, 
					int x, int y, int width, int height,
					bool hasLocation, bool hasSize)
			{
				// TODO
				return null;
			}
 protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize)
 {
     if (tool != null)
     {
         System.Type c = tool.GetType(this.designerHost);
         if (!typeof(ToolStrip).IsAssignableFrom(c))
         {
             ToolStripContainer parent = this.panel.Parent as ToolStripContainer;
             if (parent != null)
             {
                 ToolStripContentPanel contentPanel = parent.ContentPanel;
                 if (contentPanel != null)
                 {
                     PanelDesigner toInvoke = this.designerHost.GetDesigner(contentPanel) as PanelDesigner;
                     if (toInvoke != null)
                     {
                         ParentControlDesigner.InvokeCreateTool(toInvoke, tool);
                     }
                 }
             }
         }
         else
         {
             base.CreateToolCore(tool, x, y, width, height, hasLocation, hasSize);
         }
     }
     return null;
 }
コード例 #3
0
            } // OnPaint

            public void InvokeToolboxItem(System.Drawing.Design.ToolboxItem tool)
            {
                IComponent[] newComponents = tool.CreateComponents(DesignerHost);
                _displayString = "Last Component added: " + newComponents[0].GetType().ToString();
                UpdateTable(newComponents[0].GetType());
                Invalidate();
            }
コード例 #4
0
ファイル: Toolbox.cs プロジェクト: zpzgone/Sheng.Winform.IDE
        public void ToolBoxItemButtonKeyDown(System.Windows.Forms.KeyEventArgs e, System.Drawing.Design.ToolboxItem toolboxItem)
        {
            if (toolboxItem == null)
            {
                return;
            }


            switch (e.KeyCode)
            {
            case Keys.Enter:
                if (DesignerHost == null)
                {
                    MessageBox.Show("idh Null");
                }

                IToolboxUser tbu = DesignerHost.GetDesigner(DesignerHost.RootComponent as IComponent) as IToolboxUser;

                if (tbu != null)
                {
                    // Enter means place the tool with default location and default size.
                    tbu.ToolPicked(toolboxItem);
                }
                break;

            default:
            {
                Console.WriteLine("Error: Not able to add");
                break;
            }
            }
        }
コード例 #5
0
ファイル: ModToolBox.cs プロジェクト: war-and-code/IronWASP
        private void ToolsListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e)
        {
            try
            {
                ListBox lbSender = sender as ListBox;
                if (lbSender == null)
                {
                    return;
                }

                // If this tool is the currently selected tool, draw it with a highlight.
                if (SelectedIndex == e.Index)
                {
                    e.Graphics.FillRectangle(Brushes.LightSlateGray, e.Bounds);
                }

                System.Drawing.Design.ToolboxItem tbi = lbSender.Items[e.Index] as System.Drawing.Design.ToolboxItem;
                Rectangle BitmapBounds = new Rectangle(e.Bounds.Location.X, e.Bounds.Location.Y + e.Bounds.Height / 2 - tbi.Bitmap.Height / 2, tbi.Bitmap.Width, tbi.Bitmap.Height);
                Rectangle StringBounds = new Rectangle(e.Bounds.Location.X + BitmapBounds.Width + 5, e.Bounds.Location.Y, e.Bounds.Width - BitmapBounds.Width, e.Bounds.Height);

                StringFormat format = new StringFormat();

                format.LineAlignment = StringAlignment.Center;
                format.Alignment     = StringAlignment.Near;
                e.Graphics.DrawImage(tbi.Bitmap, BitmapBounds);
                e.Graphics.DrawString(tbi.DisplayName, new Font("Tahoma", 11, FontStyle.Regular, GraphicsUnit.World), Brushes.Black, StringBounds, format);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: SylvainDevidal/OSMaker
        //- ctor
        public MainForm()
        {
            InitializeComponent();

            //- Add the toolboxItems to the future toolbox
            //- the pointer
            ToolboxItem toolPointer = new System.Drawing.Design.ToolboxItem();

            toolPointer.DisplayName = "<Pointer>";
            toolPointer.Bitmap      = new System.Drawing.Bitmap(16, 16);
            listBox1.Items.Add(toolPointer);
            //- the control
            listBox1.Items.Add(new ToolboxItem(typeof(Button)));
            listBox1.Items.Add(new ToolboxItem(typeof(ListView)));
            listBox1.Items.Add(new ToolboxItem(typeof(TreeView)));
            listBox1.Items.Add(new ToolboxItem(typeof(TextBox)));
            listBox1.Items.Add(new ToolboxItem(typeof(Label)));
            listBox1.Items.Add(new ToolboxItem(typeof(TabControl)));
            listBox1.Items.Add(new ToolboxItem(typeof(OpenFileDialog)));
            listBox1.Items.Add(new ToolboxItem(typeof(CheckBox)));
            listBox1.Items.Add(new ToolboxItem(typeof(ComboBox)));
            listBox1.Items.Add(new ToolboxItem(typeof(GroupBox)));
            listBox1.Items.Add(new ToolboxItem(typeof(ImageList)));
            listBox1.Items.Add(new ToolboxItem(typeof(Panel)));
            listBox1.Items.Add(new ToolboxItem(typeof(ProgressBar)));
            listBox1.Items.Add(new ToolboxItem(typeof(ToolBar)));
            listBox1.Items.Add(new ToolboxItem(typeof(ToolTip)));
            listBox1.Items.Add(new ToolboxItem(typeof(StatusBar)));
        }
コード例 #7
0
 ///<summary>create a tabitem from a toolboxitem. It init Icon from the tag</summary>
 public SideTabItemDesigner(string name, ToolboxItem tag)
     : base(name, tag)
 {
     CanBeRenamed = false;
     this.Icon = tag.Bitmap;
     ReloadToolBox();
 }
コード例 #8
0
 private void SelectItemChangedFunction(System.Drawing.Design.ToolboxItem item)
 {
     if (SelectItemChanged != null)
     {
         SelectItemChanged(item);
     }
 }
コード例 #9
0
        public List<ToolboxItem> GetToolboxItemList()
        {
            List<dynamic> itemMetadataList = new List<dynamic>
            {
                new { DisplayName = "Place", Bitmap = Resources.Place, CommandName = "Place" },
                new { DisplayName = "Transition", Bitmap = Resources.Transition, CommandName = "Transition" },
                new { DisplayName = "AND-split", Bitmap = Resources.AndSplit, CommandName = "AndSplit" },
                new { DisplayName = "OR-split", Bitmap = Resources.OrSplit, CommandName = "OrSplit" },
                new { DisplayName = "AND-join", Bitmap = Resources.AndJoin, CommandName = "AndJoin" },
                new { DisplayName = "OR-join", Bitmap = Resources.OrJoin, CommandName = "OrJoin" },
                new { DisplayName = "Subprocess", Bitmap = Resources.Subprocess, CommandName = "Subprocess" },
            };

            List<ToolboxItem> result = new List<ToolboxItem>();
            foreach (dynamic metadata in itemMetadataList)
            {
                ToolboxItem toolboxItem = new ToolboxItem();
                toolboxItem.Properties.Add(
                    ItemCommandNameProperty,
                    new PetriNetEditorToolboxItemData
                    {
                        CommandName = metadata.CommandName
                    });

                toolboxItem.DisplayName = metadata.DisplayName;
                toolboxItem.Bitmap = metadata.Bitmap;

                result.Add(toolboxItem);
            }

            return result;
        }
コード例 #10
0
        public void RemoveToolboxItem(System.Drawing.Design.ToolboxItem item, string category)
        {
            ToolBoxGroupPanel group = null;

            if (category != null && group_panels.TryGetValue(category, out group))
            {
                int toRemove = -1;
                for (int i = 0; i < group.Items.Count; i++)
                {
                    ToolBoxListItem listItem = (ToolBoxListItem)group.Items[i];
                    if (listItem.ToolBoxItem == item)
                    {
                        listItem.Click -= new EventHandler(item_Click);
                        toRemove        = i;
                        break;
                    }
                }
                if (toRemove != -1)
                {
                    group.Items.RemoveAt(toRemove);
                }
                if (group.Items.Count == 0)
                {
                    Controls.Remove(group);
                }
            }
        }
コード例 #11
0
		private static SideTab CreateReportingSidetab ()
		{
			SideTab sideTab = new SideTab("ReportDesigner");
			sideTab.CanSaved = false;
			AddPointerToSideTab(sideTab);
			
			// TextItem
			ToolboxItem tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseTextItem));
			tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.TextBox");
			tb.Bitmap = WinFormsResourceService.GetIcon("Icons.16.16.SharpReport.Textbox").ToBitmap();
			sideTab.Items.Add(new SideTabItemDesigner(tb));	
			
			// Row
			tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseRowItem));
			tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.SharpQuery.Table");
			tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.DataRow");
			sideTab.Items.Add(new SideTabItemDesigner(tb));
			
			
			//BaseTable
			tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.SharpQuery.Table");
			tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseTableItem));
			tb.DisplayName ="Table";
			sideTab.Items.Add(new SideTabItemDesigner(tb));	
			
			
			
			tb.Bitmap = WinFormsResourceService.GetBitmap("Icons.16x16.SharpQuery.Table");
			//BaseDataItem
			tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseDataItem));
			tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.DataField");
			sideTab.Items.Add(new SideTabItemDesigner(tb));	
			
			//Grahics
			// Line
			tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseLineItem));
			tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Line");
			tb.Bitmap = WinFormsResourceService.GetIcon("Icons.16.16.SharpReport.Line").ToBitmap();
			sideTab.Items.Add(new SideTabItemDesigner(tb));
			
			// Rectangle
			tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseRectangleItem));
			tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Rectangle");
			tb.Bitmap = GlobalValues.RectangleBitmap();
			sideTab.Items.Add(new SideTabItemDesigner(tb));
			
			// Circle
			tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseCircleItem));
			tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Circle");
			tb.Bitmap = GlobalValues.CircleBitmap();
			sideTab.Items.Add(new SideTabItemDesigner(tb));
			
		
			// Image
			tb = new ToolboxItem(typeof(ICSharpCode.Reports.Addin.BaseImageItem));
			tb.DisplayName = ResourceService.GetString("SharpReport.Toolbar.Image");
			tb.Bitmap = WinFormsResourceService.GetIcon("Icons.16x16.ResourceEditor.bmp").ToBitmap();
			sideTab.Items.Add(new SideTabItemDesigner(tb));
			return sideTab;
		}
 private static ToolboxItem GetCachedToolboxItem(System.Type itemType)
 {
     ToolboxItem toolboxItem = null;
     if (CachedToolboxItems == null)
     {
         CachedToolboxItems = new Dictionary<System.Type, ToolboxItem>();
     }
     else if (CachedToolboxItems.ContainsKey(itemType))
     {
         return CachedToolboxItems[itemType];
     }
     if (toolboxItem == null)
     {
         toolboxItem = ToolboxService.GetToolboxItem(itemType);
         if (toolboxItem == null)
         {
             toolboxItem = new ToolboxItem(itemType);
         }
     }
     CachedToolboxItems[itemType] = toolboxItem;
     if ((CustomToolStripItemCount > 0) && ((CustomToolStripItemCount * 2) < CachedToolboxItems.Count))
     {
         CachedToolboxItems.Clear();
     }
     return toolboxItem;
 }
コード例 #13
0
        private void list_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            try
            {
                ListBox   lbSender           = sender as ListBox;
                Rectangle lastSelectedBounds = lbSender.GetItemRectangle(0);
                try
                {
                    lastSelectedBounds = lbSender.GetItemRectangle(selectedIndex);
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }

                selectedIndex          = lbSender.IndexFromPoint(e.X, e.Y);    // change our selection
                lbSender.SelectedIndex = selectedIndex;
                lbSender.Invalidate(lastSelectedBounds);                       // clear highlight from last selection
                lbSender.Invalidate(lbSender.GetItemRectangle(selectedIndex)); // highlight new one

                if (selectedIndex != 0)
                {
                    SelectItemChangedFunction((System.Drawing.Design.ToolboxItem)(lbSender.Items[selectedIndex]));

                    if (e.Clicks == 2)
                    {
                        CreateToolboxItemFunction();
                        IDesignerHost idh = (IDesignerHost)this.DesignerHost.GetService(typeof(IDesignerHost));
                        IToolboxUser  tbu = idh.GetDesigner(idh.RootComponent as IComponent) as IToolboxUser;

                        if (tbu != null)
                        {
                            tbu.ToolPicked((System.Drawing.Design.ToolboxItem)(lbSender.Items[selectedIndex]));
                        }
                    }
                    else if (e.Clicks < 2)
                    {
                        System.Drawing.Design.ToolboxItem tbi = lbSender.Items[selectedIndex] as System.Drawing.Design.ToolboxItem;
                        IToolboxService tbs = this;

                        // The IToolboxService serializes ToolboxItems by packaging them in DataObjects.
                        DataObject d = tbs.SerializeToolboxItem(tbi) as DataObject;

                        try
                        {
                            lbSender.DoDragDrop(d, DragDropEffects.Copy);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
コード例 #14
0
        public override void SetSelectedToolboxItem(ToolboxItem toolboxItem)
        {
            if (toolboxItem == null)
                base.SetSelectedToolboxItem(FindToolBoxItem(x => x.DisplayName == "Pointer"));
            else
                base.SetSelectedToolboxItem(toolboxItem);

        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         this.tbxItem = null;
     }
     base.Dispose(disposing);
 }
コード例 #16
0
ファイル: ToolboxService.cs プロジェクト: Kalnor/monodevelop
		public void AddToolboxItem (ToolboxItem toolboxItem, string category)
		{
			if (!categories.ContainsKey (category))
				categories[category] = new ArrayList ();
			
			System.Diagnostics.Trace.WriteLine ("Adding ToolboxItem: " + toolboxItem.DisplayName + ", " + category);
			((ArrayList) categories[category]).Add (toolboxItem);
		}
コード例 #17
0
		///<summary>create a tabitem from a toolboxitem. It init Icon and name from the tag</summary>
		public SideTabItemDesigner(ToolboxItem tag) : base(tag.DisplayName, tag)
		{
			if (tag == null) {
				throw new ArgumentNullException("tag");
			}
			CanBeRenamed = false;
			this.Icon = tag.Bitmap;
			ReloadToolBox();
		}
コード例 #18
0
            } // OnPaint

            public void InvokeToolboxItem(System.Drawing.Design.ToolboxItem tool)
            {
                IDesignerHost dh = DesignerHost;

                if (dh != null)
                {
                }
                Invalidate();
            }
コード例 #19
0
 public ToolboxPane()
 {
     this.InitializeComponent();
     this.pointer = new ToolboxItem();
     this.pointer.DisplayName = "<Zeiger>";
     this.pointer.Bitmap = new Bitmap(0x10, 0x10);
     this.FillToolbox();
     ListBox list = this.listWindowsForms;
 }
コード例 #20
0
ファイル: ToolCursor.cs プロジェクト: hksonngan/sharptracing
 /// <summary>
 /// Initializes a new instance of the <see cref="ToolCursor"/> class.
 /// </summary>
 /// <param name="item">A <see cref="ToolboxItem"/> object.</param>
 public ToolCursor(ToolboxItem item)
 {
     this._item = item;
     if (item.Bitmap != null) {
         using (Bitmap bitmap = this.CreateCursor(item.Bitmap)) {
             this._hIcon = bitmap.GetHicon();
             this._cursor = new Cursor(this._hIcon);
         }
     }
 }
 protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize)
 {
     if (this.Selected == null)
     {
         this.Selected = this.splitterPanel1;
     }
     SplitterPanelDesigner toInvoke = (SplitterPanelDesigner) this.designerHost.GetDesigner(this.Selected);
     ParentControlDesigner.InvokeCreateTool(toInvoke, tool);
     return null;
 }
        public object SerializeToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)  //根据toolboxItem创建对象,
        {
            DataObject dataObj = null;

            if (toolboxItem != null)
            {
                // package the item in a dataobject
                dataObj = new DataObject(toolboxItem);
            }
            return(dataObj);
        }
コード例 #23
0
ファイル: BasicToolBox.cs プロジェクト: 15831944/erp-1
        // We only implement what is really essential for ToolboxService

        public ToolboxItem GetSelectedToolboxItem(IDesignerHost host)
        {
            System.Drawing.Design.ToolboxItem tbi = (System.Drawing.Design.ToolboxItem) this.Items[selectedIndex];
            if (tbi.DisplayName != "<Pointer>")
            {
                return(tbi);
            }
            else
            {
                return(null);
            }
        }
コード例 #24
0
            }             // OnPaint

            public void InvokeToolboxItem(System.Drawing.Design.ToolboxItem tool)
            {
                IDesignerHost dh = DesignerHost;

                if (dh != null)
                {
                    VOB.InterfaceVOB vob = dh.GetService(typeof(VOB.InterfaceVOB)) as VOB.InterfaceVOB;
                    if (vob != null)
                    {
                        vob.SendNotice(VOB.enumVobNotice.NewObject, tool);
                    }
                }
                Invalidate();
            }
コード例 #25
0
        public void AddToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category)
        {
            ToolBoxListItem item = new ToolBoxListItem(toolboxItem);

            if (!group_panels.ContainsKey(category))
            {
                ToolBoxGroupPanel gp = new ToolBoxGroupPanel();
                gp.Text = category;
                Controls.Add(gp);
            }

            item.Click += new EventHandler(item_Click);
            group_panels[category].Items.Add(item);
        }
コード例 #26
0
 public void SetSelectedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
 {
     foreach (ToolBoxGroupPanel p in group_panels.Values)
     {
         foreach (ToolBoxListItem i in p.Items)
         {
             if (i.ToolBoxItem == toolboxItem)
             {
                 i.Selected = true;
                 break;
             }
         }
     }
 }
コード例 #27
0
        public ToolboxItemToolboxNode(ToolboxItem item)
        {
            this.item = item;
            base.Name = item.DisplayName;
            if (item.Bitmap != null)
                base.Icon = base.ImageToPixbuf (item.Bitmap);

            if (item.AssemblyName != null)
                foreach (System.ComponentModel.CategoryAttribute ca in
                    System.Reflection.Assembly.Load (item.AssemblyName)
                    .GetType (item.TypeName)
                    .GetCustomAttributes (typeof (System.ComponentModel.CategoryAttribute), true))
                    this.Category = ca.Category;
        }
コード例 #28
0
ファイル: ModToolBox.cs プロジェクト: war-and-code/IronWASP
        // We only implement what is really essential for ToolboxService

        public System.Drawing.Design.ToolboxItem GetSelectedToolboxItem(IDesignerHost host)
        {
            ListBox List = this.ToolsListBox;

            System.Drawing.Design.ToolboxItem TBI = (System.Drawing.Design.ToolboxItem)List.Items[SelectedIndex];
            if (TBI.DisplayName != "Select from below:")
            {
                return(TBI);
            }
            else
            {
                return(null);
            }
        }
コード例 #29
0
		///<summary>Load an assembly's controls</summary>
		public SideTabDesigner(SideBarControl sideBar, Category category, IToolboxService toolboxService) : this(sideBar, category.Name, toolboxService)
		{
			foreach (ToolComponent component in category.ToolComponents) {
				if (component.IsEnabled) {
					ToolboxItem toolboxItem = new ToolboxItem();
					toolboxItem.TypeName    = component.FullName;
					toolboxItem.Bitmap      = ToolboxProvider.ComponentLibraryLoader.GetIcon(component);
					toolboxItem.DisplayName = component.Name;
					Assembly asm = component.LoadAssembly();
					toolboxItem.AssemblyName = asm.GetName();
					
					this.Items.Add(new SideTabItemDesigner(toolboxItem));
				}
			}
		}
 protected override IComponent[] CreateToolCore(ToolboxItem tool, int x, int y, int width, int height, bool hasLocation, bool hasSize)
 {
     TabControl control = (TabControl) this.Control;
     if (control.SelectedTab == null)
     {
         throw new ArgumentException(System.Design.SR.GetString("TabControlInvalidTabPageType", new object[] { tool.DisplayName }));
     }
     IDesignerHost service = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     if (service != null)
     {
         TabPageDesigner toInvoke = (TabPageDesigner) service.GetDesigner(control.SelectedTab);
         ParentControlDesigner.InvokeCreateTool(toInvoke, tool);
     }
     return null;
 }
コード例 #31
0
        public ToolBoxListItem(ToolboxItem toolBoxItem)
        {
            Size = new Size (150, 20);

            SetStyle (ControlStyles.ResizeRedraw, true);

            Text = toolBoxItem.DisplayName;

            if (toolBoxItem.Bitmap != null)
                image = toolBoxItem.Bitmap;
            else
                image = SystemIcons.Exclamation.ToBitmap ();

            tool_box_item = toolBoxItem;
        }
コード例 #32
0
ファイル: BasicToolBox.cs プロジェクト: 15831944/erp-1
        private void populateItems()
        {
            ToolboxItem pointer = new System.Drawing.Design.ToolboxItem();

            pointer.DisplayName = "<Pointer>";
            pointer.Bitmap      = new System.Drawing.Bitmap(16, 16);
            this.Items.Add(pointer);

            AddToolBox(typeof(myControl.cbControl), typeof(ComboBox), "下拉列表");
            AddToolBox(typeof(myControl.ckControl), typeof(CheckBox), "复选框");
            AddToolBox(typeof(myControl.DateControl), typeof(DateTimePicker), "日期");
            AddToolBox(typeof(myControl.EditControl), typeof(TextBox), "文本框");
            AddToolBox(typeof(myControl.lupControl), typeof(ComboBox), "下拉查询");
            AddToolBox(typeof(myControl.SpinControl), typeof(MaskedTextBox), "数值编辑框");
        }
コード例 #33
0
        void navBarControl_LinkPressed(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            SelectedToolboxItem = (System.Drawing.Design.ToolboxItem)e.Link.Item.Tag;

            IToolboxService tbs = this;
            DataObject      d   = tbs.SerializeToolboxItem(SelectedToolboxItem) as DataObject;

            try
            {
                this.DoDragDrop(d, DragDropEffects.Copy);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            SelectedToolboxItem = null;
        }
コード例 #34
0
ファイル: MainWindow.xaml.cs プロジェクト: barbarossia/CWF
        /// <summary>
        /// Find the activity, if any, associated with ToolboxItem
        /// </summary>
        private static ActivityItem LookupToolboxItem(ToolboxItem itemToFind, IEnumerable<ActivityAssemblyItem> activityAssemblyItems)
        {
            if (itemToFind == null)
            {
                return null;
            }

            ActivityAssemblyItem hostActivityAssemblyItem =
                activityAssemblyItems.FirstOrDefault(
                    aai => aai.Matches(itemToFind.AssemblyName));

            if (hostActivityAssemblyItem != null)
            {
                return hostActivityAssemblyItem.ActivityItems.FirstOrDefault(ai => ai.FullName == itemToFind.TypeName);
            }
            return null;
        }
コード例 #35
0
ファイル: EditorHost.cs プロジェクト: dodev/AspNetEdit
        private void handleToolboxNode(ItemToolboxNode node)
        {
            ToolboxItemToolboxNode tiNode = node as ToolboxItemToolboxNode;

            if (tiNode != null)
            {
                //load the type into this process and get the ToolboxItem
                tiNode.Type.Load();
                System.Drawing.Design.ToolboxItem ti = tiNode.GetToolboxItem();

                //web controls have sample HTML that need to be deserialised, in a ToolboxDataAttribute
                //TODO: Fix WebControlToolboxItem and (mono classlib's use of it) so we don't have to mess around with type lookups and attributes here
                if (ti.AssemblyName != null && ti.TypeName != null)
                {
                    //look up and register the type
                    ITypeResolutionService typeRes = (ITypeResolutionService)designerHost.GetService(typeof(ITypeResolutionService));
                    typeRes.ReferenceAssembly(ti.AssemblyName);
                    Type controlType = typeRes.GetType(ti.TypeName, true);

                    //read the WebControlToolboxItem data from the attribute
                    AttributeCollection atts = TypeDescriptor.GetAttributes(controlType);

                    System.Web.UI.ToolboxDataAttribute tda = (System.Web.UI.ToolboxDataAttribute)atts [typeof(System.Web.UI.ToolboxDataAttribute)];

                    //if it's present
                    if (tda != null && tda.Data.Length > 0)
                    {
                        //look up the tag's prefix and insert it into the data
                        WebFormReferenceManager webRef = designerHost.GetService(typeof(WebFormReferenceManager)) as WebFormReferenceManager;
                        if (webRef == null)
                        {
                            throw new Exception("Host does not provide an IWebFormReferenceManager");
                        }
                        string aspText = String.Format(tda.Data, webRef.GetTagPrefix(controlType));
                        System.Diagnostics.Trace.WriteLine("Toolbox processing ASP.NET item data: " + aspText);

                        //and add it to the document
                        designerHost.RootDocument.InsertFragment(aspText);
                        return;
                    }
                }

                //No ToolboxDataAttribute? Get the ToolboxItem to create the components itself
                ti.CreateComponents(designerHost);
            }
        }
コード例 #36
0
        //- ctor
        public MainForm()
        {
            InitializeComponent();


            //- STEP.B
            _mgr.PropertyGridHost.Parent = this.splitContainer.Panel2;
            //- STEP.C
            //- SelectedIndexChanged event fires when the TabControls SelectedIndex or SelectedTab value changes.
            //- give the focus to the DesigneSurface accordingly to te selected TabPage and sync the propertyGrid
            this.tabControl1.SelectedIndexChanged += (object sender, EventArgs e) =>
            {
                TabControl tabCtrl = sender as TabControl;
                _mgr.ActiveDesignSurface = (DesignSurfaceExt2)_mgr.DesignSurfaces[tabCtrl.SelectedIndex];
            };


            //- Add the toolboxItems to the future toolbox
            //- the pointer
            ToolboxItem toolPointer = new System.Drawing.Design.ToolboxItem();

            toolPointer.DisplayName = "<Pointer>";
            toolPointer.Bitmap      = new System.Drawing.Bitmap(16, 16);
            listBox1.Items.Add(toolPointer);
            //- the control
            listBox1.Items.Add(new ToolboxItem(typeof(Button)));
            listBox1.Items.Add(new ToolboxItem(typeof(ListView)));
            listBox1.Items.Add(new ToolboxItem(typeof(TreeView)));
            listBox1.Items.Add(new ToolboxItem(typeof(TextBox)));
            listBox1.Items.Add(new ToolboxItem(typeof(Label)));
            listBox1.Items.Add(new ToolboxItem(typeof(TabControl)));
            listBox1.Items.Add(new ToolboxItem(typeof(OpenFileDialog)));
            listBox1.Items.Add(new ToolboxItem(typeof(CheckBox)));
            listBox1.Items.Add(new ToolboxItem(typeof(ComboBox)));
            listBox1.Items.Add(new ToolboxItem(typeof(GroupBox)));
            listBox1.Items.Add(new ToolboxItem(typeof(ImageList)));
            listBox1.Items.Add(new ToolboxItem(typeof(Panel)));
            listBox1.Items.Add(new ToolboxItem(typeof(ProgressBar)));
            listBox1.Items.Add(new ToolboxItem(typeof(ToolBar)));
            listBox1.Items.Add(new ToolboxItem(typeof(ToolTip)));
            listBox1.Items.Add(new ToolboxItem(typeof(StatusBar)));
        }
コード例 #37
0
		public ToolboxItemToolboxNode (ToolboxItem item)
			: base (item.TypeName, item.AssemblyName.FullName)
		{
			base.Name = item.DisplayName;
			if (item.Bitmap != null)
				base.Icon = ImageToPixbuf (item.Bitmap);
			
			foreach (ToolboxItemFilterAttribute tbfa in item.Filter)
				base.ItemFilters.Add (tbfa);
			
			//we only need to serialise the ToolboxItem if it is non-standard, because we can reliably recreate the two built-in types
			if (item.GetType () == typeof (ToolboxItem))
				toolboxItemType = null; //no-op, but this has consequences 	
			else if (item.GetType () == typeof (System.Web.UI.Design.WebControlToolboxItem))
				toolboxItemType = new TypeReference (typeof (System.Web.UI.Design.WebControlToolboxItem));
			else {
				serializedToolboxItem = SerializeToolboxItem (item);
				toolboxItemType = new TypeReference (item.GetType ());
			} 
		}
 public ToolboxItemContainer(ToolboxItem item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     this._toolboxItem = item;
     this.UpdateFilter(item);
     this._hashCode = item.DisplayName.GetHashCode();
     if (item.AssemblyName != null)
     {
         this._hashCode ^= item.AssemblyName.GetHashCode();
     }
     if (item.TypeName != null)
     {
         this._hashCode ^= item.TypeName.GetHashCode();
     }
     if (this._hashCode == 0)
     {
         this._hashCode = item.DisplayName.GetHashCode();
     }
 }
コード例 #39
0
ファイル: MainForm.cs プロジェクト: zhangzheng1205/ZLB_ZuTai
        private void ToolBoxSelect()
        {
            _toolboxService = new CustomToolboxService();
            // 选中不同的工具条项目
            m_toolbox.toolBox.SelectedItemChanged += delegate(object sender, ToolBoxItem newItem)
            {
                _toolboxService.SetSelectedToolboxItem(newItem.Tag as System.Drawing.Design.ToolboxItem);
            };

            // 双击工具栏项目时增加到设计器中
            m_toolbox.toolBox.ItemDoubleClicked += delegate(object sender, ToolBoxItem newItem)
            {
                System.Drawing.Design.ToolboxItem toolboxItem = newItem.Tag as System.Drawing.Design.ToolboxItem;
                if (null != toolboxItem && ActivPage.surFace != null)
                {
                    IToolboxUser toolboxUser = ActivPage.host.GetDesigner(ActivPage.host.RootComponent as IComponent) as IToolboxUser;
                    if (null != toolboxUser)
                    {
                        toolboxUser.ToolPicked(toolboxItem);
                    }
                }
            };

            // 拖动工具栏项目的支持代码
            m_toolbox.toolBox.ItemDragStart += delegate(object sender, ToolBoxItem newItem)
            {
                System.Drawing.Design.ToolboxItem toolboxItem = newItem.Tag as System.Drawing.Design.ToolboxItem;
                if (null != toolboxItem)
                {
                    DataObject dataObject = ((IToolboxService)_toolboxService).SerializeToolboxItem(toolboxItem) as DataObject;
                    m_toolbox.toolBox.DoDragDrop(dataObject, DragDropEffects.Copy);
                }
            };
            _toolboxService.ResetToolboxItem += delegate
            {
                m_toolbox.toolBox.ResetSelection();
            };
        }
コード例 #40
0
 void IToolboxUser.ToolPicked(ToolboxItem tool)
 {
     this.ToolPicked(tool);
 }
コード例 #41
0
 bool IToolboxUser.GetToolSupported(ToolboxItem tool)
 {
     return this.GetToolSupported(tool);
 }
コード例 #42
0
 public void AddToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
 {
     AddToolboxItem(toolboxItem, "All");
 }
コード例 #43
0
		/// Remove a ToolboxItem from our toolbox.
		void System.Drawing.Design.IToolboxService.RemoveToolboxItem(ToolboxItem toolboxItem)
		{
			// UNIMPLEMENTED - Our ToolboxPane handles its own creation and modification
			// well enough, and our tool list stays constant. However, if you want a tool
			// list to have Add/Remove capability, here's the best place to do it.
		}
コード例 #44
0
 void IToolboxUser.ToolPicked(System.Drawing.Design.ToolboxItem item)
 {
     // TODO
 }
コード例 #45
0
        private static ICollection GetActivitiesFromToolboxItem(IServiceProvider serviceProvider, bool addAssemblyReference, IDesignerHost designerHost, ICollection activities, ToolboxItem toolBoxItem)
        {
            // this will make sure that we add the assembly reference to project
            if (addAssemblyReference && toolBoxItem.AssemblyName != null)
            {
                ITypeResolutionService trs = serviceProvider.GetService(typeof(ITypeResolutionService)) as ITypeResolutionService;
                if (trs != null)
                    trs.ReferenceAssembly(toolBoxItem.AssemblyName);
            }

            ActivityToolboxItem ActivityToolboxItem = toolBoxItem as ActivityToolboxItem;
            if (addAssemblyReference && ActivityToolboxItem != null)
                activities = ActivityToolboxItem.CreateComponentsWithUI(designerHost);
            else
                activities = toolBoxItem.CreateComponents(designerHost);
            return activities;
        }
コード例 #46
0
ファイル: Toolbox.cs プロジェクト: zpzgone/Sheng.Winform.IDE
 public void RemoveToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category)
 {
 }
コード例 #47
0
ファイル: Toolbox.cs プロジェクト: zpzgone/Sheng.Winform.IDE
 public void RemoveToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
 {
 }
コード例 #48
0
ファイル: Toolbox.cs プロジェクト: zpzgone/Sheng.Winform.IDE
 public void SetSelectedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
 {
 }
コード例 #49
0
ファイル: Toolbox.cs プロジェクト: zpzgone/Sheng.Winform.IDE
 public void AddLinkedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, IDesignerHost host)
 {
 }
コード例 #50
0
ファイル: Toolbox.cs プロジェクト: zpzgone/Sheng.Winform.IDE
 public void AddToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
 {
 }
コード例 #51
0
 public void RemoveToolboxItem(System.Drawing.Design.ToolboxItem item)
 {
     this.RemoveToolboxItem(item, "All");
 }
コード例 #52
0
ファイル: Toolbox.cs プロジェクト: zpzgone/Sheng.Winform.IDE
        public void ToolBoxItemButtonMouseDown(System.Windows.Forms.MouseEventArgs e, System.Drawing.Design.ToolboxItem toolboxItem)
        {
            if (toolboxItem == null)
            {
                return;
            }

            if (this.DesignerHost == null)
            {
                return;
            }

            if (e.Clicks == 2)
            {
                IDesignerHost idh = (IDesignerHost)this.DesignerHost.GetService(typeof(IDesignerHost));
                IToolboxUser  tbu = idh.GetDesigner(idh.RootComponent as IComponent) as IToolboxUser;

                if (tbu != null)
                {
                    tbu.ToolPicked(toolboxItem);
                }
            }
            else if (e.Clicks < 2)
            {
                IToolboxService tbs = this;

                // The IToolboxService serializes ToolboxItems by packaging them in DataObjects.
                DataObject d = tbs.SerializeToolboxItem(toolboxItem) as DataObject;

                try
                {
                    this.DoDragDrop(d, DragDropEffects.Copy);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #53
0
 protected virtual bool GetToolSupported(ToolboxItem tool)
 {
     return true;
 }
コード例 #54
0
ファイル: Toolbox.cs プロジェクト: zpzgone/Sheng.Winform.IDE
 public object SerializeToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
 {
     return(new DataObject(toolboxItem));
 }
コード例 #55
0
 protected virtual void ToolPicked(ToolboxItem tool)
 {
     IMenuCommandService service = (IMenuCommandService) this.GetService(typeof(IMenuCommandService));
     if (service != null)
     {
         MenuCommand command = service.FindCommand(StandardCommands.TabOrder);
         if ((command != null) && command.Checked)
         {
             return;
         }
     }
     IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     if (host != null)
     {
         host.Activate();
     }
     try
     {
         ParentControlDesigner selectedParentControlDesigner = this.GetSelectedParentControlDesigner();
         if (!base.InvokeGetInheritanceAttribute(selectedParentControlDesigner).Equals(InheritanceAttribute.InheritedReadOnly))
         {
             ParentControlDesigner.InvokeCreateTool(selectedParentControlDesigner, tool);
             IToolboxService service2 = (IToolboxService) this.GetService(typeof(IToolboxService));
             if (service2 != null)
             {
                 service2.SelectedToolboxItemUsed();
             }
         }
     }
     catch (Exception exception)
     {
         base.DisplayError(exception);
         if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
         {
             throw;
         }
     }
 }
コード例 #56
0
		/// We serialize a toolbox by packaging it in a DataObject. Simple!
		public object SerializeToolboxItem(ToolboxItem toolboxItem)
		{
			return new DataObject(toolboxItem);
		}
コード例 #57
0
        internal static Activity[] DeserializeActivitiesFromToolboxItem(IServiceProvider serviceProvider, ToolboxItem toolboxItem, bool addAssemblyReference)
        {
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");

            IDesignerHost designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost));
            if (designerHost == null)
                throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(IDesignerHost).Name));

            ICollection activities = null;

            if (toolboxItem != null)
            {
                activities = GetActivitiesFromToolboxItem(serviceProvider, addAssemblyReference, designerHost, activities, toolboxItem);
            }

            if (activities != null && Helpers.AreAllActivities(activities))
                return (Activity[])new ArrayList(activities).ToArray(typeof(Activity));
            else
                return new Activity[] { };
        }
コード例 #58
0
		/// Remove a ToolboxItem from the specified category in our toolbox.
		public void RemoveToolboxItem(ToolboxItem toolboxItem, string category)
		{
			// UNIMPLEMENTED - Our ToolboxPane handles its own creation and modification
			// well enough, and our tool list stays constant. However, if you want a tool
			// list to have Add/Remove capability, here's the best place to do it.
		}
コード例 #59
0
		public WebFormsToolboxNode (ToolboxItem item) : base (item)
		{
		}
コード例 #60
0
 public object SerializeToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
 {
     return(null);
 }