Exemple #1
0
        private void tp_OnDelEvent(string name)
        {
            Configuration    config  = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            AppConfigSection Section = config.GetSection("applications") as AppConfigSection;

            Section.KeyValues.Remove(name);
            config.Save();
            ConfigurationManager.RefreshSection("applications");
        }
Exemple #2
0
        public const uint SHGFI_LARGEICON = 0x000000000; // get large icon
        private void AddButton(string name, string path, string position)
        {
            Configuration      config   = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            AppConfigSection   Section  = config.GetSection("applications") as AppConfigSection;
            AppKeyValueSetting keyvalue = new AppKeyValueSetting();

            keyvalue.Name = name; keyvalue.Path = path; keyvalue.Position = position;
            Section.KeyValues.Add(keyvalue);
            config.Save();
            ConfigurationManager.RefreshSection("applications");
        }
Exemple #3
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);
        }