Esempio n. 1
0
        internal static bool CreateAutoRunShortcut()
        {
            try
            {
                RemoveAutoRunShortcut();

                var lnk = ShellLinkFactory.GetNewInstance();

                lnk.SetPath(AppPath);
                lnk.SetArguments("/autorun"); // silent
                lnk.SetIconLocation(AppPath, 0);
                lnk.SetWorkingDirectory(Path.GetDirectoryName(AppPath) ?? "");
                // ReSharper disable once SuspiciousTypeConversion.Global
                (lnk as IPersistFile)?.Save(StartupFullPath, false);

                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                TrayIconManager.ShowNotification("", "Failed to add Cluckeys to Startup folder.");
            }

            return(false);
        }
Esempio n. 2
0
        public static void CheckForUpdates(bool silent = true)
        {
            if (_isChecking)
            {
                return;
            }

            _isChecking = true;

            Task.Run(() =>
            {
                try
                {
                    var result  = HttpRequest(UpdatesUrl);
                    var version = (string)result["tag_name"];

                    if (new Version(version.Substring(1)) <= Assembly.GetExecutingAssembly().GetName().Version)
                    {
                        Application.Current.Dispatcher?.Invoke(() =>
                        {
                            _isChecking = false;
                            if (!silent)
                            {
                                TrayIconManager.ShowNotification("", "You are now on the latest version.");
                            }
                        });
                    }
                    else
                    {
                        Application.Current.Dispatcher?.Invoke(() =>
                        {
                            _isChecking = false;
                            TrayIconManager.ShowUpdatesAvailable(version);
                        });
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    Application.Current.Dispatcher?.Invoke(() =>
                    {
                        _isChecking = false;
                        if (!silent)
                        {
                            TrayIconManager.ShowNotification("",
                                                             $"Error occured when checking for updates: {e.Message}");
                        }
                    });
                }
            });
        }
Esempio n. 3
0
        internal static bool RemoveAutoRunShortcut()
        {
            try
            {
                File.Delete(StartupFullPath);
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                TrayIconManager.ShowNotification("", "Failed to delete Cluckeys startup shortcut.");
            }

            return(false);
        }