예제 #1
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;

                DisplayNameAttribute display = (DisplayNameAttribute)Attribute.GetCustomAttribute(type, typeof(DisplayNameAttribute));
                if (display != null)
                {
                    tbi.DisplayName = display.DisplayName;
                }

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

                Toolbox.ToolsListBox.Items.Add(tbi);
            }
        }
예제 #2
0
        private void PopulateToolboxItems(XmlNode tabNode, ToolboxTab toolboxTab)
        {
            if (tabNode == null)
            {
                return;
            }

            XmlNode toolboxItemCollectionNode = tabNode[Strings.ToolboxItemCollection];

            if (toolboxItemCollectionNode == null)
            {
                return;
            }

            XmlNodeList toolboxItemNodeList = toolboxItemCollectionNode.ChildNodes;

            if (toolboxItemNodeList == null)
            {
                return;
            }

            ToolboxItemCollection toolboxItems = new ToolboxItemCollection();

            foreach (XmlNode toolboxItemNode in toolboxItemNodeList)
            {
                if (toolboxItemNode == null)
                {
                    continue;
                }

                XmlNode typeNode = toolboxItemNode[Strings.Type];
                if (typeNode == null)
                {
                    continue;
                }

                bool found = false;
                System.Reflection.Assembly[] loadedAssemblies = System.AppDomain.CurrentDomain.GetAssemblies();
                for (int i = 0; i < loadedAssemblies.Length && !found; i++)
                {
                    System.Reflection.Assembly assembly = loadedAssemblies[i];
                    System.Type[] types = assembly.GetTypes();
                    for (int j = 0; j < types.Length && !found; j++)
                    {
                        System.Type type = types[j];
                        if (type.FullName == typeNode.InnerXml.ToString())
                        {
                            ToolboxItem toolboxItem = new ToolboxItem();
                            toolboxItem.Type = type;
                            toolboxItems.Add(toolboxItem);
                            found = true;
                        }
                    }
                }
            }
            toolboxTab.ToolboxItems = toolboxItems;
            return;
        }
예제 #3
0
        public void AddTab(string tabName, Type[] itemTypes)
        {
            ToolboxTab toolboxTab = new ToolboxTab();

            toolboxTab.Name = tabName;

            ToolboxItemCollection toolboxItems = new ToolboxItemCollection();

            for (int i = 0; i < itemTypes.Length; i++)
            {
                ToolboxItem toolboxItem = new ToolboxItem();

                toolboxItem.Type = itemTypes[i];
                toolboxItem.Name = itemTypes[i].Name;
                toolboxItems.Add(toolboxItem);
            }
            toolboxTab.ToolboxItems = toolboxItems;

            m_ToolboxTabCollection.Add(toolboxTab);
        }
예제 #4
0
 ///  <summary>
 ///    Adds a <see cref="ToolboxTab"/> with the specified value to the
 ///    <see cref="ToolboxTabCollection"/> .
 ///  </summary>
 ///  <param name="value">The <see cref="ToolboxTab"/> to add.</param>
 ///  <returns>
 ///    The index at which the new element was inserted.
 ///  </returns>
 ///  <remarks><seealso cref="ToolboxTabCollection.AddRange"/></remarks>
 ///  <history>
 ///      [dineshc] 3/26/2003  Created
 ///  </history>
 public int Add(ToolboxTab value)
 {
     return(List.Add(value));
 }
예제 #5
0
 ///  <summary>
 ///     Removes a specific <see cref="ToolboxTab"/> from the
 ///    <see cref="ToolboxTabCollection"/> .
 ///  </summary>
 ///  <param name="value">The <see cref="ToolboxTab"/> to remove from the <see cref="ToolboxTabCollection"/> .</param>
 ///  <remarks><exception cref="System.ArgumentException"><paramref name="value"/> is not found in the Collection. </exception></remarks>
 ///  <history>
 ///      [dineshc] 3/26/2003  Created
 ///  </history>
 public void Remove(ToolboxTab value)
 {
     List.Remove(value);
 }
예제 #6
0
 ///  <summary>
 ///  Inserts a <see cref="ToolboxTab"/> into the <see cref="ToolboxTabCollection"/> at the specified index.
 ///  </summary>
 ///  <param name="index">The zero-based index where <paramref name="value"/> should be inserted.</param>
 ///  <param name=" value">The <see cref="ToolboxTab"/> to insert.</param>
 ///  <remarks><seealso cref="ToolboxTabCollection.Add"/></remarks>
 ///  <history>
 ///      [dineshc] 3/26/2003  Created
 ///  </history>
 public void Insert(int index, ToolboxTab value)
 {
     List.Insert(index, value);
 }
예제 #7
0
 ///  <summary>
 ///    Returns the index of a <see cref="ToolboxTab"/> in
 ///       the <see cref="ToolboxTabCollection"/> .
 ///  </summary>
 ///  <param name="value">The <see cref="ToolboxTab"/> to locate.</param>
 ///  <returns>
 ///  The index of the <see cref="ToolboxTab"/> of <paramref name="value"/> in the
 ///  <see cref="ToolboxTabCollection"/>, if found; otherwise, -1.
 ///  </returns>
 ///  <remarks><seealso cref="ToolboxTabCollection.Contains"/></remarks>
 ///  <history>
 ///      [dineshc] 3/26/2003  Created
 ///  </history>
 public int IndexOf(ToolboxTab value)
 {
     return(List.IndexOf(value));
 }
예제 #8
0
 ///  <summary>
 ///  Gets a value indicating whether the
 ///    <see cref="ToolboxTabCollection"/> contains the specified <see cref="ToolboxTab"/>.
 ///  </summary>
 ///  <param name="value">The <see cref="ToolboxTab"/> to locate.</param>
 ///  <returns>
 ///  <see langword="true"/> if the <see cref="ToolboxTab"/> is contained in the collection;
 ///   otherwise, <see langword="false"/>.
 ///  </returns>
 ///  <remarks><seealso cref="ToolboxTabCollection.IndexOf"/></remarks>
 ///  <history>
 ///      [dineshc] 3/26/2003  Created
 ///  </history>
 public bool Contains(ToolboxTab value)
 {
     return(List.Contains(value));
 }
예제 #9
0
        private ToolboxTabCollection PopulateToolboxTabs(XmlDocument xmlDocument)
        {
            if (xmlDocument == null)
            {
                return(null);
            }

            XmlNode toolboxNode = xmlDocument.FirstChild;

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

            XmlNode tabCollectionNode = toolboxNode.FirstChild;

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

            XmlNodeList tabsNodeList = tabCollectionNode.ChildNodes;

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

            ToolboxTabCollection toolboxTabs = new ToolboxTabCollection();

            foreach (XmlNode tabNode in tabsNodeList)
            {
                if (tabNode == null)
                {
                    continue;
                }

                XmlNode propertiesNode = tabNode.FirstChild;
                if (propertiesNode == null)
                {
                    continue;
                }

                XmlNode nameNode = propertiesNode[Strings.Name];
                if (nameNode == null)
                {
                    continue;
                }

                ToolboxTab toolboxTab = new ToolboxTab();
                toolboxTab.Name = nameNode.InnerXml.ToString();
                PopulateToolboxItems(tabNode, toolboxTab);
                toolboxTabs.Add(toolboxTab);
            }
            if (toolboxTabs.Count == 0)
            {
                return(null);
            }

            return(toolboxTabs);
        }