Exemple #1
0
        internal static void CreateAutorunShortcut()
        {
            if (App.IsUWP)
            {
                return;
            }

            try
            {
                RemoveAutorunShortcut();

                var lnk = (IShellLinkW) new ShellLink();

                lnk.SetPath(App.AppFullPath);
                lnk.SetArguments("/autorun"); // silent
                lnk.SetIconLocation(App.AppFullPath, 0);
                lnk.SetWorkingDirectory(App.AppPath);
                ((IPersistFile)lnk).Save(StartupFullPath, false);
            }
            catch (Exception e)
            {
                ProcessHelper.WriteLog(e.ToString());
                TrayIconManager.ShowNotification("", "Failed to add QuickLook to Startup folder.");
            }
        }
Exemple #2
0
        internal static void CreateAutorunShortcut()
        {
            if (App.IsUWP)
            {
                return;
            }

            try
            {
                File.Create(StartupFullPath).Close();

                var lnk = ShellLinkHelper.OpenShellLink(StartupFullPath);

                lnk.Path      = App.AppFullPath;
                lnk.Arguments = "/autorun"; // silent
                lnk.SetIconLocation(App.AppFullPath, 0);
                lnk.WorkingDirectory = App.AppPath;

                lnk.Save(StartupFullPath);
            }
            catch (Exception)
            {
                TrayIconManager.ShowNotification("", "Failed to add QuickLook to Startup folder.");
            }
        }
Exemple #3
0
        public static void CollectAndShowReleaseNotes()
        {
            Task.Run(() =>
            {
                try
                {
                    var json = DownloadJson("https://api.github.com/repos/xupefei/QuickLook/releases");

                    var notes = string.Empty;

                    foreach (var item in json)
                    {
                        notes += $"# {item["name"]}\r\n\r\n";
                        notes += item["body"] + "\r\n\r\n";
                    }

                    var changeLogPath = Path.GetTempFileName() + ".md";
                    File.WriteAllText(changeLogPath, notes);

                    PipeServerManager.SendMessage(PipeMessages.Invoke, changeLogPath);
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                    Application.Current.Dispatcher.Invoke(
                        () => TrayIconManager.ShowNotification("",
                                                               string.Format(TranslationHelper.GetString("Update_Error"), e.Message)));
                }
            });
        }
Exemple #4
0
        internal static void CreateAutorunShortcut()
        {
            if (App.IsUWP)
            {
                return;
            }

            try
            {
                File.Create(StartupFullPath).Close();

                var shl = new Shell();
                var dir = shl.NameSpace(Path.GetDirectoryName(StartupFullPath));
                var itm = dir.Items().Item(Path.GetFileName(StartupFullPath));
                var lnk = (ShellLinkObject)itm.GetLink;

                lnk.Path      = App.AppFullPath;
                lnk.Arguments = "/autorun"; // silent
                lnk.SetIconLocation(App.AppFullPath, 0);
                lnk.WorkingDirectory = App.AppPath;

                lnk.Save(StartupFullPath);
            }
            catch (Exception)
            {
                TrayIconManager.ShowNotification("", "Failed to add QuickLook to Startup folder.");
            }
        }
Exemple #5
0
        public static void CheckForUpdates(bool silent = false)
        {
            if (App.IsUWP)
            {
                if (!silent)
                {
                    Process.Start("ms-windows-store://pdp/?productid=9NV4BS3L1H4S");
                }

                return;
            }

            Task.Run(() =>
            {
                try
                {
                    var json = DownloadJson("https://api.github.com/repos/xupefei/QuickLook/releases/latest");

                    var nVersion = (string)json["tag_name"];
                    //nVersion = "9.2.1";

                    if (new Version(nVersion) <= Assembly.GetExecutingAssembly().GetName().Version)
                    {
                        if (!silent)
                        {
                            Application.Current.Dispatcher.Invoke(
                                () => TrayIconManager.ShowNotification("",
                                                                       TranslationHelper.Get("Update_NoUpdate")));
                        }
                        return;
                    }

                    CollectAndShowReleaseNotes();

                    Application.Current.Dispatcher.Invoke(
                        () =>
                    {
                        TrayIconManager.ShowNotification("",
                                                         string.Format(TranslationHelper.Get("Update_Found"), nVersion),
                                                         timeout: 20000,
                                                         clickEvent:
                                                         () => Process.Start(
                                                             @"https://github.com/xupefei/QuickLook/releases/latest"));
                    });
                }
                catch (Exception e)
                {
                    Debug.WriteLine(e.Message);
                    Application.Current.Dispatcher.Invoke(
                        () => TrayIconManager.ShowNotification("",
                                                               string.Format(TranslationHelper.Get("Update_Error"), e.Message)));
                }
            });
        }
Exemple #6
0
        internal static void RemoveAutorunShortcut()
        {
            if (App.IsUWP)
            {
                return;
            }

            try
            {
                File.Delete(StartupFullPath);
            }
            catch (Exception e)
            {
                ProcessHelper.WriteLog(e.ToString());
                TrayIconManager.ShowNotification("", "Failed to delete QuickLook startup shortcut.");
            }
        }