Example #1
0
        public void InvokePreview(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            if (_viewerWindow.Visibility == Visibility.Visible && path == _invokedPath)
            {
                return;
            }

            if (!Directory.Exists(path) && !File.Exists(path))
            {
                return;
            }

            _invokedPath = path;

            RunFocusMonitor();

            var matchedPlugin = PluginManager.GetInstance().FindMatch(path);

            BeginShowNewWindow(path, matchedPlugin);
        }
Example #2
0
        internal bool InvokeViewer(string path = null, bool closeIfSame = false)
        {
            if (closeIfSame)
            {
                if (_currentMainWindow.Visibility == Visibility.Visible && path == _path)
                {
                    ClosePreview();
                    return(false);
                }
            }

            if (path != null)
            {
                _path = path;
            }

            if (string.IsNullOrEmpty(_path))
            {
                return(false);
            }
            if (!Directory.Exists(_path) && !File.Exists(_path))
            {
                return(false);
            }

            RunFocusMonitor();

            var matchedPlugin = PluginManager.GetInstance().FindMatch(_path);

            BeginShowNewWindow(matchedPlugin);

            return(true);
        }
Example #3
0
        private void CurrentPluginFailed(string path, ExceptionDispatchInfo e)
        {
            var plugin = _viewerWindow.Plugin.GetType();

            _viewerWindow.BeginHide();

            TrayIconManager.ShowNotification("", $"Failed to preview {Path.GetFileName(path)}", true);

            Debug.WriteLine(e.SourceException.ToString());
            Debug.WriteLine(e.SourceException.StackTrace);

            const string source = "QuickLook Preview Error";

            if (!EventLog.SourceExists(source))
            {
                EventLog.CreateEventSource(source, "Application");
            }
            EventLog.WriteEntry(source, e.SourceException.ToString(),
                                EventLogEntryType.Error);

            if (plugin != PluginManager.GetInstance().DefaultPlugin.GetType())
            {
                BeginShowNewWindow(path, PluginManager.GetInstance().DefaultPlugin);
            }
            else
            {
                e.Throw();
            }
        }
Example #4
0
        private void BeginShowNewWindow(IViewer matchedPlugin, string path)
        {
            _viewWindow         = new MainWindow();
            _viewWindow.Closed += (sender2, e2) =>
            {
                _viewWindow.Dispose();
                _viewWindow = null;
                GC.Collect();
            };

            try
            {
                _viewWindow.BeginShow(matchedPlugin, path);
            }
            catch (Exception e) // if current plugin failed, switch to default one
            {
                Debug.WriteLine(e.ToString());
                Debug.WriteLine(e.StackTrace);

                if (matchedPlugin.GetType() != PluginManager.GetInstance().DefaultPlugin)
                {
                    matchedPlugin.Dispose();
                    _viewWindow.BeginShow(PluginManager.GetInstance().DefaultPlugin.CreateInstance <IViewer>(), path);
                }
            }
        }
Example #5
0
        /* 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();
        }
Example #6
0
        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();
        }
Example #7
0
        private void CurrentPluginFailed(ExceptionDispatchInfo e)
        {
            var plugin = _currentMainWindow.Plugin.GetType();

            _currentMainWindow.BeginHide();

            TrayIconManager.GetInstance().ShowNotification("", $"Failed to preview {Path.GetFileName(_path)}", true);

            Debug.WriteLine(e.SourceException.ToString());
            Debug.WriteLine(e.SourceException.StackTrace);

            if (plugin != PluginManager.GetInstance().DefaultPlugin.GetType())
            {
                BeginShowNewWindow(PluginManager.GetInstance().DefaultPlugin);
            }
            else
            {
                e.Throw();
            }
        }
Example #8
0
        private void CurrentPluginFailed(string path, ExceptionDispatchInfo e)
        {
            var plugin = _viewerWindow.Plugin.GetType();

            _viewerWindow.BeginHide();

            TrayIconManager.ShowNotification($"Failed to preview {Path.GetFileName(path)}", "Consider reporting this incident to QuickLook’s author.", true);

            Debug.WriteLine(e.SourceException.ToString());

            ProcessHelper.WriteLog(e.SourceException.ToString());

            if (plugin != PluginManager.GetInstance().DefaultPlugin.GetType())
            {
                BeginShowNewWindow(path, PluginManager.GetInstance().DefaultPlugin);
            }
            else
            {
                e.Throw();
            }
        }
Example #9
0
        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);
        }
Example #10
0
        internal void InvokeRoutine()
        {
            if (CloseCurrentWindow())
            {
                return;
            }

            if (!WindowHelper.IsFocusedControlExplorerItem())
            {
                return;
            }

            var path = GetCurrentSelection();

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            var matchedPlugin = PluginManager.GetInstance().FindMatch(path);

            BeginShowNewWindow(matchedPlugin, path);
        }
Example #11
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            PluginManager.GetInstance();

            BackgroundListener.GetInstance();
        }