Ejemplo n.º 1
0
        // Sérialize la toolboxItem nécessaire pour le drag and drop
        public object SerializeToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
        {
            DataObject dataObject = new DataObject();

            dataObject.SetData(typeof(System.Drawing.Design.ToolboxItem), toolboxItem);
            return(dataObject);
        }
Ejemplo n.º 2
0
        private void UpdateToolboxItems(int tabIndex)
        {
            Toolbox.ToolsListBox.Items.Clear();
            Toolbox.ToolsListBox.Items.Add(pointer);
            if (Toolbox.Tabs.Count <= 0)
            {
                return;
            }

            ToolboxTab            toolboxTab   = Toolbox.Tabs[tabIndex];
            ToolboxItemCollection toolboxItems = toolboxTab.ToolboxItems;

            foreach (ToolboxItem toolboxItem in toolboxItems)
            {
                Type type = toolboxItem.Type;
                System.Drawing.Design.ToolboxItem     tbi = new System.Drawing.Design.ToolboxItem(type);
                System.Drawing.ToolboxBitmapAttribute tba = TypeDescriptor.GetAttributes(type)[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute;

                if (tba != null)
                {
                    tbi.Bitmap = (System.Drawing.Bitmap)tba.GetImage(type);
                }

                Toolbox.ToolsListBox.Items.Add(tbi);
            }
        }
		private System.Drawing.Design.ToolboxItem pointer; // a "null" tool
		public ToolboxUIManagerVS(Toolbox toolbox)
		{
			m_toolbox = toolbox;
			pointer = new System.Drawing.Design.ToolboxItem();
			pointer.DisplayName = "<Pointer>";
			pointer.Bitmap = new System.Drawing.Bitmap(16, 16);
		}
Ejemplo n.º 4
0
 private System.Drawing.Design.ToolboxItem pointer;         // a "null" tool
 public ToolboxUIManagerVS(Toolbox toolbox)
 {
     m_toolbox           = toolbox;
     pointer             = new System.Drawing.Design.ToolboxItem();
     pointer.DisplayName = "<Pointer>";
     pointer.Bitmap      = new System.Drawing.Bitmap(16, 16);
 }
 private void DrawToolBoxItem()
 {
     if (this.ToolboxItems == null)
     {
         return;
     }
     if (this.ToolboxItems.Count == 0)
     {
         return;
     }
     this.SuspendLayout();
     for (int i = this.ToolboxItems.Count - 1; i >= 0; i--)
     {
         Type type = this.ToolboxItems[i].Type;
         System.Drawing.Design.ToolboxItem     tbi = new System.Drawing.Design.ToolboxItem(type);
         System.Drawing.ToolboxBitmapAttribute tba =
             TypeDescriptor.GetAttributes(type)[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute;
         if (tba != null)
         {
             tbi.Bitmap = (System.Drawing.Bitmap)tba.GetImage(type);
         }
         DrawToolBoxItem(tbi, this.ToolboxItems[i].Name);
     }
     this.ResumeLayout();
 }
Ejemplo n.º 6
0
        public DummyToolbox()
        {
            InitializeComponent();

            #region Ìí¼ÓToolBox

            string fileName = Application.StartupPath + @"\..\..\data\ControlLibrary.xml";
            ComponentLibraryLoader componentLibraryLoader = new ComponentLibraryLoader();
            componentLibraryLoader.LoadToolComponentLibrary(fileName);

            toolBox = new ToolBox.ToolBox {
                Dock = DockStyle.Fill
            };

            foreach (Category category in componentLibraryLoader.Categories)
            {
                if (category.IsEnabled)
                {
                    ToolBoxCategory cate = new ToolBoxCategory();
                    cate.ImageIndex = -1;
                    cate.IsOpen     = false;
                    cate.Name       = category.Name;
                    cate.Parent     = null;

                    ToolBoxItem item = new ToolBoxItem();
                    item.Tag    = null;
                    item.Name   = "<Pointer>";
                    item.Parent = null;
                    cate.Items.Add(item);

                    foreach (ToolComponent component in category.ToolComponents)
                    {
                        item = new ToolBoxItem();

                        System.Drawing.Design.ToolboxItem toolboxItem = new System.Drawing.Design.ToolboxItem();
                        toolboxItem.TypeName    = component.FullName;
                        toolboxItem.Bitmap      = componentLibraryLoader.GetIcon(component);
                        toolboxItem.DisplayName = component.Name;
                        Assembly asm = component.LoadAssembly();
                        toolboxItem.AssemblyName = asm.GetName();

                        item.Image  = toolboxItem.Bitmap;
                        item.Tag    = toolboxItem;
                        item.Name   = component.Name;
                        item.Parent = null;

                        cate.Items.Add(item);
                    }

                    toolBox.Categories.Add(cate);
                }
            }

            pnlToolBox.Controls.Add(toolBox);//×ó±ßpanelÌí¼Ó¿Ø¼þ

            #endregion
        }
Ejemplo n.º 7
0
        // On définit un toolboxItem à sélectionner sur le toolBox
        public void SetSelectedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
        {
            if (toolBox == null)
            {
                return;
            }

            toolBox.SelectedItem = toolboxItem;
        }
Ejemplo n.º 8
0
 public ToolboxItemButton(System.Drawing.Design.ToolboxItem toolboxItem, string displayName)
 {
     this.SetStyle(ControlStyles.UserPaint, true);
     this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
     this.SetStyle(ControlStyles.ResizeRedraw, true);
     this._displayName = displayName;
     this._toolboxItem = toolboxItem;
 }
Ejemplo n.º 9
0
        // Retire un toolboxItem du toolbox
        public void RemoveToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
        {
            if (toolBox == null)
            {
                return;
            }

            toolBox.SelectedItem = null;
            toolBox.Items.Remove(toolboxItem);
        }
Ejemplo n.º 10
0
        // Retoutrne la liste de ToolboxItems sélectionnés
        public System.Drawing.Design.ToolboxItemCollection GetToolboxItems()
        {
            if (toolBox == null)
            {
                return(null);
            }

            System.Drawing.Design.ToolboxItem[] t = new System.Drawing.Design.ToolboxItem[toolBox.Items.Count];
            toolBox.Items.CopyTo(t, 0);

            return(new System.Drawing.Design.ToolboxItemCollection(t));
        }
Ejemplo n.º 11
0
        // Déserialize un toolboxitem nécessaire pour le drag and drop
        public System.Drawing.Design.ToolboxItem DeserializeToolboxItem(object serializedObject)
        {
            IDataObject dataObject = serializedObject as IDataObject;

            if (dataObject == null)
            {
                return(null);
            }

            System.Drawing.Design.ToolboxItem t = (System.Drawing.Design.ToolboxItem)dataObject.GetData(typeof(System.Drawing.Design.ToolboxItem));
            return(t);
        }
Ejemplo n.º 12
0
 public void AddItem(System.Drawing.Design.ToolboxItem Item, int TabIndex, ToolBoxItemDetails details)
 {
     if (TabIndex > arrTabs.Count - 1 && TabIndex < 0)
     {
         MessageBox.Show("Invalid Index value given to AddItem");
         return;
     }
     GetTab(TabIndex).AddItem(Item);
     //GetTab(TabIndex).ImgIndex = details.ImageIndex;
     //GetTab(TabIndex).ListV.Items.Add(details.Caption, details.ImageIndex);
     //GetTab(TabIndex).ListV.Items[0].Selected = true;
 }
Ejemplo n.º 13
0
        public void AddItem(System.Drawing.Design.ToolboxItem Item, int TabIndex, ToolBoxItemDetails details, string imagePath, string toolTip)
        {
            if (TabIndex > arrTabs.Count - 1 && TabIndex < 0)
            {
                MessageBox.Show("Invalid Index value given to AddItem");
                return;
            }
            ToolBoxTab tab = GetTab(TabIndex);

            tab.AddItem(Item);
            tab.ImgListView.Items.Add(imagePath, toolTip, details.Caption);
            tab.ImgListView.Items[0].Selected = true;
            tab.ImgListView.BringToFront();
        }
        private void DrawToolBoxItem(System.Drawing.Design.ToolboxItem toolboxItem, string displayName)
        {
            if (displayName == String.Empty)
            {
                displayName = toolboxItem.DisplayName;
            }
            ToolboxItemButton toolboxButton = new ToolboxItemButton(toolboxItem, displayName);

            toolboxButton.Index  = this.toolboxItemButtonCollection.Count;
            toolboxButton.Height = this.ItemHeight;
            toolboxButton.Dock   = DockStyle.Top;
            this.toolTip.SetToolTip(toolboxButton, toolboxItem.Description);
            toolboxButton.MouseDown += new MouseEventHandler(toolboxButton_MouseDown);
            toolboxButton.KeyUp     += new KeyEventHandler(toolboxButton_KeyUp);
            this.toolboxItemButtonCollection.Add(toolboxButton);
            this.Controls.Add(toolboxButton);
        }
 public ToolboxItemContainer(Toolbox toolbox)
 {
     InitializeComponent();
     this.Toolbox = toolbox;
     this.SetStyle(ControlStyles.UserPaint, true);
     this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
     this.SetStyle(ControlStyles.ResizeRedraw, true);
     pointer                   = new System.Drawing.Design.ToolboxItem();
     pointer.DisplayName       = "<指针>";
     pointer.Bitmap            = IconsLibrary.Arrow;
     this.toolTip.AutoPopDelay = 5000;
     this.toolTip.BackColor    = System.Drawing.Color.White;
     this.toolTip.ForeColor    = System.Drawing.Color.Black;
     this.toolTip.InitialDelay = 300;
     this.toolTip.ReshowDelay  = 300;
 }
Ejemplo n.º 16
0
            private ToolboxItemSerializer(SerializationInfo info, StreamingContext context)
            {
                AssemblyName name = (AssemblyName)info.GetValue("AssemblyName", typeof(AssemblyName));

                byte[] buffer = (byte[])info.GetValue("Stream", typeof(byte[]));
                if (_formatter == null)
                {
                    _formatter = new BinaryFormatter();
                }
                SerializationBinder binder = _formatter.Binder;

                _formatter.Binder = new ToolboxItemContainer.ToolboxSerializationBinder(name);
                try
                {
                    this._toolboxItem = (System.Drawing.Design.ToolboxItem)_formatter.Deserialize(new MemoryStream(buffer));
                }
                finally
                {
                    _formatter.Binder = binder;
                }
            }
 void System.Drawing.Design.IToolboxService.RemoveToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
 {
 }
 void System.Drawing.Design.IToolboxService.AddLinkedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category, System.ComponentModel.Design.IDesignerHost host)
 {
 }
 protected virtual System.Drawing.Design.ToolboxItemContainer CreateItemContainer(System.Drawing.Design.ToolboxItem item, System.ComponentModel.Design.IDesignerHost link)
 {
     throw null;
 }
 public void UpdateFilter(System.Drawing.Design.ToolboxItem item)
 {
 }
 public ToolboxItemContainer(System.Drawing.Design.ToolboxItem item)
 {
 }
		private void UpdateToolboxItems(int tabIndex)
		{
			Toolbox.ToolsListBox.Items.Clear();
			Toolbox.ToolsListBox.Items.Add(pointer);
			if (Toolbox.Tabs.Count <= 0)
				return;

			ToolboxTab toolboxTab = Toolbox.Tabs[tabIndex];
			ToolboxItemCollection toolboxItems = toolboxTab.ToolboxItems;

			foreach (ToolboxItem toolboxItem in toolboxItems)
			{
				Type type = toolboxItem.Type;
				System.Drawing.Design.ToolboxItem tbi = new System.Drawing.Design.ToolboxItem(type);
				System.Drawing.ToolboxBitmapAttribute tba = 
                    TypeDescriptor.GetAttributes(type)[typeof(System.Drawing.ToolboxBitmapAttribute)] as System.Drawing.ToolboxBitmapAttribute;

				if (tba != null)
				{
					tbi.Bitmap = (System.Drawing.Bitmap)tba.GetImage(type);
				}

				Toolbox.ToolsListBox.Items.Add(tbi);
			}
		}
 public int IndexOf(System.Drawing.Design.ToolboxItem value)
 {
     throw null;
 }
 private ToolboxItemSerializer(SerializationInfo info, StreamingContext context)
 {
     AssemblyName name = (AssemblyName) info.GetValue("AssemblyName", typeof(AssemblyName));
     byte[] buffer = (byte[]) info.GetValue("Stream", typeof(byte[]));
     if (_formatter == null)
     {
         _formatter = new BinaryFormatter();
     }
     SerializationBinder binder = _formatter.Binder;
     _formatter.Binder = new ToolboxItemContainer.ToolboxSerializationBinder(name);
     try
     {
         this._toolboxItem = (System.Drawing.Design.ToolboxItem) _formatter.Deserialize(new MemoryStream(buffer));
     }
     finally
     {
         _formatter.Binder = binder;
     }
 }
Ejemplo n.º 25
0
 public void Remove(System.Drawing.Design.ToolboxItem Item)
 {
     arrItems.Remove(Item);
 }
 void System.Drawing.Design.IToolboxService.SetSelectedToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
 {
 }
 void System.Drawing.Design.IToolboxService.RemoveToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem, string category)
 {
 }
 object System.Drawing.Design.IToolboxService.SerializeToolboxItem(System.Drawing.Design.ToolboxItem toolboxItem)
 {
     throw null;
 }
Ejemplo n.º 29
0
		private void PopulateToolbox()
		{
			// Populate our fake toolbox with some images and text
			foreach (Type type in DataToolBoxTypes)
			{
				System.Drawing.Design.ToolboxItem toolboxItem = new System.Drawing.Design.ToolboxItem(type);
				ilTools.Images.Add(toolboxItem.Bitmap);
				ListViewItem item = new ListViewItem(toolboxItem.DisplayName);
				item.ImageIndex = ilTools.Images.Count - 1;
				lvwTools.Items.Add(item);
			}
		}
Ejemplo n.º 30
0
 public void AddItem(System.Drawing.Design.ToolboxItem Item)
 {
     arrItems.Add(Item);
 }
 public void CreateComponentFromTool(System.Drawing.Design.ToolboxItem tool)
 {
 }
Ejemplo n.º 32
0
        public void init()
        {
            this.ToolBox.TabMouseUp += new TabMouseEventHandler(ToolBox_TabMouseUp);
            //组件类型

            ToolBoxTabCollection  tabCollection  = new ToolBoxTabCollection();
            ToolBoxItemCollection itemCollection = new ToolBoxItemCollection();

            for (int i = 0; i < CTabNameStrings.Count(); i++)
            {
                this.ToolBox.AddTab(CTabNameStrings[i], 1);
                ToolBoxTab tab = this.ToolBox[i];
                tabCollection.Add(tab);
            }
            //自定义控件处理:xuehaouan 2016-4-13 ->
            string        nodeString  = "Components/AddedComponent";//注意这里AddedComponent作为与原先的区别
            XmlNodeList   tmpXNodeLst = mXDoc.SelectNodes(nodeString);
            XmlNode       m_tmpXNode;
            IEnumerator   tmpIe       = tmpXNodeLst.GetEnumerator();
            List <string> dllFailList = new List <string>();

            while (tmpIe.MoveNext())
            {
                m_tmpXNode = tmpIe.Current as XmlNode;
                string   ModName = m_tmpXNode.Attributes["FullName"].Value;
                string   AsmStr  = m_tmpXNode.Attributes["Asm"].Value;
                Assembly assembly;
                Type     type = null;
                if (AsmStr.Substring(AsmStr.Length - 3) == "dll" || AsmStr.Substring(AsmStr.Length - 3) == "DLL")
                {
                    if (File.Exists(@dllmng.DLLPATH + AsmStr))
                    {
                        assembly = Assembly.LoadFile(dllmng.DLLPATH + AsmStr);
                        type     = assembly.GetType(AsmStr.Substring(0, AsmStr.Length - 3) + ModName); //类名称 e.g.  ACMV.Controls.PIDControlPanelWithDataConn
                    }
                    else
                    {
                        if (!dllFailList.Contains("Can not find DLL: " + AsmStr + " in file " + dllmng.DLLPATH))
                        {
                            dllFailList.Add("Can not find DLL: " + AsmStr + " in file " + dllmng.DLLPATH);
                        }
                        //MessageBox.Show("Can not find" + AsmStr + " in file " + dllmng.DLLPATH, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    if (File.Exists(@dllmng.DLLPATH + AsmStr + ".dll"))
                    {
                        assembly = Assembly.LoadFile(dllmng.DLLPATH + AsmStr + ".dll");
                        type     = assembly.GetType(AsmStr + "." + ModName); //类名称 e.g.  ACMV.Controls.PIDControlPanelWithDataConn
                    }
                    else
                    {
                        if (!dllFailList.Contains("Can not find DLL: " + AsmStr + ".dll" + " in file " + dllmng.DLLPATH))
                        {
                            dllFailList.Add("Can not find DLL: " + AsmStr + ".dll" + " in file " + dllmng.DLLPATH);
                        }
                        //MessageBox.Show("Can not find" + AsmStr + ".dll " + " in file " + dllmng.DLLPATH, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                if (type != null)
                {
                    System.Drawing.Design.ToolboxItem tbi = new System.Drawing.Design.ToolboxItem(type);

                    tabCollection[tabCollection.Count - 1].AddItem(tbi.DisplayName, 2, true, tbi);
                }
            }
            string infoStr = "";

            foreach (string dllFail in dllFailList)
            {
                infoStr += dllFail + "\r\n";
            }
            if (infoStr != "")
            {
                MessageBox.Show(infoStr + "\r\n" + "Please Check!", "Custom Control(DLL) Error Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            //<-
            if (null != tabCollection)
            {
                for (int i = 0; i < moduleType.Count(); i++)
                {
                    FillTreeView(bnTreeView, moduleType[i], i);
                    tabCollection[0].Control = bnTreeView;
                }

                //   }
                for (int i = 0; i < SubModuleTypes.Count(); i++)
                {
                    System.Drawing.Design.ToolboxItem tbi = new System.Drawing.Design.ToolboxItem(SubModuleTypes[i]);

                    tabCollection[1].AddItem(tbi.DisplayName, 3, true, tbi);
                }
            }
        }
 public bool Contains(System.Drawing.Design.ToolboxItem value)
 {
     throw null;
 }
Ejemplo n.º 34
0
 public bool RemoveItem(System.Drawing.Design.ToolboxItem item)
 {
     GetTab(0).Remove(item);
     return(true);
 }
 internal ToolboxItemSerializer(System.Drawing.Design.ToolboxItem toolboxItem)
 {
     this._toolboxItem = toolboxItem;
 }