示例#1
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();
        }
示例#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 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);
 }