SetIndeterminate() public méthode

Sets the ProgressBar's IsIndeterminate to true. To set it to false, call SetProgress.
public SetIndeterminate ( ) : void
Résultat void
        public async void ShowProgress(string location, bool isSvn, string autoInstallName = null)
        {
            controller = await this.ShowProgressAsync("Updating...", "Downloading the required data.");
            controller.SetIndeterminate();

            ListAssemblies(location, isSvn, autoInstallName);
        }
        /// <summary>
        ///     Runs CanEnable asynchronously multiple times until successful, cancelled or max tries reached
        /// </summary>
        /// <param name="dialog"></param>
        /// <returns></returns>
        public Task<bool> CanEnableAsync(ProgressDialogController dialog)
        {
            return Task.Run(() =>
            {
                for (var tries = 1; tries <= 10; tries++)
                {
                    // Dialog interaction
                    if (dialog != null)
                    {
                        // Stop if cancelled by user
                        if (dialog.IsCanceled)
                        {
                            dialog.SetIndeterminate();
                            return false;
                        }
                        // Updated progress to indicate how much tries are left
                        dialog.SetProgress(0.1*tries);
                    }

                    if (CanEnable())
                    {
                        dialog?.SetIndeterminate();
                        return true;
                    }
                    Thread.Sleep(2000);
                }
                dialog?.SetIndeterminate();
                return false;
            });
        }
 public async void ShowProgress(string location, bool isSvn, string autoInstallName = null)
 {
     controller =
         await
             this.ShowProgressAsync(
                 Utility.GetMultiLanguageText("Updating"), Utility.GetMultiLanguageText("DownloadingData"));
     controller.SetIndeterminate();
     controller.SetCancelable(true);
     ListAssemblies(location, isSvn, autoInstallName);
 }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            TestRunWorker testRunWorker = (TestRunWorker)faultModel.TestRunWorker;
            testRunWorker.Desired = (double)DesiredValueNumUpDown.Value;
            testRunWorker.TestCase = TestCaseComboBox.SelectedIndex + 1;
            testRunWorker.RunWorkerCompleted += TestRunWorker_RunWorkerCompleted;
                        
            progressController = await this.ShowProgressAsync("Please wait...", "Model simulation running");
            progressController.SetIndeterminate();

            testRunWorker.RunWorkerAsync(faultModel);

            log("Allowed Oscillation Fault Model - Ran the model with desired value " + testRunWorker.Desired + " and test case" + testRunWorker.TestCase);
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            TestRunWorker testRunWorker = (TestRunWorker)faultModel.TestRunWorker;
            testRunWorker.InitialDesired = (double)InitialValueNumUpDown.Value;
            testRunWorker.FinalDesired = (double)FinalValueNumUpDown.Value;
            testRunWorker.RunWorkerCompleted += TestRunWorker_RunWorkerCompleted;

            progressController = await this.ShowProgressAsync("Please wait...", "Model simulation running");
            progressController.SetIndeterminate();
            testRunWorker.RunWorkerAsync(faultModel);

            log("Step Fault Model - Ran model with initial desired value " + testRunWorker.InitialDesired + " and final desired value " + testRunWorker.FinalDesired);

        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            TestRunWorker testRunWorker = (TestRunWorker)faultModel.TestRunWorker;
            testRunWorker.Desired = (double)DesiredValueNumUpDown.Value;
            testRunWorker.Frequency = (double)FrequencyNumUpDown.Value;
            testRunWorker.RunWorkerCompleted += TestRunWorker_RunWorkerCompleted;

            progressController = await this.ShowProgressAsync("Please wait...", "Model simulation running");
            progressController.SetIndeterminate();
            testRunWorker.RunWorkerAsync(faultModel);

            log("Disturbance Fault Model - Ran model with desired value " + testRunWorker.Desired + " and frequency " + testRunWorker.Frequency);

        }
Exemple #7
0
        private async void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            var email = txtEMail.Text;
            var pwd = txtPwd.Password;

            if (string.IsNullOrEmpty(email) && string.IsNullOrEmpty(pwd))
            {
                txtError.Text = "Please enter a EMail and a Password!";
                return;
            }
            else if (string.IsNullOrEmpty(pwd))
            {
                txtError.Text = "Please enter a Password";
                return;
            }
            else if (string.IsNullOrEmpty(email))
            {
                txtError.Text = "Please enter a EMail";
                return;
            }
            txtError.Text = "";

            IsEnabled = false;
            _controller = await this.ShowProgressAsync("Logging in...", "Authenticating...");
            _controller.SetIndeterminate();

            var result = await Task.Factory.StartNew(() =>
            {
                return commander.AuthenticateUser(email, pwd);
            });

            txtPwd.Password = "";

            await _controller.CloseAsync();

            IsEnabled = true;
            if (result == true)
            {
                await this.ShowMessageAsync("Authenticated", "Login success!");
                MainWindow mainWindow = new MainWindow();
                mainWindow.Show();
                Close();
            }
            else
            {
                txtError.Text = "Combination of EMail and Password is incorrect!";
            }
            _controller.SetProgress(1);
        }
        private async void PerformanceDay_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!initialized)
                return;
            else {
                if (PerformanceDay.SelectedItem != null)
                {
                    var selectedItem = (DateTime)PerformanceDay.SelectedItem;
                    IsEnabled = false;
                    _controller = await mainWindow.ShowProgressAsync("Performances", "Loading...");
                    _controller.SetIndeterminate();

                    await Task.Factory.StartNew(() =>
                    {
                        ufoVM.LoadPerformancesOfDay(selectedItem);
                    });

                    await _controller.CloseAsync();

                    IsEnabled = true;
                    _controller.SetProgress(1);
                }
            }
        }
        private async void btnUnsub_Click(object sender, RoutedEventArgs e)
        {
            if (!eventListViewSubs.Items.Contains(txt_User.Text))
                MsgBox("Error", "You are not subscribed to this event!");
            else
            {
                BackgroundWorker bgWorker = new BackgroundWorker() { WorkerReportsProgress = true };
                bgWorker.DoWork += (s, ee) =>
                {
                    try
                    {
                        Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
                        {
                            eventUpdating = true;
                            string eventSelected = this.eventListView.SelectedItem.ToString().Replace(" ", "_");
                            string encryptedJson = System.IO.File.ReadAllText(workingDir + "\\Config\\" + eventSelected);
                            string decryptedJson = CryptoService.Load.Decrypt(encryptedJson, softwareCfg.cipherKey);
                            eventVar _event = JsonConvert.DeserializeObject<eventVar>(decryptedJson);


                            eventListViewSubs.Items.Remove(txt_User.Text);
                            List<string> subs = new List<string>();
                            if (_event.eventSubscribers != null)
                            {
                                foreach (string sub in _event.eventSubscribers)
                                {
                                    subs.Add(sub);
                                }
                            }
                            subs.Remove(txt_User.Text);
                            _event.eventSubscribers = subs.ToArray();
                            string eventFileName = eventSelected;
                            System.IO.File.Delete(workingDir + "\\Config\\" + eventFileName);
                            Core.Events.MissionFile.Create.File(eventFileName, _event);
                            Core.Events.MissionFile.Upload.File(eventFileName);
                            eventUpdating = false;

                        }));

                    }
                    catch (Exception ex)
                    { System.Windows.MessageBox.Show(ex.ToString()); }
                };
                bgWorker.RunWorkerCompleted += async (s, ee) =>
                {
                    pause(5);
                    await pdC.CloseAsync();


                };

                bgWorker.RunWorkerAsync();
                pdC = await this.ShowProgressAsync("Please wait...", "Unsubscribing to this Event...");
                pdC.SetCancelable(false);
                pdC.SetIndeterminate();
            }
        }
        private async void updateBtnUs_Click(object sender, RoutedEventArgs e)
        {
            _controller2 = await this.ShowProgressAsync("Updating...", "Updating the WebConfig File...");
            _controller2.SetCancelable(false);
            _controller2.SetIndeterminate();

            Core.JsonUpdate.Create.File();
            Core.JsonUpdate.Upload.File();
            pause(5);
            await _controller2.CloseAsync();
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var button = sender as Button;
            var buttonCmdParam = button.CommandParameter;
            var command = button.Tag as ICommand;
            IsEnabled = false;
            _controller = await mainWindow.ShowProgressAsync("EMail", "Sending...");
            _controller.SetIndeterminate();

            await Task.Factory.StartNew(() =>
            {
                // Execute command in tag
                if (button != null)
                {
                    if (command != null)
                        command.Execute(buttonCmdParam);
                }
                return true;
            });

            await _controller.CloseAsync();

            IsEnabled = true;
            await mainWindow.ShowMessageAsync("EMail", "EMails were sent successfully!");
            _controller.SetProgress(1);
        }
        private async void RunComparisonButton_Click(object sender, RoutedEventArgs e)
        {
            DataGridHeatPoint runHeatPoint = (DataGridHeatPoint)ExplorationDataGrid.SelectedValue;

            TestRunWorker testRunWorker = (TestRunWorker)faultModel.TestRunWorker;
            testRunWorker.InitialDesired = runHeatPoint.InitialDesired;
            testRunWorker.FinalDesired = runHeatPoint.FinalDesired;
            testRunWorker.RunWorkerCompleted += TestRunWorker_RunWorkerCompleted;
            testRunWorker.ExecuteOnModel = TestRunWorker.TestModel.Both;

            progressController = await this.ShowProgressAsync("Running the model comparison", "Please wait...");
            progressController.SetCancelable(false);
            progressController.SetIndeterminate();

            testRunWorker.RunWorkerAsync(faultModel);

            log("Controller Comparison Fault Model - Ran models with initial desired value " + runHeatPoint.InitialDesired + " and final desired value " + runHeatPoint.FinalDesired);

        }
 private async void UpdateBtn_Click(object sender, RoutedEventArgs e)
 {
     _controller2 = await this.ShowProgressAsync("Updating...", "Updating the WebConfig File..." );
     _controller2.SetCancelable(false);
     _controller2.SetIndeterminate();
     config.webConfig_News = txt_News.Text;
     config.Software = txt_Software.Text;
     config.LatestVersion = txt_LatestVersion.Text;
     config.Language = txt_Language.Text;
     config.notAvailableMsg = txt_notAvailableMsg.Text;
     config.MasterIP = txt_MasterIP.Text;
     config.MasterIPDNS = txt_MasterIPDNS.Text;
     Core.JsonUpdate.Create.File();
     Core.JsonUpdate.Upload.File();
     pause(5);
     await _controller2.CloseAsync();
 }
        private async void Validate_Click(object sender, RoutedEventArgs e)
        {
            double modelSimulationTime = (double)this.ModelSimulationTimeNumUpDown.Value;
            double desiredValueReachedTime = (double)this.DesiredValueReachedNumUpDown.Value;
            double desiredFrom = (double)this.DesiredValueFromNumUpDown.Value;
            double desiredTo = (double)this.DesiredValueToNumUpDown.Value;
            double actualFrom = (double)this.ActualValueFromNumUpDown.Value;
            double actualTo = (double)this.ActualValueToNumUpDown.Value;
            double disturbanceAmplitude = (double)this.DisturbanceValueToNumUpDown.Value;
            double smoothnessDiff = (double)this.SmoothnessStartDifferenceNumUpDown.Value;
            double responsivenessClose = (double)this.ResponsivenessCloseNumUpDown.Value;

            if (desiredValueReachedTime >= modelSimulationTime)
            {
                MessageBox.Show("Invalid desired value reached time. The desired value reached time cannot be greater or equal to the model simulation time.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (desiredFrom >= desiredTo)
            {
                MessageBox.Show("Invalid desired value range", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (actualFrom >= actualTo)
            {
                MessageBox.Show("Invalid actual value range", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (actualFrom > desiredFrom)
            {
                MessageBox.Show("Invalid actual value range", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (smoothnessDiff > (Math.Abs(actualFrom - actualTo)/10))
            {
                MessageBox.Show("The value after which the smoothness measurement begins cannot be more than a tenth of the actual value range.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (responsivenessClose > (Math.Abs(actualFrom - actualTo) / 20))
            {
                MessageBox.Show("The absolute difference between the actual and the desired value at which the responsiveness measurement ends cannot be more than a fifth of the actual value range.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (String.IsNullOrWhiteSpace(this.DesiredValueNameTextBox.Text))
            {
                MessageBox.Show("Please specify the name of the desired variable.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (String.IsNullOrWhiteSpace(this.ActualValueNameTextBox.Text))
            {
                MessageBox.Show("Please specify the name of the actual variable.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (this.RefinedCandidatePointsNumUpDown.Value > 10)
            {
                MessageBox.Show("A maximum of 10 candidate points are allowed.", "Invalid setting", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            SimulationParameter desired = new SimulationParameter(this.DesiredValueNameTextBox.Text, SimulationParameterType.Desired, new decimal(desiredFrom), new decimal(desiredTo));
            SimulationParameter actual = new SimulationParameter(this.ActualValueNameTextBox.Text, SimulationParameterType.Actual, new decimal(actualFrom), new decimal(actualTo));
            SimulationParameter disturbance = new SimulationParameter(this.DisturbanceValueNameTextBox.Text, SimulationParameterType.Disturbance, new decimal(0), new decimal(disturbanceAmplitude));

            ModelRegressionSettings regressionSettings = new ModelRegressionSettings() { ModelQuality = (double)this.ModelQualityNumUpDown.Value, RefinedCandidatePoints = (int)this.RefinedCandidatePointsNumUpDown.Value, RefinementPoints = (int)this.RefinementSizeNumUpDown.Value, ValidationSetSize = (int)this.ValidationSetRandomPointsNumUpDown.Value, TrainingSetSizeEqualDistance = (int)this.TrainingSetPointsNumUpDown.Value, TrainingSetSizeRandom = (int)this.TrainingSetRandomPointsNumUpDown.Value };

            ModelSimulationSettings = new SimulationSettings(modelSimulationTime, desiredValueReachedTime, smoothnessDiff, responsivenessClose, desired, actual, disturbance, regressionSettings);

            progressController = await containingWindow.ShowProgressAsync("Please wait...", "Model compilation and simulation running");
            progressController.SetIndeterminate();
            
            TestFunctionality();
        }
        private async void RunTestCase(AllowedOscillationInternalTestCase internalTestCase)
        {
            TestRunWorker testRunWorker = (TestRunWorker)faultModel.TestRunWorker;
            testRunWorker.Desired = internalTestCase.InitialDesired;
            testRunWorker.TestCase = internalTestCase.TestCaseIndex;
            testRunWorker.RunWorkerCompleted += TestRunWorker_RunWorkerCompleted;

            progressController = await this.ShowProgressAsync("Running the model", "Please wait...");
            progressController.SetCancelable(false);
            progressController.SetIndeterminate();
            testRunWorker.RunWorkerAsync(faultModel);

            log("Allowed Oscillation Fault Model - Ran model with initial desired value " + internalTestCase.InitialDesired + ", test case " + internalTestCase.TestCaseIndex);

        }
        private async void DownloadSelectedLanguageSubtitles( )
        {
            if ( LanguageList.SelectedItems.Count <= 0 )
                return;

            controller = await window.ShowProgressAsync( "Downloading subtitles", "Downloading subtitles for the selected languages from opensubtitles.org." );
            controller.SetIndeterminate( );

            string[ ] languages = new string[ LanguageList.SelectedItems.Count ];
            for ( int x = 0; x < languages.Length; ++x )
                languages[ x ] = ( ( SubtitleLanguage ) LanguageList.SelectedItems[ x ] ).ISO639_3;

            SubtitleData[ ] data = await Task.Run( ( ) => MainWindow.Client.SearchSubtitles( languages, MainWindow.Player.GetComponent<MediaComponent>( ).Media.File ) );

            SubsGroupBox.Visibility = Visibility.Visible;

            this.SubtitlesList.ItemsSource = data;

            CollectionView subsView = ( CollectionView ) CollectionViewSource.GetDefaultView( SubtitlesList.ItemsSource );
            subsView.SortDescriptions.Add( new SortDescription( "DownloadsCount", ListSortDirection.Descending ) );

            Scroller.ScrollToBottom( );

            await controller.CloseAsync( );
        }
        private async void OnFlyoutFirstOpen( )
        {
            if ( MainWindow.Client.IsLoggedIn ) return;

            controller = await window.ShowProgressAsync( "Signing in.", "Signing into opensubtitles.org." );
            controller.SetIndeterminate( );
            LogInOutput output = await SignInClient( );

            if ( output.LogInSuccesful && MainWindow.Client.IsLoggedIn )
            {
                controller.SetTitle( "Downloading subtitle languages." );
                controller.SetMessage( "Downloading the available subtitle languages from opensubtitles.org." );
                this.languages = await GetSubtitleLanguages( );
                this.LanguageList.ItemsSource = this.languages;

                CollectionView languagesView = ( CollectionView )CollectionViewSource.GetDefaultView( LanguageList.ItemsSource );
                languagesView.SortDescriptions.Add( new SortDescription( "LanguageName", ListSortDirection.Ascending ) );
            }
            else
                await window.ShowMessageAsync( "Signing in failed", $"Unable to sign in to opensubtitles.org. Please try again later. (Status: {output.Status}, {output.StatusStringWithoutCode})" );

            await controller.CloseAsync( );

            OnFlyoutOpen( );
        }
        private async void eventMod_Click(object sender, RoutedEventArgs e)
        {
            if (!config.Administrators.Contains(txt_User.Text))
            {
                MsgBox("Error", "You MUST be and Administrator to complete this action!");
                return;
            }

            if (string.IsNullOrEmpty(txtmissionNameMod.Text) ||
               string.IsNullOrEmpty(comboMapMod.SelectedItem.ToString()) ||
               string.IsNullOrEmpty(Convert.ToString(nudPlayersMod.Value)) ||
               string.IsNullOrEmpty(txtmissionDescriptionMod.Text))
            {
                MsgBox("Error", "Please compile all field before create the event!");
                return;
            }

            BackgroundWorker bgWorker = new BackgroundWorker() { WorkerReportsProgress = true };
            bgWorker.DoWork += (s, ee) =>
            {
                try
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
                    {
                        _eventVar = new eventVar();
                        List<string> _modList = new List<string>();
                        foreach (string item in modListMod.SelectedItems)
                        {
                            _modList.Add(item);
                        }
                        _eventVar.eventName = txtmissionNameMod.Text;
                        _eventVar.eventDate = Convert.ToDateTime(eventCalendarMod.SelectedDate);
                        _eventVar.eventMap = comboMapMod.SelectedItem.ToString();
                        _eventVar.eventType = comboTypeMod.SelectedItem.ToString();
                        _eventVar.eventMinPlayers = Convert.ToInt16(nudPlayersMod.Value);
                        _eventVar.eventDescription = txtmissionDescriptionMod.Text;
                        _eventVar.eventMods = _modList.ToArray();
                        List<string> subs = new List<string>();
                        string[] _subs = null;
                        foreach (string sub in eventListViewSubs.Items)
                        {
                            subs.Add(sub);
                        }

                        _subs = subs.ToArray();

                        _eventVar.eventSubscribers = _subs;

                        string eventFileName = txtmissionNameMod.Text.Replace(" ", "_") + "_" + Convert.ToString(_eventVar.eventDate).Replace(" 00:00:00", "").Replace("/", "-") + "_" + _eventVar.eventMap;

                        if (System.IO.File.Exists(workingDir + "\\Config\\" + _eventFileName))
                        {
                            System.IO.File.Delete(workingDir + "\\Config\\" + _eventFileName);
                        }
                        Core.Events.MissionFile.Create.File(eventFileName, _eventVar);
                        Core.Events.MissionFile.Upload.File(eventFileName);
                        List<string> eventsList = new List<string>();
                        if (config.events != null)
                        {
                            foreach (string item in config.events)
                            {
                                eventsList.Add(item);
                            }
                            if (config.events.Contains(_eventFileName))
                            {
                                eventsList.Remove(_eventFileName);

                            }
                        }
                        eventsList.Add(eventFileName);
                        config.events = eventsList.ToArray();
                        Core.JsonUpdate.Create.File();
                        Core.JsonUpdate.Upload.File();


                    }));

                }
                catch (Exception ex)
                { System.Windows.MessageBox.Show(ex.ToString()); }
            };
            bgWorker.RunWorkerCompleted += async (s, ee) =>
            {
                pause(5);
                await _controller.CloseAsync();
                eventUpdating = true;
                this.eventListView.Items.Clear();
                this.eventListView.Items.Refresh();

                eventloadBase();
                eventUpdating = false;
            };

            bgWorker.RunWorkerAsync();
            _controller = await this.ShowProgressAsync("Please wait...", "Creating Online Event...");
            _controller.SetCancelable(false);
            _controller.SetIndeterminate();
        }
        private async void RunButton_Click(object sender, RoutedEventArgs e)
        {
            (sender as Button).GetValue(DataGridRow.AlternationIndexProperty);
            DataGridHeatPoint runHeatPoint = (DataGridHeatPoint)ExplorationDataGrid.SelectedValue;

            TestRunWorker testRunWorker = (TestRunWorker)faultModel.TestRunWorker;
            testRunWorker.Desired = runHeatPoint.Desired;
            testRunWorker.DisturbanceStartTime = runHeatPoint.Time;
            testRunWorker.RunWorkerCompleted += TestRunWorker_RunWorkerCompleted;

            progressController = await this.ShowProgressAsync("Running the model", "Please wait...");
            progressController.SetCancelable(false);
            progressController.SetIndeterminate();

            testRunWorker.RunWorkerAsync(faultModel);
            log("Disturbance Fault Model - Ran model with desired value " + runHeatPoint.Desired + " and disturbance start time " + runHeatPoint.Time);

        }
        async void jsonwb_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            _9GUSLauncher.MainWindow.config = JsonConvert.DeserializeObject<Config.Config>(e.Result);

            pause(1);
            StandardLog("SoftwareID " + Convert.ToString(config.SoftwareID) + " authenticated");
            mainForm.Title += " - ID " + Convert.ToString(config.SoftwareID);

            //Check for Updates

            StandardLog("Checking for Updates...");
            CheckForUpdates();
              //Create Update dir

                if (!Directory.Exists(workingDir + "\\Update"))
                {
                    Directory.CreateDirectory(workingDir + "\\Update");
                }
                else
                {
                    Directory.Delete(workingDir + "\\Update", true);
                    Directory.CreateDirectory(workingDir + "\\Update");
                }

                WebClient wb = new WebClient();

                if (result > 0)
                {
                    try
                    {
                        StandardLog("Version " + config.LatestVersion + " is available. Downloading...");
                        _controller = await this.ShowProgressAsync("Please wait...", "Downloading the update " + config.LatestVersion);
                        _controller.SetCancelable(false);
                        _controller.SetIndeterminate();
                        wb.DownloadFileAsync(new Uri(softwareCfg.updateFile), workingDir + "\\Update\\9GUSLauncher.exe");
                        wb.DownloadProgressChanged += new DownloadProgressChangedEventHandler(downloadProgress);
                        wb.DownloadFileCompleted += new AsyncCompletedEventHandler(completedDownload);
                    }
                    catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); }


                }
                else if (result < 0)
                {
                    StandardLog("You are running a Beta Version. No Updates will be done."); // the update system isn't in the freeze problem
                    //No Update, version is more than latest
                }
                else
                {
                    StandardLog("Version Stable. No Updates needed.");
                    //Version Stable
                    LeftToRightMarquee();
                    login_button.IsEnabled = true;
                }


        }
        private async void btnExportAll_Click(object sender, RoutedEventArgs e)
        {
            var folderDialog = new CommonOpenFileDialog();
            folderDialog.Title = "Where should I save your data?";
            folderDialog.IsFolderPicker = true;
            folderDialog.EnsureFileExists = true;
            folderDialog.EnsurePathExists = true;
            folderDialog.EnsureValidNames = true;
            folderDialog.EnsureReadOnly = false;
            folderDialog.Multiselect = false;
            folderDialog.ShowPlacesList = true;

            if (folderDialog.ShowDialog() == CommonFileDialogResult.Ok)
            {
                Telemetry.TrackEvent(TelemetryCategory.Export, Telemetry.TelemetryEvent.Export.Full);

                var folder = folderDialog.FileName;

                BandCloudManager.Instance.Events.Clear();

                _fullExportProgressDialog = await ((MetroWindow)(Window.GetWindow(this))).ShowProgressAsync("Exporting Full Activity Data", "Loading Activities list...");
                _fullExportProgressDialog.SetCancelable(true); // TODO: this needs to be implemented. No event?
                _fullExportProgressDialog.SetIndeterminate();

                // HACK HACK HACK HACK
                // TODO: add a Cancelled Event into the MahApps.Metro library

                // polling method to cancel the export if the user requests that it be cancelled
                Task.Run(async () =>
                {
                    while (_fullExportProgressDialog != null && _fullExportProgressDialog.IsOpen)
                    {
                        if (_fullExportProgressDialog.IsCanceled)
                        {
                            BandCloudManager.Instance.CancelFullExport = true;

                            Telemetry.TrackEvent(TelemetryCategory.Export, Telemetry.TelemetryEvent.Export.FullCancelled);

                            // we'd exit from the while loop anyway, but only when the progress dialog finally exits
                            // which can take up to 10 seconds, so might as well shut this down asap
                            return; 
                        }

                        await Task.Delay(500);
                    }
                });

                await LoadEvents();

                var progressIndicator = new Progress<BandCloudExportProgress>(ReportFullExportProgress);
                
                // TODO: progress reporter
                await BandCloudManager.Instance.ExportFullEventData(folder, ExportSettings, progressIndicator);

                _fullExportProgressDialog.CloseAsync();

                SaveExportSettings();
            }
        }
Exemple #22
0
 public ProgressStatistics( ProgressDialogController controller )
 {
     Controller = controller;
     Controller.SetIndeterminate();
 }
        public async Task LoadTheGameDbGame()
        {
            await Task.Factory.StartNew(async () =>
            {
                GiochiCaricati = string.Empty;
                await App.Current.Dispatcher.BeginInvoke((Action)async delegate ()
                {
                    progressDialog = await _dialogCoordinator.ShowProgressAsync(this, "Attendi...", "Attendi mentre carico la lista dei giochi", false, new MetroDialogSettings()
                    {
                        ColorScheme = MetroDialogColorScheme.Accented
                    });
                    progressDialog.SetIndeterminate();
                });
                
                IsReadOnlyTitleSearch = true;
                if (GamesDto.Count > 0)
                    GamesDto.Clear();
                List<GameSummary> gs = new List<GameSummary>();
                if (CurrentPlatform.Name != "Tutti")
                    gs = await _currentWebApi.TheGamesDBGameListByPlatform(DataInizio, DataFine, CurrentPlatform);
                else
                    AvailablePlatforms.Where(x => x.Name != "Tutti").ToList().ForEach(async _currentPlatform =>
                    {
                        gs.AddRange(await _currentWebApi.TheGamesDBGameListByPlatform(DataInizio, DataFine, _currentPlatform));
                    });

                await App.Current.Dispatcher.BeginInvoke((Action)async delegate ()
                {
                    await progressDialog.CloseAsync();
                });

                int numGiochi = gs.Count;
                int giocoCorrente = 0;
                double percentageToIncrement = (double)100 / numGiochi;
                ProgressBarValue = 0;

                gs.ForEach(async currentGameSummary =>
                {
                    try
                    {
                        if (await _currentWebApi.GetGameByFieldSearch(new Game() { ImportId = currentGameSummary.ID }) == default(Game))
                        {
                            GameDto result = _mapper.Map<GameDto>(await _currentWebApi.TheGamesDBGetGameDetails(currentGameSummary));
                            await App.Current.Dispatcher.BeginInvoke((Action)delegate ()
                            {
                                GamesDto.Add(result);
                            });
                        }
                    }
                    catch (Exception ex)
                    {
                        numGiochi--;
                        giocoCorrente--;
                        string a = ex.Message;
                    }
                    finally
                    {
                        giocoCorrente++;
                        GiochiCaricati = string.Format("{0} / {1}", giocoCorrente, numGiochi);
                        ProgressBarValue += percentageToIncrement;
                        if (numGiochi == giocoCorrente)
                        {
                            await App.Current.Dispatcher.BeginInvoke((Action)async delegate ()
                            {
                                await _dialogCoordinator.ShowMessageAsync(this, "Caricamento completato...", "Puoi modificare i giochi prima dell'importazione",  MessageDialogStyle.Affirmative, new MetroDialogSettings()
                                {
                                    ColorScheme = MetroDialogColorScheme.Accented
                                });                                
                            });                            
                            IsReadOnlyTitleSearch = false;
                        }
                    }                
                });
            });
        }