예제 #1
0
        private void AddAppToList(ExeApp app)
        {
            var item    = new ListViewItem(app.Name);
            var appPath = app.ExecutablePath;

            item.Tag = app;

            //get icon
            using (var thumb = IconHelper.ExtractIconForPath(appPath, new Size((int)(32 * _dpiF), (int)(32 * _dpiF)), app.IsGesturingEnabled))
            {
                var imgIndex = imglistAppIcons.Images.IndexOfKey(appPath);
                if (imgIndex < 0)
                {
                    imglistAppIcons.Images.Add(appPath, thumb);
                }
                else
                {
                    imglistAppIcons.Images[imgIndex] = IconHelper.ExtractIconForPath(appPath, new Size((int)(32 * _dpiF), (int)(32 * _dpiF)), app.IsGesturingEnabled);
                }
            }

            item.ImageKey = appPath;
            if (!app.IsGesturingEnabled)
            {
                item.ForeColor = Color.Firebrick;
            }

            if (!File.Exists(appPath))
            {
                item.Text     += "(不存在)";
                item.ForeColor = Color.Gray;
            }

            listApps.Items.Add(item);
        }
예제 #2
0
        private void ToggleSelectedAppGesturingEnabled()
        {
            var app = GetSelectedAppOrGlobal();

            if (app == null)
            {
                return;
            }

            app.IsGesturingEnabled = !app.IsGesturingEnabled;
            var item = listApps.SelectedItems[0];

            var exeApp = app as ExeApp;

            if (exeApp == null) //global
            {
                item.ImageKey  = app.IsGesturingEnabled ? "icon" : "icon_bw";
                item.ForeColor = app.IsGesturingEnabled ? Color.DodgerBlue : Color.Firebrick;
            }
            else //exeApp
            {
                var imgIndex = imglistAppIcons.Images.IndexOfKey(exeApp.ExecutablePath);
                imglistAppIcons.Images[imgIndex] = IconHelper.ExtractIconForPath(exeApp.ExecutablePath, new Size((int)(32 * _dpiF), (int)(32 * _dpiF)), exeApp.IsGesturingEnabled);

                item.ForeColor = exeApp.IsGesturingEnabled ? Color.Black : Color.Firebrick;
                //item.Group = listApps.Groups[exeApp.IsGesturingEnabled ? "enabled" : "disabled"];
            }

            //更新“启用作用于xxx”中的小图片
            pictureSelectedApp.Image = imglistAppIcons.Images[item.ImageKey];


            //阻止引发事件,只有用户点击“启用”的时候才发布事件
            check_gesturingDisabled.CheckedChanged -= check_gesturingEnabled_CheckedChanged;
            check_gesturingDisabled.Checked         = !app.IsGesturingEnabled;
            check_gesturingDisabled.CheckedChanged += check_gesturingEnabled_CheckedChanged;


//            if (!listGestureIntents.Enabled && listGestureIntents.SelectedItems.Count == 1)
//            {
//                listGestureIntents.SelectedItems[0].Selected = false;
//                UnloadCommand();
//            }
        }
예제 #3
0
 private void LoadIcon(string path)
 {
     pictureSelectedAppIcon.Image = IconHelper.ExtractIconForPath(path, new Size(48, 48), true, 0);
 }