コード例 #1
0
ファイル: FloatingToolBox.cs プロジェクト: orf53975/src
 /// <summary>
 /// Add a ToolBoxItem collection to the collection.
 /// </summary>
 public void AddRange(ToolBoxItemCollection items)
 {
     foreach (ToolBoxItem item in items)
     {
         this.Add(item);
     }
 }
コード例 #2
0
ファイル: FloatingToolBox.cs プロジェクト: orf53975/src
        public FloatingToolBox(Form owner)
        {
            _owner = owner;
            // Initializing
            _fWindow = new FloatingWindow();
            float deg = (float)(Math.Asin(15d / 25d) * 180 / Math.PI);

            _iconRect = new Rectangle(0, -10, 50, 50);
            _toolTip  = new Ai.Control.ToolTip();
            _items    = new ToolBoxItemCollection(this);
            _sf       = new StringFormat();
            _hosts    = new List <ItemHost>();
            // Setting up floating window.
            _fWindow.Height        = 45;
            _fWindow.ShowInTaskbar = false;
            _fWindow.Active        = false;
            _fWindow.Modal         = false;
            _fWindow.Selectable    = false;
            _fWindow.Owner         = _owner;
            _fWindow.Paint        += _Paint;
            _fWindow.MouseMove    += _MouseMove;
            _fWindow.MouseDown    += _MouseDown;
            _fWindow.MouseUp      += _MouseUp;
            _fWindow.MouseLeave   += _MouseLeave;
            _fWindow.MouseEnter   += _MouseEnter;
            _fWindow.KeyDown      += _KeyDown;
            // Setting up tooltip
            _toolTip.AnimationSpeed = 20;
            _toolTip.Draw          += tooltip_Draw;
            _toolTip.Popup         += tooltip_Popup;
            // Setting up string format.
            _sf.Alignment     = StringAlignment.Center;
            _sf.LineAlignment = StringAlignment.Center;
            // Setting up items.
            _items.AfterClear  += _items_AfterClear;
            _items.AfterInsert += _items_AfterInsert;
            _items.AfterRemove += _items_AfterRemove;
            measureWindow();
        }
コード例 #3
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);
                }
            }
        }