private void InvokeRoutine(Keys key, bool isKeyDown) { Debug.WriteLine($"InvokeRoutine: key={key},down={isKeyDown}"); if (isKeyDown) { switch (key) { case Keys.Enter: PipeServerManager.SendMessage(PipeMessages.RunAndClose); break; } } else { switch (key) { case Keys.Up: case Keys.Down: case Keys.Left: case Keys.Right: PipeServerManager.SendMessage(PipeMessages.Switch); break; case Keys.Space: PipeServerManager.SendMessage(PipeMessages.Toggle); break; case Keys.Escape: PipeServerManager.SendMessage(PipeMessages.Close); break; } } }
public void Start() { if (IsRunning) { return; } IsRunning = true; new Task(() => { var last = string.Empty; while (IsRunning) { Thread.Sleep(500); if (NativeMethods.QuickLook.GetFocusedWindowType() == NativeMethods.QuickLook.FocusedWindowType.Invalid) { continue; } var path = NativeMethods.QuickLook.GetCurrentSelection(); if (IsRunning && last != path) { last = path; PipeServerManager.SendMessage(PipeMessages.Switch, path); } } }).Start(); }
private bool EnsureFirstInstance(string[] args) { _isRunning = new Mutex(true, "QuickLook.App.Mutex", out bool isFirst); if (isFirst) { return(true); } // second instance: preview this file if (args.Any() && (Directory.Exists(args.First()) || File.Exists(args.First()))) { PipeServerManager.SendMessage(PipeMessages.Toggle, args.First()); } //add by gh else if (args.Contains("/setvisible")) { SettingHelper.Set("Visible", true); MessageBox.Show(TranslationHelper.Get("APP_SECOND_TEXT_HIDE"), TranslationHelper.Get("APP_SECOND"), MessageBoxButton.OK, MessageBoxImage.Information); } //---------// // second instance: duplicate else { MessageBox.Show(TranslationHelper.Get("APP_SECOND_TEXT"), TranslationHelper.Get("APP_SECOND"), MessageBoxButton.OK, MessageBoxImage.Information); } return(false); }
private void App_OnExit(object sender, ExitEventArgs e) { if (!_cleanExit) { return; } _isRunning.ReleaseMutex(); PipeServerManager.GetInstance().Dispose(); //add by gh - 自动启动隐藏后台图标 if (SettingHelper.Get("Visible", true)) { TrayIconManager.GetInstance().Dispose(); } //----------// //comment by gh //TrayIconManager.GetInstance().Dispose(); //----------// KeystrokeDispatcher.GetInstance().Dispose(); ViewWindowManager.GetInstance().Dispose(); }
private void App_OnExit(object sender, ExitEventArgs e) { if (_isFirstInstance) { PipeServerManager.GetInstance().Dispose(); TrayIconManager.GetInstance().Dispose(); BackgroundListener.GetInstance().Dispose(); } }
private void App_OnExit(object sender, ExitEventArgs e) { if (_isFirstInstance) { _isRunning.ReleaseMutex(); PipeServerManager.GetInstance().Dispose(); TrayIconManager.GetInstance().Dispose(); BackgroundListener.GetInstance().Dispose(); ViewWindowManager.GetInstance().Dispose(); } }
private void App_OnExit(object sender, ExitEventArgs e) { if (!_isFirstInstance) { return; } _isRunning.ReleaseMutex(); PipeServerManager.GetInstance().Dispose(); TrayIconManager.GetInstance().Dispose(); KeystrokeDispatcher.GetInstance().Dispose(); ViewWindowManager.GetInstance().Dispose(); }
private void InvokeRoutine(Keys key, bool isKeyDown) { if (!_validKeys.Contains(key)) { Debug.WriteLine($"Invalid keypress: key={key},down={isKeyDown}, time={_lastInvalidKeyPressTick}"); _lastInvalidKeyPressTick = DateTime.Now.Ticks; return; } if (DateTime.Now.Ticks - _lastInvalidKeyPressTick < VALID_KEY_PRESS_DELAY) { return; } _lastInvalidKeyPressTick = 0L; Debug.WriteLine($"InvokeRoutine: key={key},down={isKeyDown}"); if (isKeyDown) { switch (key) { case Keys.Enter: PipeServerManager.SendMessage(PipeMessages.RunAndClose); break; } } else { switch (key) { case Keys.Up: case Keys.Down: case Keys.Left: case Keys.Right: PipeServerManager.SendMessage(PipeMessages.Switch); break; case Keys.Space: PipeServerManager.SendMessage(PipeMessages.Toggle); break; case Keys.Escape: PipeServerManager.SendMessage(PipeMessages.Close); break; } } }
/* comment by gh * private void CheckUpdate() * { * if (DateTime.Now.Ticks - SettingHelper.Get<long>("LastUpdateTicks") < TimeSpan.FromDays(7).Ticks) * return; * * Task.Delay(120 * 1000).ContinueWith(_ => Updater.CheckForUpdates(true)); * SettingHelper.Set("LastUpdateTicks", DateTime.Now.Ticks); * } *///----------// private void RunListener(StartupEventArgs e) { //comment by gh - 启动不显示启动提示 //TrayIconManager.GetInstance(); //if (!e.Args.Contains("/autorun") && !IsUWP) //TrayIconManager.ShowNotification("", TranslationHelper.Get("APP_START")); //if (e.Args.Contains("/first")) //AutoStartupHelper.CreateAutorunShortcut(); //----------// //add by gh - 自动启动隐藏后台图标 if (SettingHelper.Get("Visible", true)) { TrayIconManager.GetInstance(); if (!e.Args.Contains("/autorun") && !IsUWP) { TrayIconManager.ShowNotification("", TranslationHelper.Get("APP_START")); } } else if (e.Args.Contains("/setvisible")) { SettingHelper.Set("Visible", true); TrayIconManager.GetInstance(); if (!IsUWP) { TrayIconManager.ShowNotification("", TranslationHelper.Get("APP_START")); } } //自己添加的功能,与quick look无关 if (SettingHelper.Get("Watcher", false)) { DesktopWatcher.GetInstance().WatcherStart(); } if (e.Args.Contains("/first")) { AutoStartupHelper.CreateAutorunShortcut(); } //----------// NativeMethods.QuickLook.Init(); PluginManager.GetInstance(); ViewWindowManager.GetInstance(); KeystrokeDispatcher.GetInstance(); PipeServerManager.GetInstance(); }
private void RunListener(StartupEventArgs e) { TrayIconManager.GetInstance(); if (!e.Args.Contains("/autorun") && !IsUWP) { TrayIconManager.ShowNotification("", TranslationHelper.GetString("APP_START")); } if (e.Args.Contains("/first")) { AutoStartupHelper.CreateAutorunShortcut(); } NativeMethods.QuickLook.Init(); PluginManager.GetInstance(); ViewWindowManager.GetInstance(); BackgroundListener.GetInstance(); PipeServerManager.GetInstance(); }
private void Application_Startup(object sender, StartupEventArgs e) { if (!EnsureOSVersion() || !EnsureFirstInstance(e.Args) || !EnsureFolderWritable(SettingHelper.LocalDataPath)) { _cleanExit = false; Shutdown(); return; } CheckUpdate(); RunListener(e); // first instance: run and preview this file if (e.Args.Any() && (Directory.Exists(e.Args.First()) || File.Exists(e.Args.First()))) { PipeServerManager.SendMessage(PipeMessages.Toggle, e.Args.First()); } }
private void RunListener(StartupEventArgs e) { TrayIconManager.GetInstance(); if (!e.Args.Contains("/autorun")) { TrayIconManager.GetInstance().ShowNotification("", "QuickLook is running in the background."); } if (e.Args.Contains("/first")) { AutoStartupHelper.CreateAutorunShortcut(); } NativeMethods.QuickLook.Init(); PluginManager.GetInstance(); BackgroundListener.GetInstance(); PipeServerManager.GetInstance().MessageReceived += (msg, ea) => Dispatcher.BeginInvoke( new Action(() => ViewWindowManager.GetInstance().InvokeViewer(msg as string, closeIfSame: true)), DispatcherPriority.ApplicationIdle); }
private void InvokeRoutine(Keys key, bool isKeyDown) { var path = NativeMethods.QuickLook.GetCurrentSelection(); Debug.WriteLine($"InvokeRoutine: key={key},down={isKeyDown}"); if (isKeyDown) { switch (key) { case Keys.Enter: PipeServerManager.SendMessage(PipeMessages.RunAndClose); break; } } else { switch (key) { case Keys.Up: case Keys.Down: case Keys.Left: case Keys.Right: PipeServerManager.SendMessage(PipeMessages.Switch, path); break; case Keys.Space: PipeServerManager.SendMessage(PipeMessages.Toggle, path); break; case Keys.Escape: PipeServerManager.SendMessage(PipeMessages.Close); break; } } }
private void RemoteCallShowPreview(StartupEventArgs e) { PipeServerManager.SendMessage(PipeMessages.Toggle, e.Args.First()); }
public static PipeServerManager GetInstance() { return(_instance ?? (_instance = new PipeServerManager())); }