Ejemplo n.º 1
0
        private void Grid_Drop(object sender, DragEventArgs e)
        {
            string fileName = "";

            try
            {
                fileName = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString();
            }
            catch
            {
                ShowMassage("无法识别该文件。");
                return;
            }

            //向listbox中添加
            //当前最大ID
            foreach (var item in AllControl.hotpathId.Keys)
            {
                int i = int.Parse(item);
                if (AllControl.canUseMinID <= i)
                {
                    AllControl.canUseMinID = i + 1;
                }
            }
            int index = AllControl.canUseMinID;

            AllControl.AddHotPathItem(index.ToString(), index + "-name", fileName);
            AddItemInListBox(AllControl.hotpathId[index.ToString()]);
        }
Ejemplo n.º 2
0
 protected override void OnSourceInitialized(EventArgs e)
 {
     base.OnSourceInitialized(e);
     //注册快捷键设置
     AllControl.register = new Register(this);
     AllControl.ReadConfig();
     ShowWindow(false);
 }
Ejemplo n.º 3
0
        private void cbAuto_Checked(object sender, RoutedEventArgs e)
        {
            bool isChecked = (bool)cbAuto.IsChecked;
            //完整路径
            string path = Process.GetCurrentProcess().MainModule.FileName;
            //文件名
            string name = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString();

            bool isSuccess;

            if (isChecked) //设置开机自启动
            {
                AllControl.isAutoStartUp = true;
                isSuccess = AllControl.CreateStartup(name, path);
                //如果操作失败则重新设置按钮状态
                if (isSuccess)
                {
                    cbAuto.IsChecked = true;
                }
                else
                {
                    cbAuto.IsChecked = false;
                }
            }
            else //取消开机自启动
            {
                AllControl.isAutoStartUp = false;
                // 获取全局 开始 文件夹位置
                //string directory = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartup);
                // 获取当前登录用户的 开始 文件夹位置
                string directory    = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
                string shortcutPath = Path.Combine(directory, string.Format("{0}.lnk", name));
                isSuccess = AllControl.DestoryFile(shortcutPath);
            }

            if (isSuccess)
            {
                ShowMassage("操作成功。");
            }
            else
            {
                ShowMassage("操作失败");
            }
        }
Ejemplo n.º 4
0
        //监听组合键返回了什么信息
        private void LockKeyManager_GetCombineKeyEvent(KeysInfo keysInfo)
        {
            //按下ESC键注销该控件的快捷键
            if (keysInfo.key == 27)
            {
                uint removeResult = AllControl.RemoveHotKeyItem(AllControl.CurrControl.Name);
                if (removeResult == 1)
                {
                    ShowMassage("注销成功。");
                }
                else
                {
                    ShowMassage("注销失败。");
                }
                ((TextBox)AllControl.CurrControl).Text = "";
                return;
            }

            //准备注册热键
            if (keysInfo.key == 0 || keysInfo.lockKey.Count == 0)
            {
                ShowMassage("缺少实体键或功能键");
                return;
            }
            if (keysInfo.isWin)
            {
                ShowMassage("不能包含Win键。");
                return;
            }

            ((TextBox)AllControl.CurrControl).Text = keysInfo.keyName;
            // 注册热键
            uint result = AllControl.AddHotkeyItem(AllControl.CurrControl.Name, keysInfo.key, keysInfo.keyFlag, keysInfo.keyName);

            if (result == 0)
            {
                ShowMassage("注册失败。");
            }
            else
            {
                ShowMassage("注册成功");
            }
        }
Ejemplo n.º 5
0
 //移除控件
 public void removeListBoxItem(HotPathItem item)
 {
     lbItem.Items.Remove(item);
     AllControl.RemoveHotPathItem(item.txtID.Text);
 }
Ejemplo n.º 6
0
 private void SettingWindow_Closed(object sender, EventArgs e)
 {
     WindowCenter.SettingWindow = null;
     AllControl.SaveConfig();
 }
Ejemplo n.º 7
0
 private static void Setting(object sender, EventArgs e)
 {
     AllControl.OpenSettingWindow();
 }
Ejemplo n.º 8
0
 private void MainWindow_Closed(object sender, EventArgs e)
 {
     AllControl.SaveConfig();
 }