Пример #1
0
        public MainWindow()
        {
            UpdateLazerInstallationPath();
            InitializeComponent(); //Setup dependencies before initialisation
            Client = new GitHubClient(new ProductHeaderValue("Osu!ModeManager", GetCurrentApplicationVersionName()));

            //Create new OAuth token if none exists, or if the latest is older than 8 hours
            if (Environment.GetCommandLineArgs().Contains("--flush") || Settings.Default.LatestToken.IsNullOrEmpty() || DateTime.UtcNow - Settings.Default.LatestTokenCreationTime >= TimeSpan.FromHours(8))
            {
                Debug.WriteLine("New OAuth Token Required");
                AuthoriseButton.Visibility = Visibility.Visible;
            }
            else
            {
                Debug.WriteLine("Reusing OAuth Token");
                Client.Credentials = new Credentials(Settings.Default.LatestToken);
                Dispatcher.Invoke(async() => await SelfUpdateWindow.CreateUpdateChecker(this), DispatcherPriority.Normal);
            }
            //AuthoriseButton.Visibility = System.Windows.Visibility.Visible;

            LazerVersionCombo.SelectedIndex = 0;

            LoadGamemodes();

            Debug.WriteLine("osu!lazer is installed at: " + LazerInstallationPath.FullName);
        }
Пример #2
0
        public static async Task CreateUpdateChecker(Window Caller = null)
        {
            Debug.WriteLine("Checking for application updates...");
            bool UpdateRequired = await CheckForUpdate();

            if (UpdateRequired)
            {
                Debug.WriteLine("\tAn update is available.");
                Caller?.Hide();
                SelfUpdateWindow SelfUpdateWindow = new SelfUpdateWindow();
                SelfUpdateWindow.Show();
                _Caller = Caller;

                SelfUpdateWindow.UpdateCurrentVersionLabel(MainWindow.GetCurrentApplicationVersionName());
                SelfUpdateWindow.UpdateLatestVersionLabel(_LatestRelease.TagName);
                SelfUpdateWindow.DownloadButton.Visibility = Visibility.Visible;
            }
            else
            {
                Debug.WriteLine("\tThis application is up to date. :D");
            }
        }