SetCancelable() публичный Метод

Sets if the Cancel button is visible.
public SetCancelable ( bool value ) : void
value bool
Результат void
 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);
 }
Пример #2
0
 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();
 }
Пример #3
0
        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;
                }


        }
Пример #4
0
        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();
        }
Пример #5
0
        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();
            }
        }
Пример #6
0
        public async void eventloadBase()
        {
            if(eventUpdating == false)
            {
                comboMap.Items.Add("Stratis");
                comboMap.Items.Add("Altis");
                comboMap.Items.Add("Takistan");
                comboMap.Items.Add("Chernarous");
                comboMap.Items.Add("Bukovina");
                comboMap.Items.Add("Kunduz");

                comboType.Items.Add("COOP");
                comboType.Items.Add("PvP Public");
                comboType.Items.Add("PvP Private");

                comboMapMod.Items.Add("Stratis");
                comboMapMod.Items.Add("Altis");
                comboMapMod.Items.Add("Takistan");
                comboMapMod.Items.Add("Chernarous");
                comboMapMod.Items.Add("Bukovina");
                comboMapMod.Items.Add("Kunduz");

                comboTypeMod.Items.Add("COOP");
                comboTypeMod.Items.Add("PvP Public");
                comboTypeMod.Items.Add("PvP Private");

                try
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
                    {
                        _controller = await this.ShowProgressAsync("Please wait...", "Setting up Events & Configs...\r\n\r\nThis operation may take some minutes...");
                        _controller.SetCancelable(false);
                        if (!string.IsNullOrEmpty(modPath))
                        {
                            string[] folders = System.IO.Directory.GetDirectories(modPath, "@*", System.IO.SearchOption.AllDirectories);

                            foreach (string folder in folders)
                            {
                                string input = folder;
                                string output = input.Split('@').Last();
                                modList.Items.Add("@" + output);
                                modListMod.Items.Add("@" + output);
                            }
                        }
                        else
                        {
                            modList.Items.Add("Please Select the Mods Path and restart the Application!");
                            modListMod.Items.Add("Please Select the Mods Path and restart the Application!");
                            eventCreate.IsEnabled = false;
                            eventMod.IsEnabled = false;
                        }

                        if (!Directory.Exists(workingDir + "\\Config"))
                        {
                            Directory.CreateDirectory(workingDir + "\\Config");

                        }
                        else
                        {
                            Directory.Delete(workingDir + "\\Config", true);
                            Directory.CreateDirectory(workingDir + "\\Config");
                        }


                        if (config.events != null)
                        {
                            foreach (string files in config.events)
                            {
                                DownloadFiles(files);
                            }
                        }

                        //Read events files

                        foreach (string _event in config.events)
                        {
                            eventListView.Items.Add(_event.Replace("_", " "));
                        }



                        pause(5);
                        await _controller.CloseAsync();

                    }));
                }
                catch (Exception ex)
                { System.Windows.MessageBox.Show(ex.ToString()); }
            }
            else
            {
                try
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
                    {
                        _controller = await this.ShowProgressAsync("Please wait...", "Updating Events & Configs...");
                        _controller.SetCancelable(false);
                        if (!string.IsNullOrEmpty(modPath))
                        {
                            string[] folders = System.IO.Directory.GetDirectories(modPath, "@*", System.IO.SearchOption.AllDirectories);
                            modList.Items.Clear();
                            modListMod.Items.Clear();
                            
                            foreach (string folder in folders)
                            {
                                string input = folder;
                                string output = input.Split('@').Last();
                                modList.Items.Add("@" + output);
                                modListMod.Items.Add("@" + output);
                            }
                        }
                        else
                        {
                            modList.Items.Add("Please Select the Mods Path and restart the Application!");
                            modListMod.Items.Add("Please Select the Mods Path and restart the Application!");
                            eventCreate.IsEnabled = false;
                            eventMod.IsEnabled = false;
                        }

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


                        if (config.events != null)
                        {
                            foreach (string files in config.events)
                            {
                                DownloadFiles(files);
                            }
                        }

                        //Read events files

                        foreach (string _event in config.events)
                        {
                            eventListView.Items.Add(_event.Replace("_", " "));
                        }

                        eventUpdating = false;
                        pause(5);
                        await _controller.CloseAsync();

                    }));
                }
                catch (Exception ex)
                { System.Windows.MessageBox.Show(ex.ToString()); }
            }
            

        }
Пример #7
0
        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();
        }
Пример #8
0
        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();
            }
        }
Пример #9
0
        private async void ExportEventSummaryToCSV(int? count = null)
        {
            Telemetry.TrackEvent(TelemetryCategory.Export, Telemetry.TelemetryEvent.Export.Summary);

            var saveDialog = new SaveFileDialog();
            saveDialog.AddExtension = true;
            saveDialog.FileName = "band_export.csv";
            saveDialog.DefaultExt = ".csv";

            var result = saveDialog.ShowDialog();

            if (result == true)
            {
                _summaryExportProgressDialog = await ((MetroWindow)(Window.GetWindow(this))).ShowProgressAsync("Exporting Data", "...");
                _summaryExportProgressDialog.SetCancelable(true); // TODO: this needs to be implemented. No event?
                _summaryExportProgressDialog.SetProgress(0);

                var progressIndicator = new Progress<BandCloudExportProgress>(ReportSummaryExportProgress);

                await BandCloudManager.Instance.ExportEventsSummaryToCSV(count, ExportSettings, saveDialog.FileName, progressIndicator);

                _summaryExportProgressDialog.CloseAsync();

                if (ExportSettings.OpenFileAfterExport)
                {
                    Process.Start(saveDialog.FileName);                    
                }

                SaveExportSettings();
            }
        }
Пример #10
0
        private static async Task WaitForCancel(ProgressDialogController dialog, string message)
        {
            dialog.SetMessage("Failed: " + message);
            dialog.SetCancelable(true);

            while (!dialog.IsCanceled)
                await Task.Delay(10);

            await dialog.CloseAsync();
        }
        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 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 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);

        }