示例#1
0
        private void CreateTool()
        {
            tp          = new ToolPanel(sizeWidth, sizeHight, horNum, verNum);
            tp.Location = new Point(0, 0);
            this.Width  = tp.Width; this.Height = tp.Height;
            this.Controls.Add(tp);
            AppConfigSection appSection = (AppConfigSection)ConfigurationManager.GetSection("applications");

            foreach (AppKeyValueSetting app in appSection.KeyValues)
            {
                string path     = app.Path;
                string name     = app.Name;
                string position = app.Position;
                if (!File.Exists(path) && !Directory.Exists(path))
                {
                    continue;
                }
                Image    img = GetFileImage(path);
                int      x = 0; int y = 0;
                string   numString = position;
                string[] tmpArray  = numString.Split(',');
                if (tmpArray.Length != 2)
                {
                    continue;
                }
                bool ret = int.TryParse(tmpArray[1], out x);
                if (!ret)
                {
                    continue;
                }
                ret = int.TryParse(tmpArray[0], out y);
                if (!ret)
                {
                    continue;
                }
                tp.AddButton(x, y, name, path, img);
            }


            int SH = (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2;
            int SW = (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2;

            this.Location       = new Point(SW, SH);
            tp.OnDropFileEvent += new ToolPanel.DropFileDelegate(tp_OnDrag);
            tp.OnDelEvent      += new ToolPanel.DelDelegate(tp_OnDelEvent);
            tp.OnClickEvent    += new ToolPanel.ClickDelegate(tp_OnClickEvent);
        }