예제 #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);
        }
        /// <summary>
        /// 判断是否在当前的应用程序上禁用的鼠标手势
        /// 如果应用程序没有添加到记录中,则检查全局手是否可用
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public bool IsGesturingEnabledForContext(GestureContext context, out ExeApp foundApp)
        {
            foundApp = GetExeAppByContext(context);

            return foundApp != null ?
                foundApp.IsGesturingEnabled : IntentStore.GlobalApp.IsGesturingEnabled;
        }
예제 #3
0
        public EditAppForm(ExeApp editingApp, IGestureIntentStore intentStore)
            : this(intentStore)
        {
            _isEditingMode = true;

            _editingApp = editingApp;

            Text = "修改 \"" + editingApp.Name + "\"";
            AppName = txtSelectedAppNae.Text = editingApp.Name;
            AppPath = lnkSelectedAppPath.Text = editingApp.ExecutablePath;

            groupSelectedApp.Visible = true;
            btnOk.Enabled = true;

            toolTip1.SetToolTip(lnkSelectedAppPath, editingApp.ExecutablePath);


            LoadIcon(editingApp.ExecutablePath);

            if (!editingApp.AppExists())
            {
                ShowErrorMsg("该应用程序不存在,请确定它的位置");
            }

        }
예제 #4
0
        //private Dictionary<uint, string> _procFileNameDict = new Dictionary<uint, string>(64);

        /// <summary>
        /// Native下以进程文件名为key查找。
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override ExeApp GetExeAppByContext(GestureContext context)
        {
            //全屏模式下禁用

            string str;
            ExeApp found = null;

            var procId = context.ProcId;//Native.GetActiveProcessId();

            Debug.WriteLine("procId=" + procId);


            //if (!_procFileNameDict.TryGetValue(procId, out str))
            //{
            str = Native.GetProcessFile(procId);
            //_procFileNameDict[procId] = str;
            // }

            Debug.WriteLine("Image=" + str);
            if (str == null)
            {
                return(null);
            }

            IntentStore.TryGetExeApp(str, out found);

            return(found);
        }
예제 #5
0
        /// <summary>
        /// 判断是否在当前的应用程序上禁用的鼠标手势
        /// 如果应用程序没有添加到记录中,则检查全局手是否可用
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public bool IsGesturingEnabledForContext(GestureContext context, out ExeApp foundApp)
        {
            foundApp = GetExeAppByContext(context);

            return(foundApp != null ?
                   foundApp.IsGesturingEnabled : IntentStore.GlobalApp.IsGesturingEnabled);
        }
예제 #6
0
        public OrderableExeApp(ExeApp from)
        {
            var t = from.GetType();

            foreach (var fieldInf in t.GetFields())
            {
                fieldInf.SetValue(this, fieldInf.GetValue(from));
            }
            foreach (var propInf in t.GetProperties())
            {
                propInf.SetValue(this, propInf.GetValue(from, null), null);
            }
        }
        public GestureIntent Find(Gesture gesture, ExeApp inApp)
        {
            GestureIntent found;

            if (inApp != null)
            {
                found = inApp.Find(gesture);
                if (found == null && inApp.InheritGlobalGestures) //是否继承了全局手势
                {
                    found = IntentStore.GlobalApp.Find(gesture);
                }
            }
            else
            {
                found = IntentStore.GlobalApp.Find(gesture);
            }

            return found;
        }
예제 #8
0
        public GestureIntent Find(Gesture gesture, ExeApp inApp)
        {
            GestureIntent found;

            if (inApp != null)
            {
                found = inApp.Find(gesture);
                if (found == null && inApp.InheritGlobalGestures) //是否继承了全局手势
                {
                    found = IntentStore.GlobalApp.Find(gesture);
                }
            }
            else
            {
                found = IntentStore.GlobalApp.Find(gesture);
            }

            return(found);
        }
        /// <summary>
        /// Native下以进程文件名为key查找。
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override ExeApp GetExeAppByContext(GestureContext context)
        {
            //全屏模式下禁用

            string str;
            ExeApp found = null;

            var procId = Native.GetActiveProcessId();


            if (!_procFileNameDict.TryGetValue(procId, out str))
            {
                str = Native.GetProcessFile(procId);
                _procFileNameDict[procId] = str;
            }

            IntentStore.TryGetExeApp(str, out found);

            return(found);
        }
예제 #10
0
        private void HighlightAppInList(ExeApp app)
        {
            ListViewItem ensureVisiblItem = null;

            foreach (ListViewItem item in listApps.Items)
            {
                if (item.Index != 0 && app.ExecutablePath.Equals((item.Tag as ExeApp).ExecutablePath))
                {
                    item.Selected    = true;
                    ensureVisiblItem = item;
                    break;
                }
            }

            listApps.Focus();
            if (ensureVisiblItem != null)
            {
                listApps.EnsureVisible(ensureVisiblItem.Index);
            }
        }
예제 #11
0
        public EditAppForm(ExeApp editingApp, IGestureIntentStore intentStore)
            : this(intentStore)
        {
            _isEditingMode = true;

            _editingApp = editingApp;

            Text    = "修改 \"" + editingApp.Name + "\"";
            AppName = txtSelectedAppNae.Text = editingApp.Name;
            AppPath = lnkSelectedAppPath.Text = editingApp.ExecutablePath;

            groupSelectedApp.Visible = true;
            btnOk.Enabled            = true;

            toolTip1.SetToolTip(lnkSelectedAppPath, editingApp.ExecutablePath);


            LoadIcon(editingApp.ExecutablePath);

            if (!editingApp.AppExists())
            {
                ShowErrorMsg("该应用程序不存在,请确定它的位置");
            }
        }
예제 #12
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);
        }
예제 #13
0
 public void Add(ExeApp app)
 {
     app.ExecutablePath = app.ExecutablePath.ToLower();
     Apps.Add(app.ExecutablePath, app);
 }
예제 #14
0
 public bool TryGetExeApp(string key, out ExeApp found)
 {
     return Apps.TryGetValue(key.ToLower(), out found);
 }
예제 #15
0
 public void Remove(ExeApp app)
 {
     Remove(app.ExecutablePath.ToLower());
 }
예제 #16
0
 public void Add(ExeApp app)
 {
     ExeAppsRegistry.Add(app.ExecutablePath, app);
 }
예제 #17
0
 public void Remove(ExeApp app)
 {
     Remove(app.ExecutablePath);
 }
예제 #18
0
 public bool TryGetExeApp(string key, out ExeApp found)
 {
     return(ExeAppsRegistry.TryGetValue(key, out found));
 }
예제 #19
0
        private void HighlightAppInList(ExeApp app)
        {
            ListViewItem ensureVisiblItem = null;

            foreach (ListViewItem item in listApps.Items)
            {
                if (item.Index != 0 && app.ExecutablePath.Equals((item.Tag as ExeApp).ExecutablePath))
                {
                    item.Selected = true;
                    ensureVisiblItem = item;
                    break;
                }
            }

            listApps.Focus();
            if (ensureVisiblItem != null) listApps.EnsureVisible(ensureVisiblItem.Index);
        }
예제 #20
0
 public bool TryGetExeApp(string key, out ExeApp found)
 {
     return(Apps.TryGetValue(key.ToLower(), out found));
 }
예제 #21
0
 public void Add(ExeApp app)
 {
     app.ExecutablePath = app.ExecutablePath.ToLower();
     Apps.Add(app.ExecutablePath, app);
 }
예제 #22
0
 public void Remove(ExeApp app)
 {
     Remove(app.ExecutablePath.ToLower());
 }
예제 #23
0
 public static bool AppExists(this ExeApp app)
 {
     return(File.Exists(app.ExecutablePath));
 }