コード例 #1
0
        private Button buildBtn(IWindowEntry win, int setElementWidth, int setElementMargin)
        {
            // http://www.bubuko.com/infodetail-2282119.html
            // https://blog.csdn.net/honantic/article/details/48781543

            //https://bbs.csdn.net/topics/392094061
            //https://social.msdn.microsoft.com/Forums/vstudio/en-US/99856840-f8ef-4547-9150-c4c46ec2f3df/need-dashed-focus-box?forum=wpf

            Button btn = new Button();

            btn.Width  = btn.Height = setElementWidth;
            btn.Margin = new Thickness(setElementMargin, 0, setElementMargin, 0);
            var backImg = CoreSearchResult.LoadIcon(win);

            if (backImg == null && !string.IsNullOrEmpty(win.ProcessName))
            {
                btn.Background = GoToWindow.Plugins.Core.Utils.IconLoader.DrawText(win.ProcessName, null, System.Drawing.Color.White, System.Drawing.Color.Transparent);
            }
            else
            {
                btn.Background = new ImageBrush(backImg);
            }
            btn.BorderBrush       = null;
            btn.GotFocus         += Btn_GotFocus;
            btn.FocusVisualStyle  = null;
            btn.PreviewMouseDown += Btn_PreviewMouseDown;
            btn.Tag = win;
            SetHotkey(win);
            return(btn);
        }
コード例 #2
0
 internal void Show(IWindowEntry windowEntry, Action onExePathWinUpdate)
 {
     mEntity   = new TbExecutablePathEntity(windowEntry.ProcessName, windowEntry.ExecutablePath);
     mCallback = onExePathWinUpdate;
     Show();
     ShowDialogAndUpdate(mEntity, true);
 }
コード例 #3
0
        public void Hide(bool hideIfPending, bool requested, MainWindow target)
        {
            if (!requested && Settings.Default.KeepOpenOnLostFocus)
            {
                Log.Debug("Ignoring hide on focus out because KeepOpenOnLostFocus is active.");
                return;
            }

            lock (_lock)
            {
                if (_mainWindow == null || !ReferenceEquals(_mainWindow, target))
                {
                    Log.Debug("Ignore hide request because window is already hidden.");
                    return;
                }

                try
                {
                    _mainWindow.Close();
                    Log.Debug("Window Hidden");
                }
                catch (InvalidOperationException exc)
                {
                    Log.Warn("Window is still closing", exc);
                }
                catch (Exception exc)
                {
                    Log.Error("Failed hiding window.", exc);
                }

                _mainWindow      = null;
                _mainViewModel   = null;
                _mainWindowEntry = null;
            }
        }
コード例 #4
0
		public bool IsSameWindow(IWindowEntry other)
		{
			if (other == null)
				return false;

			return ProcessId == other.ProcessId && HWnd == other.HWnd;
		}
コード例 #5
0
        public static void Del(IWindowEntry win)
        {
            TbHideWin db = new TbHideWin();

            db.Open();
            db.ExeSQL(string.Format("delete from {0} where name='{1}' and title='{2}'", db.TB_HIDEWIN, win.ProcessName, win.Title));
            db.Close();
        }
コード例 #6
0
 internal void Show(IWindowEntry win)
 {
     mWin          = win;
     BoxInfo.Text  = win.ProcessName + "     快捷键:" + (Key)win.hotKey + "\n" + win.Title;
     BoxInfo.Text += "\n按alt+tab,松开tab,然后按快捷键,即可切换到对应的窗口";
     BoxInfo.Text += "\n按Delete,删除当前快捷键";
     Show();
 }
コード例 #7
0
 private void SaveHotKey(IWindowEntry win, Key key)
 {
     if (win.hotKey != (int)key)
     {
         win.hotKey = (int)key;
         Database.updateHotkey(win);
         //win.onHotkeyUpdate();
     }
 }
コード例 #8
0
 private void SaveHotKey(IWindowEntry win, Key key)
 {
     if (win.hotKey != (int)key)
     {
         win.hotKey = (int)key;
         TbHotkey.updateHotkey(win, string.IsNullOrEmpty(win.ExecutablePath) ? false : true);
         mCallback();
     }
 }
コード例 #9
0
        private static bool IsKnownException(IWindowEntry window)
        {
            if (window.ProcessName == "Fiddler" && window.Title == "SSFiddlerMsgWin")
            {
                return(true);
            }

            return(false);
        }
コード例 #10
0
ファイル: WindowEntry.cs プロジェクト: rog1039/GoToWindow
        public bool IsSameWindow(IWindowEntry other)
        {
            if (other == null)
            {
                return(false);
            }

            return(ProcessId == other.ProcessId && HWnd == other.HWnd);
        }
コード例 #11
0
        public static void Add(IWindowEntry win)
        {
            Del(win);
            TbHideWin db = new TbHideWin();

            db.Open();
            db.ExeSQL(string.Format("insert into {0} (name,title) values('{1}','{2}')", db.TB_HIDEWIN, win.ProcessName, win.Title));
            db.Close();
        }
コード例 #12
0
 internal void Show(IWindowEntry win, Action onHideWinUpdate)
 {
     Show();
     if (MessageBox.Show(String.Format("确定隐藏 \n程序名:{0}\n标题:{1} \n    窗口吗?", win.ProcessName, win.Title), "隐藏窗口", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
     {
         TbHideWin.Add(win);
         onHideWinUpdate();
         Close();
     }
 }
コード例 #13
0
 internal void Show(IWindowEntry win, Action callback)
 {
     mWin          = win;
     mCallback     = callback;
     BoxInfo.Text  = "请直接输入快捷键\n";
     BoxInfo.Text += "\n说明:按alt+tab,松开tab,然后按快捷键,即可切换到对应的窗口";
     BoxInfo.Text += "\n\n当前信息:" + win.ProcessName + "     快捷键:" + (Key)win.hotKey + "   " + win.Title;
     BoxInfo.Text += "\n\n按Delete,删除当前快捷键\n按F11进入详细设置";
     Show();
 }
コード例 #14
0
        public static BitmapFrame LoadIcon(IWindowEntry win)
        {
            //string executable;

            //using (var process = Process.GetProcessById((int)win.ProcessId))
            //{
            //    executable = process.GetExecutablePath();
            //}

            return(IconLoader.LoadIcon(win.IconHandle, win.ExecutablePath));
        }
コード例 #15
0
        private void SetHotkey(IWindowEntry win)
        {
            bool find = false;

            foreach (var item in mListHotkey)
            {
                if (win.ProcessName.Equals(item.name))
                {
                    win.hotKey = item.key;
                    find       = true;
                    break;
                }
            }
            if (!find)
            {
                win.hotKey = 0;
            }
        }
コード例 #16
0
        public void Show()
        {
            lock (_lock)
            {
                if (_state == GoToWindowState.Shown)
                {
                    Log.Debug("Sending Tab Again to Main Window.");
                    _mainWindow.ShortcutAgain();
                    return;
                }

                if (_state != GoToWindowState.Hidden)
                {
                    return;
                }

                Log.Debug("Showing Main Window.");
                _state = GoToWindowState.Showing;
            }

            if (Showing != null)
            {
                Showing(this, new EventArgs());
            }

            SetAvailableWindowSize(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight);
            _mainWindow.Left = SystemParameters.PrimaryScreenWidth / 2f - _mainViewModel.AvailableWindowWidth / 2f;
            _mainWindow.Top  = SystemParameters.PrimaryScreenHeight / 2f - (_mainViewModel.AvailableWindowHeight + 56) / 2f;
            _mainWindow.Show();

            if (_mainWindowEntry == null)
            {
                var interopHelper = new WindowInteropHelper(_mainWindow);
                _mainWindowEntry = WindowEntryFactory.Create(interopHelper.Handle);

                Log.DebugFormat("GoToWindow main window created with hWnd {0}", _mainWindowEntry.HWnd);
            }

            _mainWindow.SetFocus();
            _mainWindowEntry.Focus();

            Application.Current.Dispatcher.InvokeAsync(LoadViewModel, DispatcherPriority.Background);
        }
コード例 #17
0
        public static void updateHotkey(IWindowEntry win)
        {
            Database db = new Database();

            db.Open();
            using (var dr = db.ExeQuerySQL(string.Format("select key from {0} where name='{1}'", db.TB_HOTKEY, win.ProcessName)))
            {
                // 把原来先设置好的快捷键取消
                db.ExeSQL(String.Format("update {0} set key=0 where key={1}", db.TB_HOTKEY, win.hotKey));
                if (dr.Read())
                {
                    db.ExeSQL(String.Format("update {0} set key={1} where name='{2}'", db.TB_HOTKEY, win.hotKey, win.ProcessName));
                }
                else
                {
                    db.ExeSQL(string.Format("insert into {0} (name,key) values('{1}',{2})", db.TB_HOTKEY, win.ProcessName, win.hotKey));
                }
            }
            db.Close();
        }
コード例 #18
0
ファイル: GoToWindowContext.cs プロジェクト: hanw3/GoToWindow
        public void Show()
        {
            lock (_lock)
            {
                if (_mainWindow != null)
                {
                    Log.Debug("Sending Tab Again to Main Window.");
                    _mainWindow.ShortcutAgain();
                    return;
                }

                _mainViewModel = new MainViewModel();

                SetAvailableWindowSize(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight);

                _mainWindow = new MainWindow {
                    DataContext = _mainViewModel
                };
                _mainWindow.Closing  += _mainWindow_Closing;
                _mainViewModel.Close += _mainViewModel_Close;

                Showing?.Invoke(this, new EventArgs());

                _mainWindow.Left  = SystemParameters.PrimaryScreenWidth / 2f - _mainViewModel.AvailableWindowWidth / 2f;
                _mainWindow.Top   = SystemParameters.PrimaryScreenHeight / 2f - (_mainViewModel.AvailableWindowHeight + 56) / 2f;
                _mainWindow.Width = _mainViewModel.AvailableWindowWidth;

                _mainWindow.Show();

                var interopHelper = new WindowInteropHelper(_mainWindow);
                _mainWindowEntry = WindowEntryFactory.Create(interopHelper.Handle);

                Log.DebugFormat("GoToWindow main window created with hWnd {0}", _mainWindowEntry.HWnd);

                _mainWindow.SetFocus();
                _mainWindowEntry.Focus();

                Application.Current.Dispatcher.InvokeAsync(LoadViewModel, DispatcherPriority.Input);
            }
        }
コード例 #19
0
        private Button buildBtn(IWindowEntry win, int setElementWidth, int setElementMargin)
        {
            // http://www.bubuko.com/infodetail-2282119.html
            // https://blog.csdn.net/honantic/article/details/48781543

            //https://bbs.csdn.net/topics/392094061
            //https://social.msdn.microsoft.com/Forums/vstudio/en-US/99856840-f8ef-4547-9150-c4c46ec2f3df/need-dashed-focus-box?forum=wpf

            Button btn = new Button();

            btn.Width             = btn.Height = setElementWidth;
            btn.Margin            = new Thickness(setElementMargin, 0, setElementMargin, 0);
            btn.Background        = new ImageBrush(CoreSearchResult.LoadIcon(win));
            btn.BorderBrush       = null;
            btn.GotFocus         += Btn_GotFocus;
            btn.FocusVisualStyle  = (Style)FindResource("newFocusStyle");
            btn.PreviewMouseDown += Btn_PreviewMouseDown;
            btn.Tag = win;
            //win.onHotkeyUpdate = OnHotkeyUpdateEvent;
            SetHotkey(win);
            return(btn);
        }
コード例 #20
0
        private static void UpdateProcessName(IWindowEntry window)
        {
            window.ProcessName = WmiProcessWatcher.GetProcessName(window.ProcessId, () =>
            {
                using (var process = Process.GetProcessById((int)window.ProcessId))
                {
                    //TODO: Windows 10 App Icons

                    /*
                     * try
                     * {
                     *      window.ProcessFileName = process.MainModule.FileName;
                     * }
                     * catch (Exception ex)
                     * {
                     *      Log.Warn("Could not get the executable name of the process " + window, ex);
                     * }
                     * */
                    return(process.ProcessName);
                }
            });
        }
コード例 #21
0
	    private static bool IsKnownException(IWindowEntry window)
	    {
		    if (window.ProcessName == "Fiddler" && window.Title == "SSFiddlerMsgWin")
			    return true;

		    return false;
	    }
コード例 #22
0
 private void switchToWin(IWindowEntry tag)
 {
     WindowToForeground.ForceWindowToForeground(tag.HWnd);
     HideWin();
 }
コード例 #23
0
	    public CoreSearchResult(IWindowEntry entry, Func<UserControl> viewCtor)
			: base(viewCtor)
		{
			_entry = entry;
		}
コード例 #24
0
ファイル: CorePlugin.cs プロジェクト: vkhurana/GoToWindow
 private static ISearchResult ConvertWindowEntryToSearchResult(IWindowEntry entry)
 {
     return(new CoreSearchResult(entry, () => new BasicListEntry()));
 }
コード例 #25
0
 public CoreSearchResult(IWindowEntry entry, Func <UserControl> viewCtor)
     : base(viewCtor)
 {
     _entry = entry;
 }
コード例 #26
0
 private void showWin(IWindowEntry tag)
 {
     ShowWindow(tag.HWnd, 1);
     SwitchToThisWindow(tag.HWnd, true);
     HideWin();
 }
コード例 #27
0
 internal void Show(IWindowEntry win, Action callback)
 {
     mCallback = callback;
     Show();
 }
コード例 #28
0
        private void AssertExists(IList <IWindowEntry> windows, IWindowEntry expected)
        {
            var containsExpected = windows.Any(expected.IsSameWindow);

            Assert.IsTrue(containsExpected, String.Format("Expected window {0}.\r\nWindows List:\r\n{1}", expected, String.Join("\r\n", windows)));
        }
コード例 #29
0
		public void Show()
		{
			lock (_lock)
			{
				if (_state == GoToWindowState.Shown)
				{
					Log.Debug("Sending Tab Again to Main Window.");
					_mainWindow.ShortcutAgain();
					return;
				}

				if (_state != GoToWindowState.Hidden)
					return;

				Log.Debug("Showing Main Window.");
				_state = GoToWindowState.Showing;
			}

			if (Showing != null)
				Showing(this, new EventArgs());

			SetAvailableWindowSize(SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight);
			_mainWindow.Left = SystemParameters.PrimaryScreenWidth/2f - _mainViewModel.AvailableWindowWidth/2f;
			_mainWindow.Top = SystemParameters.PrimaryScreenHeight/2f - (_mainViewModel.AvailableWindowHeight + 56)/2f;
			_mainWindow.Show();

			if (_mainWindowEntry == null)
			{
				var interopHelper = new WindowInteropHelper(_mainWindow);
				_mainWindowEntry = WindowEntryFactory.Create(interopHelper.Handle);

				Log.DebugFormat("GoToWindow main window created with hWnd {0}", _mainWindowEntry.HWnd);
			}

			_mainWindow.SetFocus();
			_mainWindowEntry.Focus();

			Application.Current.Dispatcher.InvokeAsync(LoadViewModel, DispatcherPriority.Background);
		}
コード例 #30
0
	    private static void UpdateProcessName(IWindowEntry window)
	    {
		    window.ProcessName = WmiProcessWatcher.GetProcessName(window.ProcessId, () =>
		    {
			    using (var process = Process.GetProcessById((int) window.ProcessId))
			    {
					//TODO: Windows 10 App Icons
					/*
				    try
				    {
						window.ProcessFileName = process.MainModule.FileName;
				    }
				    catch (Exception ex)
				    {
						Log.Warn("Could not get the executable name of the process " + window, ex);
				    }
					 * */
				    return process.ProcessName;
			    }
		    });
	    }
コード例 #31
0
        private void AssertExists(IList <IWindowEntry> windows, IWindowEntry expected)
        {
            var containsExpected = windows.Any(expected.IsSameWindow);

            Assert.IsTrue(containsExpected, $"Expected window {expected}.\r\nWindows List:\r\n{string.Join("\r\n", windows)}");
        }
コード例 #32
0
		private static ISearchResult ConvertWindowEntryToSearchResult(IWindowEntry entry)
		{
			return new CoreSearchResult(entry, () => new BasicListEntry());
		}
コード例 #33
0
 public static void CloseWindow(IWindowEntry win)
 {
     // https://blog.csdn.net/hellokandy/article/details/53408799
     SendMessageTimeout(win.HWnd, WM_CLOSE, 0, 0, 0, 50, out IntPtr iconHandle);
 }
コード例 #34
0
ファイル: TbHotkey.cs プロジェクト: advx9600/GoToWindow
        public static void updateHotkey(IWindowEntry win, bool isUpdatePath)
        {
            var entity = new TbHotKeyEntity(win.ProcessName, win.hotKey, win.ExecutablePath);

            updateHotkey(entity, isUpdatePath);
        }
コード例 #35
0
		private void AssertExists(IList<IWindowEntry> windows, IWindowEntry expected)
		{
			var containsExpected = windows.Any(expected.IsSameWindow);
			Assert.IsTrue(containsExpected, String.Format("Expected window {0}.\r\nWindows List:\r\n{1}", expected, String.Join("\r\n", windows)));
		}