示例#1
0
        private void Lb_MouseClick5(object sender, MouseEventArgs e)//扫描桌面
        {
            if (Sqlite.GetMenuAll() > 0)
            {
                MessageBox.Show(" Error : \r\n\t扫描功能只能用于:初始化后第一次使用! ", "ForceTer");
                return;
            }
            string desktop       = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            string publicdesktop = desktop.Substring(0, desktop.LastIndexOf("\\"));

            publicdesktop = publicdesktop.Substring(0, publicdesktop.LastIndexOf("\\")) + "\\Public\\Desktop";

            List <string> ls  = scanMenu(desktop);
            List <string> pls = scanMenu(publicdesktop);

            if (MessageBox.Show("共扫描到 < " + (ls.Count + pls.Count) + " > 个有效的快捷方式,是否要将他们加入到系统列表?", "ForceTer 3.0", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                List <Menu> lm = new List <Menu>();
                foreach (string a in ls)
                {
                    Menu m = new Menu();
                    m.Id       = Guid.NewGuid().ToString();
                    m.Filetype = "exe";
                    m.Icon     = m.Id + ".png";
                    WshShell     shell = new WshShell();
                    IWshShortcut iw    = (IWshShortcut)shell.CreateShortcut(desktop + "\\" + a);
                    m.Address = iw.TargetPath;
                    m.Name    = a.Substring(0, a.LastIndexOf("."));
                    m.Type    = 1;
                    m.Hot     = 1;
                    lm.Add(m);
                }
                foreach (string a in pls)
                {
                    Menu m = new Menu();
                    m.Id       = Guid.NewGuid().ToString();
                    m.Filetype = "exe";
                    m.Icon     = m.Id + ".png";
                    WshShell     shell = new WshShell();
                    IWshShortcut iw    = (IWshShortcut)shell.CreateShortcut(publicdesktop + "\\" + a);
                    m.Address = iw.TargetPath;
                    m.Name    = a.Substring(0, a.LastIndexOf("."));
                    m.Type    = 1;
                    m.Hot     = 1;
                    lm.Add(m);
                }
                foreach (Menu m in lm)
                {
                    Console.WriteLine(m.Address);

                    Files.SaveImageFile(m.Id + ".png", Icon.ExtractAssociatedIcon(m.Address).ToBitmap());
                    Sqlite.AddMenu(m);
                }
                RemoveLoad();
                ft.Show();
                ft.LoadMenu("热门应用", true);
                ft.ResetKey();
                Pb_MouseClick4(sender, e);
            }
        }
示例#2
0
        private void Lb_MouseClick(object sender, MouseEventArgs e)//点击了添加程序按钮
        {
            Menu m = new Menu();

            m.Id       = Guid.NewGuid().ToString();
            m.Filetype = this.Tag.ToString().ToLower();
            m.Icon     = m.Id + ".png";
            foreach (Control ctrl in this.Controls)
            {
                if ((string)ctrl.Tag == "address")
                {
                    if (ctrl.Text.Trim() != "")
                    {
                        m.Address = ctrl.Text;
                    }
                    else
                    {
                        return;
                    }
                }
                else if ((string)ctrl.Tag == "name")
                {
                    if (ctrl.Text.Trim() != "")
                    {
                        m.Name = ctrl.Text;
                    }
                    else
                    {
                        MessageBox.Show(" Error : \r\n\tEnter your project NAME !!!   名称为空! ", "ForceTer");
                        return;
                    }
                }
                else if ((string)ctrl.Tag == "type")
                {
                    int num = ((ComboBox)ctrl).SelectedIndex;
                    if (num != 0)
                    {
                        m.Type = ((ComboBox)ctrl).SelectedIndex;
                    }
                    else
                    {
                        MessageBox.Show(" Error : \r\n\tTYPE cannot be null !!!   分类选择错误! ", "ForceTer");
                        return;
                    }
                }
                else if ((string)ctrl.Tag == "hot")
                {
                    m.Hot = ((CheckBox)ctrl).CheckState == CheckState.Checked ? 1 : 0;
                }
            }
            if (Sqlite.SelectMenuName(m.Name))
            {
                MessageBox.Show(" Error : \r\n\tThe NAME already exists !!!   名字已经存在了! ", "ForceTer");
                return;
            }
            else
            {
                Files.SaveImageFile(m.Id + ".png", System.IO.File.Exists(icoAddress) ? Icon.ExtractAssociatedIcon(icoAddress).ToBitmap() : Properties.Resources.Project);
                Sqlite.AddMenu(m);
                RemoveLoad();
                if (MessageBox.Show(" Success : \r\n\t项目添加成功,点击确认按钮返回 ForceTer 3.0 ! ", "ForceTer", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    ft.Show();
                    this.Close();
                    ft.LoadMenu("热门应用", true);
                    ft.ResetKey();
                }
            }
        }