Ejemplo n.º 1
0
        public async void Checker()
        {
            if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
            {
                var client = new GitHubClient(new ProductHeaderValue("my-cool-app"));
                var repo   = await client.Release.GetAll("Maartin10", "LeBOTcoin");

                var checker         = new UpdateChecker("Maartin10", "LeBOTcoin");
                var versionactuelle = new Version(ProductVersion);
                var versionnouvelle = new Version(repo[0].TagName.Substring(1));
                if (versionactuelle < versionnouvelle)
                {
                    var result = new UpdateNotifyDialog(checker).ShowDialog();
                    if (result == DialogResult.Yes)
                    {
                        checker.DownloadAsset("LeBOTcoin.", ".Setup.msi", repo[0].TagName); // "LeBOTcoin.v1.0.0.Setup.msi"
                        Close();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private async void Check_Update_Click(object sender, RoutedEventArgs e)
        {
            var checker = new UpdateChecker("zapezhman", "FFWSC"); // uses your Application.ProductVersion

            UpdateType update = await checker.CheckUpdate().ConfigureAwait(true);

            if (update == UpdateType.None)
            {
                // Up to date!
            }
            else
            {
                // Ask the user if he wants to update
                // You can use the prebuilt form for this if you want (it's really pretty!)
                var result = new UpdateNotifyDialog(checker).ShowDialog();
                if (result.Equals(DialogResult.HasValue))
                {
                    checker.DownloadAsset("Converter.zip"); // opens it in the user's browser
                }
            }
        }
Ejemplo n.º 3
0
        private async void BtnCheckUpdates_Click(object sender, RoutedEventArgs e)
        {
            var checker = new UpdateChecker("melonis45", "dansermenu"); // uses your Application.ProductVersion

            try
            {
                UpdateType update = await checker.CheckUpdate();

                if (update == UpdateType.None)
                {
                    MessageBox.Show("Up to date!", "Check was successful", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    // Ask the user if he wants to update
                    // You can use the prebuilt form for this if you want (it's really pretty!)
                    var result = new UpdateNotifyDialog(checker).ShowDialog();
                    if (result == System.Windows.Forms.DialogResult.Yes)
                    {
                        string url       = $"https://github.com/melonis45/dansermenu/releases/download/{checker.latestTag}/DANSER-Menu-V{checker.latestTag}.zip";
                        int    processId = Process.GetCurrentProcess().Id;

                        Process          updateProcess = new Process();
                        ProcessStartInfo startInfo     = new ProcessStartInfo
                        {
                            FileName  = "Updater.exe",
                            Arguments = $"{url} {processId}"
                        };

                        updateProcess.StartInfo = startInfo;
                        updateProcess.Start();
                    }
                }
            }
            catch (System.Net.Http.HttpRequestException)
            {
                MessageBox.Show("No internet connection found!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
        }
Ejemplo n.º 4
0
        void Check(object sender, EventArgs e)
        {
            UpdateChecker checker;

            if (ProductVersion.Checked)
            {
                checker = new UpdateChecker(User.Text, Repo.Text);
            }
            else
            {
                checker = new UpdateChecker(User.Text, Repo.Text, Version.Text);
            }

            ((Button)sender).Enabled = false;
            checker.CheckUpdate(locked: (UpdateType)Lock.SelectedIndex).ContinueWith(continuation =>
            {
                // if (continuation.Result == UpdateType.None)
                //    return;

                Invoke(new Action(() => // Go back to the UI thread
                {
                    ((Button)sender).Enabled = true;
                    if (continuation.Result != UpdateType.None)
                    {
                        var result = new UpdateNotifyDialog(checker).ShowDialog();
                        if (result == DialogResult.Yes)
                        {
                            checker.DownloadAsset(Asset.Text);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Up to date!");
                    }
                }));
            });
        }
Ejemplo n.º 5
0
        private void OrganizerForm_Load(object sender, EventArgs e)
        {
            Version appVersion = Assembly.GetExecutingAssembly().GetName().Version;

            lblVersion.Text = string.Format(lblVersion.Text, appVersion.Major, appVersion.Minor);

            checker = new UpdateChecker("founderio", "emoticorg");
            checker.CheckUpdate(UpdateType.Major).ContinueWith(continuation =>
            {
                Invoke(new Action(() =>
                {
                    if (continuation.Result != UpdateType.None)
                    {
                        var result = new UpdateNotifyDialog(checker).ShowDialog();
                        if (result == DialogResult.Yes)
                        {
                            checker.DownloadAsset("Emoticorg.zip");
                        }
                    }
                }));
            });

            string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string dataDir = Path.Combine(appdata, "Emoticorg");

            try
            {
                Directory.CreateDirectory(dataDir);
                store = EmoticonStore.openStore(Path.Combine(dataDir, "store.sqlite"));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error loading database:\n" + ex.ToString(), "Error Loading Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                store = null;
                Application.Exit();
            }

            if (!store.IsReadable)
            {
                MessageBox.Show("This Emoticon store was created by a different application version and cannot be converted.\nSupported Version: " + EmoticonStore.VERSION + " Loaded Version: " + store.LoadedVersionString, "Error Loading Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                store = null;
                Application.Exit();
            }
            else if (store.NeedsUpgrade)
            {
                DialogResult result = MessageBox.Show("This Emoticon store needs be converted before usage.\nWARNING: This may break compatibility with lower application versions!\nTarget Version: " + EmoticonStore.VERSION + " Loaded Version: " + store.LoadedVersionString + "\n\nDo you want to convert?", "Conversion Needed", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    try
                    {
                        store.Upgrade();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Error upgrading database:\n" + ex.ToString(), "Error Upgrading Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        store = null;
                        Application.Exit();
                    }
                }
            }

            if (treeView1.Nodes.Count > 0)
            {
                treeView1.SelectedNode = treeView1.Nodes[0];
            }
            RefreshCategories();
        }