コード例 #1
0
        /// <summary>
        /// Hides this window and shows the floating ones instead
        /// </summary>
        /// <param name="hide">Whether to hide this window and force the FloatingWindow to be shown</param>
        private void PutToBackground(bool hide = true)
        {
            this.notifyIcon.Visible = true;
            if (hide)
            {
                this.Hide();
                this.floatingWindow.ShowSelfOrPie();

                Toaster.Toast($"{Constants.APP_ID} is running in background");
                Console.WriteLine("Hiding the window to background...");
            }
        }
コード例 #2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var assembly = Assembly.GetEntryAssembly();

            var updateDotExe = Path.Combine(Path.GetDirectoryName(assembly.Location), "..", "Update.exe");

            var isSquirrelInstallation = File.Exists(updateDotExe);

            if (isSquirrelInstallation)
            {
                var updateTask = new Task(async() =>
                {
                    var mgr = await UpdateManager.GitHubUpdateManager(Constants.GITHUB_RELEASES_URL);
                    Console.Out.WriteLine($"Checking for updates at {Constants.GITHUB_RELEASES_URL}...");

                    var result = await mgr.CheckForUpdate();

                    if (result.ReleasesToApply.Count > 0)
                    {
                        Console.Out.WriteLine($"There are {result.ReleasesToApply.Count} update(s) to be downloaded. WinMediaPie will be upgraded to version {result.FutureReleaseEntry.Version}.");

                        Toaster.Toast($"Updating WinMediaPie to version {result.FutureReleaseEntry.Version} in background");
                    }
                    else
                    {
                        Console.Out.WriteLine($"There are no new updates. Version {result.CurrentlyInstalledVersion.Version} is the latest available");
                    }

                    await mgr.UpdateApp();
                });

                updateTask.ContinueWith(t =>
                {
                    AggregateException exception = t.Exception;

                    Console.Out.WriteLine("Error checking for updates: ", exception);
                }, TaskContinuationOptions.OnlyOnFaulted);

                updateTask.Start();
            }
            else
            {
                Console.Out.WriteLine("Not a Squirrel setup based installation, automatic updates are unavailable.");
            }
        }