示例#1
0
        public ToolboxTabProject CreateProjectTab(string name, Guid guid)
        {
            ToolboxTabProject retTab = null;
            int n = TabCount;

            for (int i = 0; i < n; i++)
            {
                ToolboxTabProject ptab = toolTabs[i] as ToolboxTabProject;
                if (ptab != null)
                {
                    if (ptab.ProjectGuid == guid)
                    {
                        ptab.Visible = true;
                        retTab       = ptab;
                    }
                    else
                    {
                        ptab.Visible = false;
                    }
                }
            }
            if (retTab == null)
            {
                ToolboxTab2[] a = new ToolboxTab2[n + 1];
                toolTabs.CopyTo(a, 1);
                toolTabs        = a;
                retTab          = new ToolboxTabProject(this, name, guid);
                toolTabs[0]     = retTab;
                retTab.Visible  = true;
                retTab.Location = new Point(0, 0);
                retTab.Size     = new Size(this.ClientSize.Width - 1, LabelToolboxTabTitle.TitleHeight - 1);
                panelTabs.Controls.Add(retTab);
            }
            return(retTab);
        }
示例#2
0
 protected override void OnClick(EventArgs e)
 {
     if (mouse == enumMousePos.Close)
     {
         if (toolbox != null)
         {
             toolbox.HideToolBox(this, e);
         }
     }
     else if (mouse == enumMousePos.Add)
     {
         if (toolbox != null)
         {
             dlgToolboxTab dlg = new dlgToolboxTab();
             if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK)
             {
                 string name = dlg.GetResult();
                 if (toolbox.TabNameExists(name))
                 {
                     MessageBox.Show(this.FindForm(), "<" + name + "> already exists", "Toolbox", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else
                 {
                     ToolboxTab2 tab = toolbox.CreateTab(name, false, -1);
                     tab.AdjustSize();
                     toolbox.Changed = true;
                 }
             }
         }
     }
 }
示例#3
0
        public void CreatePrimaryObjTab()
        {
            Bitmap      bmpInt   = new Bitmap(GetType(), "int.bmp");
            Bitmap      bmpDec   = new Bitmap(GetType(), "decimal.bmp");
            Bitmap      bmpAbc   = new Bitmap(GetType(), "abc.bmp");
            Bitmap      bmpObj   = new Bitmap(GetType(), "obj.bmp");
            Bitmap      bmpBool  = new Bitmap(GetType(), "bool.bmp");
            Bitmap      bmpDate  = new Bitmap(GetType(), "date.bmp");
            Bitmap      bmpByte  = new Bitmap(GetType(), "byte.bmp");
            Bitmap      bmpEarg  = new Bitmap(GetType(), "eargv.bmp");
            Bitmap      bmpSByte = new Bitmap(GetType(), "sbyte.bmp");
            Bitmap      bmpChar  = new Bitmap(GetType(), "char.bmp");
            ToolboxTab2 tab      = CreateTab("Primary Objects", true, -1);

            tab.Persist = false;
            tab.AddItem(new xToolboxItem(typeof(object), bmpObj));
            tab.AddItem(new xToolboxItem(typeof(char), bmpChar));
            tab.AddItem(new xToolboxItem(typeof(sbyte), bmpSByte));
            tab.AddItem(new xToolboxItem(typeof(Int16), bmpInt));
            tab.AddItem(new xToolboxItem(typeof(Int32), bmpInt));
            tab.AddItem(new xToolboxItem(typeof(Int64), bmpInt));
            tab.AddItem(new xToolboxItem(typeof(byte), bmpByte));
            tab.AddItem(new xToolboxItem(typeof(UInt16), bmpInt));
            tab.AddItem(new xToolboxItem(typeof(UInt32), bmpInt));
            tab.AddItem(new xToolboxItem(typeof(UInt64), bmpInt));
            tab.AddItem(new xToolboxItem(typeof(string), bmpAbc));
            tab.AddItem(new xToolboxItem(typeof(float), bmpDec));
            tab.AddItem(new xToolboxItem(typeof(double), bmpDec));
            tab.AddItem(new xToolboxItem(typeof(bool), bmpBool));
            tab.AddItem(new xToolboxItem(typeof(DateTime), bmpDate));
            tab.AddItem(new xToolboxItem(typeof(EventArgs), bmpEarg));
            tab.AddItem(new xToolboxItem(typeof(void), bmpObj, "Object"));
            tab.AdjustSize();
        }
示例#4
0
        public ToolboxTab2 CreateTab(string name, bool readOnly, int idx)
        {
            int n = TabCount;

            for (int i = 0; i < n; i++)
            {
                if (string.Compare(name, toolTabs[i].Name, StringComparison.OrdinalIgnoreCase) == 0)
                {
                    toolTabs[i].Visible = true;
                    return(toolTabs[i]);
                }
            }
            ToolboxTab2[] a = new ToolboxTab2[n + 1];
            if (idx >= 0 && idx < n)
            {
                for (int i = 0, j = 0; i <= n; i++)
                {
                    if (i < idx)
                    {
                        a[i] = toolTabs[j];
                        j++;
                    }
                    else if (i > idx)
                    {
                        a[i] = toolTabs[j];
                        j++;
                    }
                }
            }
            else
            {
                if (n > 0)
                {
                    toolTabs.CopyTo(a, 0);
                }
            }
            toolTabs = a;
            if (idx >= 0 && idx < n)
            {
                n = idx;
            }
            toolTabs[n] = new ToolboxTab2(this, name, n, readOnly);
            if (n == 0)
            {
                toolTabs[n].Location = new Point(0, 0);
            }
            else
            {
                toolTabs[n].Location = new Point(0, toolTabs[n - 1].Height + toolTabs[n - 1].Top);
            }
            toolTabs[n].Size  = new Size(this.ClientSize.Width - 1, LabelToolboxTabTitle.TitleHeight - 1);
            this.Visible      = true;
            panelTabs.Visible = true;
            panelTabs.Controls.Add(toolTabs[n]);
            return(toolTabs[n]);
        }
 public LabelToolboxTabTitle(ToolboxTab2 tab)
 {
     toolboxTab      = tab;
     this.Font       = new Font(this.Font.FontFamily, this.Font.Size, this.Font.Style | FontStyle.Bold, this.Font.Unit);
     this.BackColor  = System.Drawing.Color.LightGray;
     this.ForeColor  = System.Drawing.Color.Black;
     this.ImageAlign = ContentAlignment.MiddleLeft;
     this.TextAlign  = ContentAlignment.MiddleCenter;
     this.Height     = TitleHeight;
 }
示例#6
0
        public void AddTab(string tab, bool readOnly, bool persist, int idx, bool clearItems)
        {
            ToolboxTab2 t = CreateTab(tab, readOnly, idx);

            t.Persist = persist;
            t.Visible = true;
            if (clearItems)
            {
                t.RemoveItems();
            }
        }
示例#7
0
 public void RemoveTab(ToolboxTab2 tab)
 {
     if (toolTabs != null)
     {
         for (int i = 0; i < toolTabs.Length; i++)
         {
             if (toolTabs[i] == tab)
             {
                 removeTab(i);
                 break;
             }
         }
     }
 }
示例#8
0
        public void SaveCustomToolboxTabs()
        {
            XmlDocument xml  = new XmlDocument();
            XmlNode     root = xml.CreateElement("Toolbox");

            xml.AppendChild(root);
            if (toolTabs != null)
            {
                for (int i = 0; i < toolTabs.Length; i++)
                {
                    ToolboxTab2 tab = toolTabs[i];
                    if (tab != null && tab.Persist)
                    {
                        XmlNode      node = xml.CreateElement("ToolboxTab");
                        XmlAttribute xa   = xml.CreateAttribute("title");
                        xa.Value = tab.Name;
                        node.Attributes.Append(xa);
                        //
                        if (tab.IsCustom)
                        {
                            xa       = xml.CreateAttribute("readonly");
                            xa.Value = "false";
                            node.Attributes.Append(xa);
                        }
                        root.AppendChild(node);
                        for (int j = 0; j < tab.ToolboxItemCount; j++)
                        {
                            xToolboxItem x = tab[j + 1] as xToolboxItem;
                            if (x != null && x.Type != null)
                            {
                                node.AppendChild(x.CreateNode(xml));
                            }
                        }
                    }
                }
            }
            xml.Save(_toolboxXml);
            Changed = false;
        }
示例#9
0
        private void removeTab(int i)
        {
            int         n   = toolTabs.Length - 1;
            ToolboxTab2 tab = toolTabs[i];

            ToolboxTab2[] a = new ToolboxTab2[n];
            for (int j = 0; j < toolTabs.Length; j++)
            {
                if (j < i)
                {
                    a[j] = toolTabs[j];
                }
                else if (j > i)
                {
                    a[j - 1]       = toolTabs[j];
                    a[j - 1].Index = j - 1;
                }
            }
            toolTabs = a;
            this.Controls.Remove(tab);
            AdjustTabPos(i - 1);
            Changed = true;
        }
 public LabelToolboxTabTitleCust(ToolboxTab2 tab)
     : base(tab)
 {
     sb = new SolidBrush(System.Drawing.SystemColors.ActiveCaptionText);
 }
示例#11
0
        public void AddToolboxItem(ToolboxItem toolboxItem, string category)
        {
            ToolboxTab2 tab = CreateTab(category, true, -1);

            tab.AddItem(toolboxItem);
        }
示例#12
0
        /// <summary>
        /// IDesignerHost is a service provided by DesignSurface
        /// </summary>
        /// <param name="toolboxItem"></param>
        /// <param name="category"></param>
        /// <param name="host"></param>
        public void AddLinkedToolboxItem(ToolboxItem toolboxItem, string category, IDesignerHost host)
        {
            ToolboxTab2 tab = CreateTab(category, true, -1);

            tab.AddItem(toolboxItem);
        }
示例#13
0
 public void ReadFromXmlFile(out string error)
 {
     if (_toolboxXml == null || _toolboxXml.Length == 0)
     {
         error = "ToolboxXml is empty";
         return;
     }
     if (!System.IO.File.Exists(_toolboxXml))
     {
         error = "ToolboxXml does not exist at " + _toolboxXml;
         return;
     }
     error = "";
     try
     {
         StreamReader sr  = new StreamReader(_toolboxXml);
         XmlDocument  xml = new XmlDocument();
         xml.LoadXml(sr.ReadToEnd());
         sr.Close();
         foreach (XmlNode nodeDoc in xml.ChildNodes)
         {
             if (string.CompareOrdinal(nodeDoc.Name, "Toolbox") == 0)
             {
                 foreach (XmlNode node in nodeDoc.ChildNodes)
                 {
                     if (string.CompareOrdinal(node.Name, "ToolboxTab") == 0)
                     {
                         XmlAttribute xa = node.Attributes["title"];
                         if (xa != null && xa.Value != null && xa.Value.Length > 0)
                         {
                             string name      = xa.Value;
                             bool   bReadOnly = true;
                             xa = node.Attributes["readonly"];
                             if (xa != null && xa.Value != null && xa.Value.Length > 0)
                             {
                                 bReadOnly = (string.Compare(xa.Value, "false", StringComparison.OrdinalIgnoreCase) != 0);
                             }
                             ToolboxTab2 tab = CreateTab(name, bReadOnly, -1);
                             foreach (XmlNode nd in node.ChildNodes)
                             {
                                 if (string.CompareOrdinal(nd.Name, "Item") == 0)
                                 {
                                     try
                                     {
                                         string s = nd.InnerText.Replace("\r", "").Replace("\n", "").Trim();
                                         Type   t = Type.GetType(s);
                                         if (t != null)
                                         {
                                             xToolboxItem xi;
                                             xa = nd.Attributes["Type"];
                                             if (xa != null)
                                             {
                                                 Type xt = Type.GetType(xa.Value);
                                                 xi = (xToolboxItem)Activator.CreateInstance(xt, new object[] { t });
                                             }
                                             else
                                             {
                                                 xi = new xToolboxItem(t);
                                             }
                                             xi.ReadNode(nd);
                                             tab.AddItem(xi);
                                         }
                                     }
                                     catch (Exception ee)
                                     {
                                         if (error.Length == 0)
                                         {
                                             error += ee.Message;
                                         }
                                         else
                                         {
                                             error += "\r\n" + ee.Message;
                                         }
                                     }
                                 }
                             }
                             tab.AdjustSize();
                         }
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         error = string.Format(CultureInfo.InvariantCulture, "{0}. \r\n{1}", e.Message, e.StackTrace);
     }
     OnResize(null);
     AdjustTabPos(0);
 }