Ejemplo n.º 1
0
        void UpdateTimerTick(object sender, EventArgs e)
        {
            ((DispatcherTimer)sender).Stop();

            bool reloadVersions = AppSettings.UpdateVersions;

            if (AppSettings.FirstStart)
            {
                // get application settings from previous version, if possible
                AppSettings.Upgrade();

                if (AppSettings.FirstStart)
                {
                    SettingsWindow settings = new SettingsWindow {
                        Owner = this
                    };
                    settings.ShowDialog();
                }
                else
                {
                    if (AppSettings.ShowChangeLog)
                    {
                        ChangelogViewer changeLog = new ChangelogViewer {
                            Owner = this
                        };
                        changeLog.ShowDialog();
                    }
                    string msg = Processing.GetResourceString("update_done");
                    Xceed.Wpf.Toolkit.MessageBox.Show(msg,
                                                      "Update",
                                                      MessageBoxButton.OK,
                                                      MessageBoxImage.Information);
                    reloadVersions = true;
                }
            }

            if (reloadVersions)
            {
                BackgroundWorker reloadV = new BackgroundWorker
                {
                    WorkerReportsProgress      = true,
                    WorkerSupportsCancellation = false
                };

                reloadV.RunWorkerCompleted += (o, args) => RunUpdateWorker();
                reloadV.DoWork             += (o, args) =>
                {
                    BackgroundWorker bw = (BackgroundWorker)o;
                    bw.ReportProgress(-5);
                    Processing.GetAppVersions();
                    bw.ReportProgress(-6);
                };
                reloadV.ProgressChanged += (o, args) =>
                {
                    switch (args.ProgressPercentage)
                    {
                    case -5:
                        string msg = Processing.GetResourceString("check_versions");

                        StatusItem.Text             = msg;
                        StatusItem.FontWeight       = FontWeights.Bold;
                        StatusItemHeader.Background = Brushes.Yellow;
                        break;

                    case -6:
                        StatusItem.Text             = string.Empty;
                        StatusItem.FontWeight       = FontWeights.Normal;
                        StatusItemHeader.Background = Brushes.Transparent;
                        break;
                    }
                };
                reloadV.RunWorkerAsync();
            }
            else
            {
                RunUpdateWorker();
            }
        }
Ejemplo n.º 2
0
        void UpdateTimerTick(object sender, EventArgs e)
        {
            ((DispatcherTimer) sender).Stop();

            bool reloadVersions = AppSettings.UpdateVersions;

            if (AppSettings.FirstStart)
            {
                // get application settings from previous version, if possible
                AppSettings.Upgrade();

                if (AppSettings.FirstStart)
                {
                    SettingsWindow settings = new SettingsWindow {Owner = this};
                    settings.ShowDialog();
                }
                else
                {
                    if (AppSettings.ShowChangeLog)
                    {
                        ChangelogViewer changeLog = new ChangelogViewer {Owner = this};
                        changeLog.ShowDialog();
                    }
                    string msg = Processing.GetResourceString("update_done");
                    Xceed.Wpf.Toolkit.MessageBox.Show(msg,
                                                      "Update",
                                                      MessageBoxButton.OK,
                                                      MessageBoxImage.Information);
                    reloadVersions = true;
                }
            }

            if (reloadVersions)
            {
                BackgroundWorker reloadV = new BackgroundWorker
                    {
                        WorkerReportsProgress = true,
                        WorkerSupportsCancellation = false
                    };

                reloadV.RunWorkerCompleted += (o, args) => RunUpdateWorker();
                reloadV.DoWork += (o, args) =>
                    {
                        BackgroundWorker bw = (BackgroundWorker) o;
                        bw.ReportProgress(-5);
                        Processing.GetAppVersions();
                        bw.ReportProgress(-6);

                    };
                reloadV.ProgressChanged += (o, args) =>
                    {
                        switch (args.ProgressPercentage)
                        {
                            case -5:
                                string msg = Processing.GetResourceString("check_versions");

                                StatusItem.Text = msg;
                                StatusItem.FontWeight = FontWeights.Bold;
                                StatusItemHeader.Background = Brushes.Yellow;
                                break;

                            case -6:
                                StatusItem.Text = string.Empty;
                                StatusItem.FontWeight = FontWeights.Normal;
                                StatusItemHeader.Background = Brushes.Transparent;
                                break;
                        }
                    };
                reloadV.RunWorkerAsync();
            }
            else
                RunUpdateWorker();
        }