예제 #1
0
        /// <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;
            }));
        }
예제 #2
0
        // Retrieve all usable MP4 files in a directory
        private void OpenWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // Update the progress message and set to indeterminate
            _progressDlg.SetMessage("Scanning Directory for compatible files.\r\nExtracting GPS Coordinates and Speed Data.");
            _progressDlg.SetIndeterminate();

            // Organise into journies
            gpsWorker.RunWorkerAsync();
            gpsWorker2.RunWorkerAsync();
        }
예제 #3
0
 private async void Button_OnClick(object sender, RoutedEventArgs e)
 {
     MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
     await Dispatcher.InvokeAsync(new Action(async() =>
     {
         MainDialogController =
             await this.ShowProgressAsync("Searching Users", "Please Wait...");
         MainDialogController.SetIndeterminate();
         try
         {
             await TalosQuests.Instance.SearchUsers(searchUserField.Text);
             await Task.Run(() =>
             {
                 Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
                 {
                     userGrid.ItemsSource = null;
                     userGrid.Items.Refresh();
                     userGrid.ItemsSource = TalosQuests.Instance.Users;
                     userGrid.Items.Refresh();
                 }));
             });
             await MainDialogController.CloseAsync();
         }
         catch (TalosQuestsException exc)
         {
             MainDialogController.SetMessage("Error: \n" + exc.Message);
             MainDialogController.SetCancelable(true);
             MainDialogController.Canceled += (o, args) => MainDialogController.CloseAsync();
         }
     }));
 }
예제 #4
0
        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( );
        }
예제 #5
0
        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( );
        }
예제 #6
0
        private async Task RunAsync()
        {
            var configuration = new Configuration
            {
                VsTemplate = VsTemplates.Text,
                VsProject  = VsProjects.Text
            };

            Cursor         = Cursors.Wait;
            _configuration = configuration;

            var options = new MetroDialogSettings
            {
                ColorScheme = MetroDialogColorScheme.Theme
            };

            MetroDialogOptions = options;
            _controller        = await this.ShowProgressAsync("Please wait...", "Repositories are getting migrated.", true, options);

            _controller.SetIndeterminate();
            _controller.Canceled += ControllerCanceled;
            await RunRepositoryMigrationAsync();

            TaskCompleted();
        }
예제 #7
0
        private async void buttonUpdateDownloadlist_Click(object sender, RoutedEventArgs e)
        {
            ProgressDialogController pdc = await this.ShowProgressAsync("更新下载列表", "操作进行中", false);

            pdc.SetIndeterminate();
            this.downloadListAll.Clear();

            List <Task> taskList = new List <Task>();

            foreach (RssListBinding rlb in this.viewModel.RssList)
            {
                await Task.Run(new Action(() => this.database.UpdateRssList(rlb))).ConfigureAwait(false);

                if (rlb.Selected)
                {
                    if (taskList.Count < MaxThreadNumber)
                    {
                        taskList.Add(GetRSS(rlb));
                    }
                    else
                    {
                        taskList.Remove(await Task.WhenAny(taskList));
                        taskList.Add(GetRSS(rlb));
                    }
                }
            }

            await Task.WhenAll(taskList);

            await this.Dispatcher.BeginInvoke(new Action(() => UpdateDataGridDownloadList()));

            await pdc.CloseAsync();
        }
예제 #8
0
        private async void OnConnectClick(object Sender, RoutedEventArgs E)
        {
            ProgressDialogController controller = await(( MetroWindow )Window.GetWindow(this)).ShowProgressAsync("Signing in.", "Attempting to sign in with the new credentials.");

            controller.SetIndeterminate( );

            Settings.Default.OSUsername = Username.Text;
            Settings.Default.Save( );

            Client           tester = new Client(MainWindow.UserAgent);
            BackgroundWorker worker = new BackgroundWorker(  );

            worker.DoWork += (sender, args) =>
            {
                Tuple <string, string> info   = args.Argument as Tuple <string, string>;
                LogInOutput            output = tester.LogIn(info.Item1, info.Item2, info.Item1.Length != info.Item2.Length || info.Item1.Length > 0);
                args.Result = output;
            };
            worker.RunWorkerCompleted += async(O, Args) =>
            {
                await controller.CloseAsync( );

                LogInOutput output = ( LogInOutput )Args.Result;
                this.IsSignedIn        = output.LogInSuccesful;
                StatusImage.Visibility = Visibility.Visible;
                StatusLabel.Visibility = Visibility.Visible;

                StatusLabel.Content = !this.IsSignedIn ? output.StatusString.Substring(4) : string.Empty;
            };
            worker.RunWorkerAsync(new Tuple <string, string>(Username.Text, Password.Password));
        }
예제 #9
0
        private async Task RunTestDataGenerationConfigurationAsync()
        {
            TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate;
            Cursor = Cursors.Wait;

            _unityContainer = new UnityContainer();
            _unityContainer.RegisterInstance(TestDataLength.Value);
            _unityContainer.RegisterInstance(DataType.Text);

            var options = new MetroDialogSettings
            {
                ColorScheme = MetroDialogColorScheme.Accented
            };

            MetroDialogOptions = options;
            _controller        = await this.ShowProgressAsync("Please wait...", "Testdata are getting generated.", true, options);

            _controller.SetIndeterminate();
            _controller.Canceled += ControllerCanceled;

            _tokenSource = new CancellationTokenSource();
            var token = _tokenSource.Token;

            _task = Task.Factory.StartNew(() => RunTestDataGeneration(token), token);
            await _task;

            _task.GetAwaiter().OnCompleted(TaskCompleted);
        }
예제 #10
0
        private async Task <bool> ShowProgress(string title, string message, bool isCancelable = false, TMPDialogSettings settings = null)
        {
            statusBarAppStatus.Content = message;

            await CloseProgress();

            if (settings == null)
            {
                settings = new TMPDialogSettings()
                {
                    AnimateHide = false, AnimateShow = false
                }
            }
            ;

            if (progressController != null)
            {
                if (progressController.IsOpen == true)
                {
                    progressController.SetMessage(message);
                }
                else
                {
                    progressController = await this.ShowProgressAsync(MainViewModel.Instance.Title, message, isCancelable, settings);
                }
            }
            else
            {
                progressController = await this.ShowProgressAsync(title, message, isCancelable, settings);

                progressController.SetIndeterminate();
            }
            return(true);
        }
예제 #11
0
        public async Task LockUi(string title = null, string msg = null, object caller = null)
        {
            await _lockScreenSemaphore.WaitAsync();

            if (IsUiLocked)
            {
                _lockScreenSemaphore.Release();
                return;
            }
            if (title == null)
            {
                title = UIStrings.Loading;
            }

            if (msg == null)
            {
                msg = UIStrings.Please_Wait;
            }

            _lockProgressController = await this.ShowProgressAsync(title, msg);

            _lockProgressController.SetIndeterminate();

            _lockProgress = new Progress <string>((update) =>
            {
                _lockProgressController.SetMessage(update);
            });

            _lockScreenSemaphore.Release();

            if (UiLocked != null)
            {
                UiLocked.Invoke(caller, null);
            }
        }
예제 #12
0
        private async Task ReloadScheme()
        {
            ProgressDialogController dialogController = null;

            try
            {
                dialogController = await _dialogCoordinator.ShowProgressAsync(this, "Scheme Loading", "Loading...");

                dialogController.SetIndeterminate();
                _scheme = await _repository.LoadScheme();

                Scheme.Reload(_scheme);
                await dialogController.CloseAsync();
            }
            catch (Exception e)
            {
                if (dialogController != null)
                {
                    await dialogController.CloseAsync();
                }

                await _dialogCoordinator.ShowMessageAsync(this, "Error", e.Message);

                Close();
            }
        }
예제 #13
0
        public MainWindow()
        {
            InitializeComponent();


            ProgressDialogController controller = null;



            UC_AIFSetting.OnProcessing += async() => {
                controller = await this.ShowProgressAsync("Please wait...", "Saving the data");

                controller.SetIndeterminate();
                fy_Settings.IsEnabled = false;
            };


            UC_AIFSetting.OnProcessed += async(m, i) => {
                loadMissions();

                controller.SetMessage("Success.");
                await Task.Delay(1000);

                if (controller != null)
                {
                    await controller.CloseAsync();
                }


                fy_Settings.IsEnabled = true;
                fy_Settings.IsOpen    = false;
            };
        }
예제 #14
0
        /// <summary>
        /// </summary>
        /// <returns></returns>
        public async Task ConfigureController()
        {
            TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Indeterminate;

            var configuration = new Configuration
            {
                PathsToScan       = _pathsToScan,
                HashTypes         = _applicationSettings.CurrentHashAlgorithms.Cast <string>().ToList(),
                LoggingPath       = _loggingPath,
                KeepFileExtension = _applicationSettings.KeepFileExtension
            };

            Cursor         = Cursors.Wait;
            _configuration = configuration;
            var options = new MetroDialogSettings
            {
                ColorScheme = MetroDialogColorScheme.Accented
            };

            MetroDialogOptions = options;
            _controller        = await this.ShowProgressAsync("Please wait...", "Hashes are getting generated.", true, options);

            _controller.SetIndeterminate();
            _controller.Canceled += ControllerCanceled;
            _task = Task <ObservableCollection <LogEntry> > .Factory.StartNew(RunHashCalculation);

            await _task;

            _task.GetAwaiter().OnCompleted(TaskCompleted);
            _logEntries = _task.Result;
        }
예제 #15
0
        private async Task BusyBox(string Message = null, string Title = null)
        {
            IsReady = false;
            progressDialogController = await Me.ShowProgressAsync(Title ?? "稍等片刻...", Message ?? "老子正在执行一些后台任务。");

            progressDialogController.SetIndeterminate();
        }
예제 #16
0
 private async void wipeQuests_Click(object sender, RoutedEventArgs e)
 {
     MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
     await Dispatcher.InvokeAsync(new Action(async() =>
     {
         MainDialogController =
             await this.ShowProgressAsync("Wiping Quests", "Please Wait...");
         MainDialogController.SetIndeterminate();
         try
         {
             var state = await TalosQuests.Instance.WipeQuests();
             await Task.Run(() =>
             {
                 Dispatcher.Invoke(DispatcherPriority.Normal, new Action(async() =>
                 {
                     if (state)
                     {
                         MainDialogController.SetMessage("Quests Wiped.");
                         await TalosQuests.Instance.FetchInfo();
                     }
                 }));
             });
             await MainDialogController.CloseAsync();
         }
         catch (TalosQuestsException exc)
         {
             MainDialogController.SetMessage("Error: \n" + exc.Message);
             MainDialogController.SetCancelable(true);
             MainDialogController.Canceled += (o, args) => MainDialogController.CloseAsync();
         }
     }));
 }
예제 #17
0
        private async void RemoveFileButton_OnClick(object sender, RoutedEventArgs e)
        {
            ProgressDialogController controller = await this.ShowProgressAsync("Удаление файла", "Подождите идет удаление файла на сервере...");

            controller.SetIndeterminate();

            FileInfoEx fileInfoEx = FilesDataGrid.SelectedItem as FileInfoEx;

            if (fileInfoEx != null)
            {
                try
                {
                    using (FileTransferServiceClient client = new FileTransferServiceClient())
                    {
                        await client.RemoveAsync(fileInfoEx);
                    }

                    await this.ShowMessageAsync("Удаление файла", "Файл был успешно удален!");

                    GetFilesList();
                }
                catch (Exception exception)
                {
                    await this.ShowMessageAsync("Ошибка", exception.Message);
                }
            }

            await controller.CloseAsync();
        }
예제 #18
0
        public async void DeleteCamera(string id, string videoStreamArn, string dataStreamName, string eventSourceUUID, string streamProcessorName, CameraView cv)
        {
            ProgressDialogController controller = await this.ShowProgressAsync("Please wait...", "");

            controller.SetIndeterminate();
            controller.SetCancelable(false);

            controller.SetMessage("Deleting event source mapping");
            await Task.Run(() => Models.Lambda.DeleteEventSourceMapping(eventSourceUUID));

            controller.SetMessage("Deleting data stream");
            await Task.Run(() => Models.DataStream.DeleteDataStream(dataStreamName));

            controller.SetMessage("Deleting video stream");
            await Task.Run(() => Models.VideoStream.DeleteVideoStream(videoStreamArn));

            controller.SetMessage("Deleting stream processor");
            await Task.Run(() => Models.StreamProcessorManager.DeleteStreamProcessor(streamProcessorName));

            controller.SetMessage("Deleting database record");
            await Task.Run(() => Models.Dynamodb.DeleteItem(id, Models.MyAWSConfigs.CamerasDBTableName));

            await controller.CloseAsync();

            cv.LoadCamerasData().ConfigureAwait(false);

            notifyIcon.Visible = true;
            notifyIcon.ShowBalloonTip(1000, "Deleted", "Camera deleted Successfully", System.Windows.Forms.ToolTipIcon.Info);
        }
예제 #19
0
        /// <summary>
        /// Start Progeess dialog using the Active Window <see cref="ActiveWindow"/>
        /// </summary>
        /// <param name="title">The progress dialog title.</param>
        /// <param name="msg">The progress dialog message.</param>
        /// <returns></returns>
        public static async Task ShowProgressDialog(String title, String msg)
        {
            ProgressController = await ActiveWindow.ShowProgressAsync(title, msg);

            ProgressController.SetCancelable(false);
            ProgressController.SetIndeterminate();
        }
예제 #20
0
        private async void XLogin_OnClick(object sender, RoutedEventArgs e)
        {
            this.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;
            AuthDialogController = await this.ShowProgressAsync("Login", "Please Wait...");

            AuthDialogController.SetIndeterminate();

            var state = await TalosQuests.Instance.Login(xUsername.Text, xPassword.Password);

            if (state)
            {
                AuthDialogController.SetMessage("Welcome.\nLoading Data...");
                await TalosQuests.Instance.FetchInfo();

                await AuthDialogController.CloseAsync();

                MainWindow l = new MainWindow();
                l.Show();
                Close();
            }
            else
            {
                await Task.Run(() =>
                {
                    Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
                    {
                        AuthDialogController.SetMessage(
                            "Either your Credentials are incorrect either your have no access.");
                    }));
                    Thread.Sleep(3000);
                });

                await AuthDialogController.CloseAsync();
            }
        }
예제 #21
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();
            }
        }
예제 #22
0
        public async Task RestartService()
        {
            ProgressDialogController progress = null;

            try
            {
                progress = await this.dialogCoordinator.ShowProgressAsync(this, "Restarting service", "Waiting for the service to stop", false);

                progress.SetIndeterminate();

                await this.windowsServiceProvider.StopServiceAsync();

                progress.SetMessage("Wating for the service to start");

                await this.windowsServiceProvider.StartServiceAsync();
            }
            catch (Exception ex)
            {
                logger.LogError(EventIDs.UIGenericError, ex, "Could not restart service");
            }
            finally
            {
                if (progress?.IsOpen ?? false)
                {
                    await progress.CloseAsync();
                }
            }
        }
예제 #23
0
        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);
        }
        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);
        }
예제 #25
0
        private async void ButtonSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool isNameEmpty        = string.IsNullOrEmpty(txtName.Text);
                bool isDescriptionEmpty = string.IsNullOrEmpty(txtDescription.Text);
                bool isFilePathEmpty    = string.IsNullOrEmpty(uploadFilePath);
                bool isFileIdEmpty      = string.IsNullOrEmpty(txtId.Text);
                bool isPhoneEmpty       = string.IsNullOrEmpty(txtPhone.Text);

                if (!isNameEmpty && !isDescriptionEmpty && !isFilePathEmpty && !isFileIdEmpty && !isPhoneEmpty)
                {
                    ProgressDialogController controller = await this.ShowProgressAsync("Please wait...", "Uploading data");

                    controller.SetIndeterminate();
                    controller.SetCancelable(false);

                    string[] temp   = uploadFilePath.Split('.');
                    string   propic = $"{txtId.Text}.{temp[temp.Length - 1]}";

                    var r_item = new Document();

                    List <String> SelectedPeople = new List <String>();
                    SelectedPeople = GetCheckedRefPeople();

                    r_item["id"]          = txtId.Text;
                    r_item["name"]        = txtName.Text;
                    r_item["description"] = txtDescription.Text;
                    r_item["phone"]       = txtPhone.Text;
                    r_item["refList"]     = SelectedPeople;
                    r_item["propic"]      = propic;

                    await Task.Run(() => Models.S3Bucket.UploadFile(uploadFilePath, propic, Models.MyAWSConfigs.ReaderS3BucketName));

                    await Task.Run(() => Models.Dynamodb.PutItem(r_item, Models.MyAWSConfigs.ReaderDBtableName));

                    await controller.CloseAsync();

                    await this.ShowMessageAsync("Success", "New Person added", MessageDialogStyle.Affirmative);

                    txtName.Text          = "";
                    txtDescription.Text   = "";
                    txtId.Text            = "";
                    txtPhone.Text         = "";
                    imgUploadImage.Source = null;

                    GiveRedersToRefernces(SelectedPeople, propic);
                }
                else
                {
                    await this.ShowMessageAsync("Error", "Fill All The Fields", MessageDialogStyle.Affirmative);
                }
            }
            catch
            {
                await this.ShowMessageAsync("Error", "Task not completed", MessageDialogStyle.Affirmative);
            }
        }
예제 #26
0
        private async Task ValidateData(bool silent)
        {
            var uiWorkflow  = IoC.Resolve <IUiWorkflow>();
            var textService = IoC.Resolve <ITextService>();
            ProgressDialogController waiter = null;

            if (!silent)
            {
                waiter = await DialogCoordinator.Instance.ShowProgressAsync(uiWorkflow,
                                                                            textService.Compile("Validate.Progress.Title", CultureInfo.CurrentUICulture, out _).ToString(),
                                                                            textService.Compile("Validate.Progress.Message", CultureInfo.CurrentUICulture, out _).ToString()
                                                                            );

                waiter.SetIndeterminate();
            }

            try
            {
                MailData previewData;
                await using (var strategy = Create())
                {
                    previewData = await strategy.GetPreviewData();
                }

                ValidationState.IsValidated = previewData != null;
                StructureCacheService.SetExampleData(previewData);

                if (!silent)
                {
                    await waiter.CloseAsync();

                    if (!ValidationState.IsValidated)
                    {
                        await DialogCoordinator.Instance.ShowMessageAsync(uiWorkflow,
                                                                          textService.Compile("ImportData.Errors.Validate.Title", CultureInfo.CurrentUICulture, out _)
                                                                          .ToString(),
                                                                          textService.Compile("ImportData.Errors.Validate.Description", CultureInfo.CurrentUICulture,
                                                                                              out _,
                                                                                              new FormattableArgument("ImportData.Errors.Validate.GeneralError", true)).ToString()
                                                                          );
                    }
                }
            }
            catch (Exception e)
            {
                if (!silent)
                {
                    await waiter.CloseAsync();

                    await DialogCoordinator.Instance.ShowMessageAsync(uiWorkflow,
                                                                      textService.Compile("ImportData.Errors.Validate.Title", CultureInfo.CurrentUICulture, out _).ToString(),
                                                                      textService.Compile("ImportData.Errors.Validate.Description", CultureInfo.CurrentUICulture, out _,
                                                                                          new FormattableArgument(e.Message, false)).ToString()
                                                                      );
                }
            }
        }
예제 #27
0
        private async void ButtonSubmit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool isFilePathEmpty = string.IsNullOrEmpty(uploadFilePath);

                if (!isFilePathEmpty)
                {
                    ProgressDialogController controller = await this.ShowProgressAsync("Please wait...", "Uploading data");

                    controller.SetIndeterminate();
                    controller.SetCancelable(false);

                    string[] temp   = uploadFilePath.Split('.');
                    string   fileId = $"{myId}.{temp[temp.Length - 1]}";

                    string BaseDirectoryPath = AppDomain.CurrentDomain.BaseDirectory;
                    string filePath          = BaseDirectoryPath + $"Resources\\Images\\{fileId}";

                    Item   item     = Dynamodb.GetItem(myId, MyAWSConfigs.AdminDBTableName);
                    string oldImage = item["aPropic"];
                    Console.WriteLine("><><><><><><><><><><>" + oldImage);

                    //Delete old profile pic in local
                    //string oldFilePath = BaseDirectoryPath + $"Resources\\Images\\{oldImage}";
                    //DeleteOldPic(oldFilePath);

                    //Delete old profile pic in s3Bucket
                    S3Bucket.DeleteFile(oldImage, MyAWSConfigs.AdminS3BucketName);

                    item["aPropic"] = fileId;

                    await Task.Run(() => Models.S3Bucket.UploadFile(uploadFilePath, fileId, MyAWSConfigs.AdminS3BucketName));

                    MessageBox.Show(fileId);
                    await Task.Run(() => Models.Dynamodb.UpdateItem(item, Models.MyAWSConfigs.AdminDBTableName));

                    await controller.CloseAsync();

                    await this.ShowMessageAsync("Success", "Changed Successfully..", MessageDialogStyle.Affirmative);

                    //activity recorded
                    Models.ActivityLogs.Activity(Models.Components.AdminComponent, "User Changed Profile Picture");

                    //imgUploadImage.Source = null;
                }
                else
                {
                    await this.ShowMessageAsync("Error", "Please check all fields", MessageDialogStyle.Affirmative);
                }
            }
            catch
            {
                await this.ShowMessageAsync("Error", "Task not completed", MessageDialogStyle.Affirmative);
            }
        }
예제 #28
0
        public async void workerRun()
        {
            // Tidy the Log File & Notify User
            MetroWindow w = (MetroWindow)Application.Current.MainWindow;

            _progressDlg = await w.ShowProgressAsync("Tidying Log File", "NovaTrakt is tidying your log file.\r\nThis process may take a while if it is the first time it has been run.");

            _progressDlg.SetIndeterminate();
            worker.RunWorkerAsync();
        }
        private async void OnSavePost()
        {
            ProgressDialogController progressController = await _dialogCoordinator.ShowProgressAsync(this, AppContext.Instance.ApplicationName, "Generating markdown...");

            progressController.SetIndeterminate();
            progressController.SetMessage($"Generating...{SelectedPost.Title.ToHtmlDecodedString()}");
            await SavePost(SelectedPost, true, progressController);

            await progressController.CloseAsync();
        }
예제 #30
0
        public async void AddAction(WorkerTask task)
        {
            Tasks.Add(task);
            if (!LoadDataWorker.IsBusy)
            {
                progressDialog = await DialogManager.ShowProgressAsync(Application.Current.MainWindow as MetroWindow, task.Title, task.Description);

                progressDialog.SetIndeterminate();
                LoadDataWorker.RunWorkerAsync();
            }
        }