private async void Incluir() { Request.Alimento = View.Alimento; Request.Peso = View.Peso; Request.Proteina = View.Proteina; Request.Carboidrato = View.Carboidrato; Request.Gordura = View.Gordura; Request.Caloria = View.Caloria; var alimentoCriado = alimentoService.Incluir(Request, "Carlosg"); if (!alimentoService.Validar) { var linq = alimentoService.Notificacoes.Select(msg => msg.Mensagem); await this.dialog.ShowMessageAsync(this, "Atenção", string.Join("\r\n", linq)); alimentoService.LimparNotificacoes(); } if (alimentoCriado != null) { Progresso = await dialog.ShowProgressAsync(this, "Progresso", "Incluindo dados do alimento. Aguarde..."); Progresso.SetIndeterminate(); var t = Task.Factory.StartNew(() => { BuscarAlimentos(); }); await t; await Progresso?.CloseAsync(); await this.dialog.ShowMessageAsync(this, "Atenção", "Alimento cadastrado com sucesso !!!"); Limpar(); } }
private async void Incluir() { Request.Id = View.Id; Request.Nome = View.Nome; Request.Telefone = View.Telefone; var clienteCriado = clienteService.Incluir(Request, "Carlosg"); if (!clienteService.Validar) { var linq = clienteService.Notificacoes.Select(msg => msg.Mensagem); await this.dialog.ShowMessageAsync(this, "Atenção", string.Join("\r\n", linq)); clienteService.LimparNotificacoes(); } if (clienteCriado != null) { Progresso = await dialog.ShowProgressAsync(this, "Progresso", "Incluindo dados do cliente. Aguarde..."); Progresso.SetIndeterminate(); var t = Task.Factory.StartNew(() => { Limpar(); }); await t; await Progresso?.CloseAsync(); await this.dialog.ShowMessageAsync(this, "Atenção", "Cliente cadastrado com sucesso !!!"); //Limpar(); } }
private async void Incluir() { Request.Descricao = View.Descricao; Request.CargaHoraria = View.CargaHoraria; Request.Valor = View.Valor; var cursoCriado = cursoService.Incluir(Request, "Carlosg"); if (!cursoService.Validar) { var linq = cursoService.Notificacoes.Select(msg => msg.Mensagem); await this.dialog.ShowMessageAsync(this, "Atenção", string.Join("\r\n", linq)); cursoService.LimparNotificacoes(); } if (cursoCriado != null) { Progresso = await dialog.ShowProgressAsync(this, "Progresso", "Incluindo dados do curso. Aguarde..."); Progresso.SetIndeterminate(); var t = Task.Factory.StartNew(() => { BuscarCursos(); }); await t; await Progresso?.CloseAsync(); await this.dialog.ShowMessageAsync(this, "Atenção", "Curso cadastrado com sucesso !!!"); Limpar(); } }
private async void Incluir() { var novoAluno = new Aluno(Aluno.Nome, Aluno.Endereco, Aluno.Bairro, Aluno.Cidade); var alunoCriado = alunoService.Incluir(novoAluno); if (!alunoService.Validar) { var linq = alunoService.Notifications.Select(msg => msg.Mensagem); await this.dialog.ShowMessageAsync(this, "Atenção", string.Join("\r\n", linq)); alunoService.ClearNotifications(); } if (alunoCriado != null) { Progresso = await dialog.ShowProgressAsync(this, "Progresso", "Incluindo dados do aluno. Aguarde..."); Progresso.SetIndeterminate(); var t = Task.Factory.StartNew(() => { BuscarAlunos(); }); await t; await Progresso?.CloseAsync(); await this.dialog.ShowMessageAsync(this, "Atenção", "Aluno cadastrado com sucesso !!!"); Limpar(); } }
private async void Incluir() { Request.Id = View.Id; Request.IdCliente = ClienteView.Id; Request.Data = View.Data; Request.Valor = View.Valor; var compraEfetuada = comprarFichaService.Incluir(Request, "Carlosg"); if (!comprarFichaService.Validar) { var linq = comprarFichaService.Notificacoes.Select(msg => msg.Mensagem); await this.dialog.ShowMessageAsync(this, "Atenção", string.Join("\r\n", linq)); comprarFichaService.LimparNotificacoes(); } if (compraEfetuada != null) { Progresso = await dialog.ShowProgressAsync(this, "Progresso", "Efetuando compra de fichas. Aguarde..."); Progresso.SetIndeterminate(); var t = Task.Factory.StartNew(() => { Limpar(); }); await t; await Progresso?.CloseAsync(); await this.dialog.ShowMessageAsync(this, "Atenção", "Compra efetuada com sucesso !!!"); //Limpar(); } }
private async void Incluir() { Request.Id = View.Id; Request.IdDealer = DealerView.Id; Request.Data = View.Data; Request.Valor = View.Valor; var caixinhaDada = caixinhaService.Incluir(Request, "Carlosg"); if (!caixinhaService.Validar) { var linq = caixinhaService.Notificacoes.Select(msg => msg.Mensagem); await this.dialog.ShowMessageAsync(this, "Atenção", string.Join("\r\n", linq)); caixinhaService.LimparNotificacoes(); } if (caixinhaDada != null) { Progresso = await dialog.ShowProgressAsync(this, "Progresso", "Registrando caixinha para dealer. Aguarde..."); Progresso.SetIndeterminate(); var t = Task.Factory.StartNew(() => { Limpar(); }); await t; await Progresso?.CloseAsync(); await this.dialog.ShowMessageAsync(this, "Atenção", "Caixinha para dealer registrada com sucesso !!!"); //Limpar(); } }
public async Task <ProgressDialogController> GetProgressDialog(MessageDialogOption options) { return(await _dialog.ShowProgressAsync(options.Context, options.Title, options.Message, options.CancellationToken != default(CancellationToken), options)); }
/// <summary> /// Downloads a statement from the net and then parses it. /// </summary> /// <param name="name">The name of the parser and downloader.</param> public async Task LoadFromWeb(string name) { var downloader = await GetDownloaderByName(name).ConfigureAwait(false); if (downloader == null) { return; } var parser = await GetParserByName(name).ConfigureAwait(false); if (parser == null) { return; } ProgressDialogController progress = await _dialogService.ShowProgressAsync(_mainVm, "Load Statement from Web", "Downloading").ConfigureAwait(false); Exception ex = null; string flex = ""; try { flex = await downloader.DownloadStatement().ConfigureAwait(false); } catch (Exception e) { ex = e; } if (flex == "" || ex != null) { await progress.CloseAsync().ConfigureAwait(true); await _dialogService.ShowMessageAsync(_mainVm, "Error downloading statement", ex?.Message).ConfigureAwait(true); return; } await Task.Run(() => parser.Parse(flex, progress)).ConfigureAwait(true); progress.SetMessage("Updating open trades"); await _tradeRepository.UpdateOpenTrades().ConfigureAwait(true); await _tradeRepository.Save().ConfigureAwait(true); progress.CloseAsync().Forget(); }
public async Task Initialize() { var progressDialog = await m_dialogCoordinator.ShowProgressAsync(this, "Initializing Retrospecive Client", "Initializing Retrospecive Client..."); progressDialog.SetProgress(0); try { progressDialog.SetMessage("Initializing User Configuration"); UserConfigurationViewModel.Initialize(LogViewModel); progressDialog.SetProgress(0.33); RaisePropertyChanged(() => UserConfigurationViewModel); RaisePropertyChanged(() => ZoomViewModel); progressDialog.SetMessage("Checking User Configuration"); if (!UserConfigurationViewModel.UserConfiguration.IsAllRequiredSet) { UserConfigurationViewModel.OpenConfigurationCommand.Execute(null); } progressDialog.SetProgress(0.66); progressDialog.SetMessage("Preparing retrospective"); RetroViewModel.Initialize(this, LogViewModel); RaisePropertyChanged(() => RetroViewModel); progressDialog.SetProgress(1); } catch (Exception e) { LogViewModel.Log <Error>(e); } await progressDialog.CloseAsync(); }
private async Task <bool> DownloadFilesAsync() { if (string.IsNullOrWhiteSpace(this.SelectedFilePath)) { return(false); } var checkResult = await this.MainWorkerServices.CheckRequirementsAsync(this.SelectedFilePath, this.CurrentConfiguration); if (!checkResult) { return(false); } var progressDialogController = await DialogCoordinator.ShowProgressAsync( context : this, title : "Downloading Office packages", message : "Please wait, this process will take minutes or hours depending on your Internet connection download speed", isCancelable : true).ConfigureAwait(false); progressDialogController.SetIndeterminate(); progressDialogController.Canceled += OnProgressDialogControllerCanceled; await this.MainWorkerServices.DownloadAsync(this.SelectedFilePath, this.CurrentConfiguration); progressDialogController.Canceled -= OnProgressDialogControllerCanceled; await progressDialogController.CloseAsync(); return(true); }
private async void ThreadControl_Click(object sender, RoutedEventArgs e) { var tokenSource = new CancellationTokenSource(); var settings = new MetroDialogSettings { NegativeButtonText = "Pause", CancellationToken = tokenSource.Token }; var _controller = await _dialogCoordinator.ShowProgressAsync(DataContext, "Title", GetMessage(), isCancelable : true, settings : settings); ThreadControl.Content = "Countinue Background Job"; while (!_controller.IsCanceled && _viewModel.Count < _viewModel.Max) { await Task.Delay(TimeSpan.FromMilliseconds(500)); _controller.SetMessage(GetMessage()); _viewModel.Count += 1; _controller.SetProgress((double)_viewModel.Count / _viewModel.Max); } if (!_controller.IsCanceled) { _viewModel.Count = 0; ThreadControl.Content = "Start Background Job"; } else { ThreadControl.Content = "Continue Background Job"; } await _controller.CloseAsync(); }
private async Task ImagesFromMovie(string fileData) { var ffmpegExe = ConfigurationManager.AppSettings["ffmpeg:ExeLocation"].ToString(); if (ffmpegExe == null) { return; } var progressResult = await _dialogService.ShowProgressAsync(this, "Converting video", ""); if (ConvertSettings.ConvertToImages) { var animPath = Path.GetFullPath(_gameConfig.Config.ImagesPath + "//" + ConvertSettings.AnimationName); if (string.IsNullOrEmpty(ConvertSettings.ImageFormat)) { ConvertSettings.ImageFormat = "png"; } await FFmpeg.ImagesFromMovieAsync(ffmpegExe, fileData, animPath, ConvertSettings.AnimationName, ConvertSettings.Fps, ConvertSettings.ImageFormat); } if (ConvertSettings.ConvertAudio) { await SoundFromMovie(fileData, ConvertSettings.AnimationName); } await progressResult.CloseAsync(); }
/// <summary> /// Запуск окна ожидания длительного процесса /// </summary> /// <param name="job">Работа</param> /// <param name="title">Заголовок</param> /// <param name="msg">сообщение</param> /// <param name="inMainThread">Выполнять в основном потоке (обязательно для AutoCAD/Revit, /// т.к. любые операции с чертежом нужно делать из основного потока). /// При этом нужно периодически выполнять прокачку очереди сообщений (DoEvents)</param> public async Task ShowProgressDialog([NotNull] Action <ProgressDialogController> job, string title, string msg, bool inMainThread = true) { Exception jobEx = null; var controller = await Task.Run(() => dialogCoordinator.ShowProgressAsync(context, title, msg)); if (inMainThread) { try { job(controller); } catch (Exception ex) { jobEx = ex; } } else { await Task.Run(() => job(controller)); } await controller.CloseAsync(); if (jobEx != null) { throw jobEx; } }
private async void OpenGameAsync() { //TODO Check if dirty and ask for confirmation var fileDialog = new OpenFileDialog { CheckFileExists = true, DefaultExt = "*.qsp", Title = "Open a QSP Game", Filter = "QSP Games|*.qsp; *.gam" }; // Show open file dialog box var result = fileDialog.ShowDialog(); // Process open file dialog box results if (result == true) { // Open document var filename = fileDialog.FileName; var controller = await dialogCoordinator.ShowProgressAsync(this, "Loading game", "Please wait"); controller.SetIndeterminate(); var openGameResult = await Task.Run(() => gameDataService.OpenGame(filename)); if (openGameResult != null) { await dialogCoordinator.ShowMessageAsync(this, "Error", openGameResult.Message); } else { if (IsSaveLoaded) { IsSaveLoaded = false; MessengerInstance.Send(new SaveMessage(SaveMessageType.SaveClosed)); } IsGameOpen = true; qspGamePath = filename; } await controller.CloseAsync(); } }
public async void GetDialog() { var message = await dialogCoordinator.ShowProgressAsync(this, "Please", "载入中,请稍后..."); message.SetIndeterminate(); await Task.Delay(5000); await message.CloseAsync(); }
public async void GetProducts() { var controller = await _dialogCoordinator.ShowProgressAsync(this, "Wait", "Loading products..."); controller.SetIndeterminate(); var products = await _dataRepository.GetProducts(); //foreach (var product in products) //{ // product.DateOfPurchase = DateTime.Parse(product.DateOfPurchase).ToShortDateString(); //} SetTotalsViewModel(products); Products = new ObservableCollection <Product>(products); await controller.CloseAsync(); }
public async void ShowProgressDialog() { MetroDialogSettings settings = new MetroDialogSettings() { NegativeButtonText = "Cancel", AnimateShow = true, AnimateHide = true }; _controller = await _dialogCoordinator.ShowProgressAsync(this, "Screen8ViewModel is working on something", "", true, settings); }
public static async void ShowRunProgress(BindableBase thisContent, IDialogCoordinator dialogCoordinator, string header, string message, int value) { var controller = await dialogCoordinator.ShowProgressAsync(thisContent, header, message); controller.SetIndeterminate(); await TaskEx.Delay(value); await controller.CloseAsync(); }
protected virtual async Task ShowProgressAsync(string message, string title = null) { if (_controller != null) { MessageBox.Show("Progress bar for one place is not closed"); return; } title = title ?? CommonStrings.ACGeneralLabel; _controller = await _dialogCoordinator.ShowProgressAsync(this, title, message); }
private async void RunProgressFromVm() { var controller = await _dialogCoordinator.ShowProgressAsync(this, "Progress from VM", "Progressing all the things, wait 3 seconds"); controller.SetIndeterminate(); await TaskEx.Delay(3000); await controller.CloseAsync(); }
async void ShowProgressDialogCommandExecute() { var result = await _dialogCoordinator.ShowProgressAsync(this, "Even geduld..", "Bezig met iets", true); result.Canceled += delegate { result.CloseAsync(); }; result.SetProgress(0.3); await Task.Delay(1000); result.SetProgress(0.5); await Task.Delay(1000); result.SetProgress(0.7); await Task.Delay(1000); result.SetProgress(1); if (result.IsOpen) { await result.CloseAsync(); } }
/// <summary> /// Shows a progress dialog /// </summary> /// <param name="title">The title of the dialog</param> /// <param name="message">The message of the dialog</param> /// <param name="setIndeterminate">true to set the controller to indeterminate, otherwise false (optional)</param> /// <returns>The progress controller</returns> protected async Task <ProgressDialogController> ShowProgress(string title, string message, bool setIndeterminate = true) { var controller = await _dialogCoordinator.ShowProgressAsync(this, title, message); if (setIndeterminate) { controller.SetIndeterminate(); } return(controller); }
/// <summary> /// Load Pending Payment /// </summary> private async void LoadPendingPayments() { try { var controller = await _dialogCoordinator.ShowProgressAsync(this, "Loading", (string)Application.Current.FindResource("LoadingInfoMessage")); controller.SetIndeterminate(); DataTable dtPendingPayment = new DataTable(); using (DataAccess da = new DataAccess()) { dtPendingPayment = da.SearchPendingPayment(null, null, string.Empty, string.Empty , (this.SContact == null ? string.Empty : this.SContact.Id.ToString()), 0); } this.PendingPaymentList.Clear(); if (dtPendingPayment.Rows.Count > 0) { Application.Current.Dispatcher.Invoke(() => { foreach (DataRow row in dtPendingPayment.Rows) { this.PendingPaymentList.Add(new PendingPayment() { Id = int.Parse(row["PendingPaymentId"].ToString()), Name = Convert.ToString(row["Name"]), PrimaryContact = Convert.ToString(row["Contact"]), Total = Convert.ToDouble(row["Total"]), PaidAmount = Convert.ToDouble(row["AmountPaid"]), PendingAmount = Convert.ToDouble(row["PendingAmount"]), SaleDate = Convert.ToDateTime(row["SaleDate"]), SaleId = int.Parse(row["SaleId"].ToString()), MinAmountForDiscount = Convert.ToDouble(row["MinAmtToAvailDiscount"]), SalePersonId = int.Parse(row["PendingPaymentId"].ToString()), SalePersonToDisplay = Convert.ToString(row["Name"]), ProductToDisplay = Convert.ToString(row["Product"]), ProductCodeToDisplay = Convert.ToString(row["ProductCode"]), }); } }); } else { //this._dialogCoordinator.ShowMessageAsync(this, "Oops!", (string)Application.Current.FindResource("NoDataFoundInfoMessage")); MessageBoxResult result = MessageBox.Show((string)Application.Current.FindResource("NoDataFoundInfoMessage"), "Information", MessageBoxButton.OK, MessageBoxImage.Information); } await controller.CloseAsync(); } catch (Exception ex) { logger.LogException(ex); } }
public async void ShowProgressMessage(string message, string header = "") { // Show... ProgressDialogController controller = await _dialogCoordinator.ShowProgressAsync(this, header, message); controller.SetIndeterminate(); // Do your work... // Close... await controller.CloseAsync(); }
private async void FooProgress() { // Show... var controller = await _dialogCoordinator.ShowProgressAsync(this, "HEADER", "MESSAGE"); controller.SetIndeterminate(); // Do your work... // Close... await controller.CloseAsync(); }
public async void Execute(CoroutineExecutionContext context) { var shell = (IoC.Get <IShell>() as Screen); dialog = await Dialogs.ShowProgressAsync(shell, "Please wait...", "Export is in Progress...", false); if (singleRallies != false || rallyCollection != false) { await Task.Factory.StartNew(() => ExportVideo(dialog)); } await dialog.CloseAsync(); }
public async Task DefaultButtonTextIsUpperCase(object parameter) { // Show... ProgressDialogController controller = await dialogCoordinator.ShowProgressAsync(this, "HEADER", "MESSAGE"); controller.SetIndeterminate(); // Do your work... Thread.Sleep(3000); // Close... await controller.CloseAsync(); }
public async Task ShowDefaultProgressAsync(string title, string message) { if (_defaultProgressDialogController == null) { _defaultProgressDialogController = await _dialogCoordinator.ShowProgressAsync(_dialogHost.DataContext, title, message); _defaultProgressDialogController.SetIndeterminate(); } else { _defaultProgressDialogController.SetTitle(title); _defaultProgressDialogController.SetMessage(message); } }
public async void ShowProgressDialog() { MetroDialogSettings settings = new MetroDialogSettings() { NegativeButtonText = "Hold the fort!" }; var controller = await _dialogCoordinator.ShowProgressAsync(this, "Progress of some process in Screen1ViewModel", "All things are progressing nicely, wait 5 seconds", true, settings); await Task.Delay(5000); if (controller.IsCanceled == true) { } await controller.CloseAsync(); }
private async void OnGetPosts(MetroWindow metroWindow) { if (string.IsNullOrWhiteSpace(Settings.Instance.GWBBlogUrl) || (string.IsNullOrWhiteSpace(Settings.Instance.GWBUserName) && string.IsNullOrWhiteSpace(Settings.Instance.GWBPassword))) { var settingsFlyout = metroWindow.Flyouts.Items[0] as Flyout; if (settingsFlyout == null) { return; } settingsFlyout.DataContext = new SettingsViewModel(); settingsFlyout.IsOpen = true; return; } ProgressDialogController progressController = await _dialogCoordinator.ShowProgressAsync(this, AppContext.Instance.ApplicationName, "Getting blog posts..."); progressController.SetIndeterminate(); //Connect to GWB var response = await GWBService.Instance.GetAllBlogPostsAsync(progressController); await progressController.CloseAsync(); if (response.Exception != null) { await _dialogCoordinator.ShowMessageAsync(this, AppContext.Instance.ApplicationName, response.Exception.Message); } else { var blog = response.Data; BlogTitle = blog.Title.ToUpper(); BlogUrl = blog.RootUrl; BlogPosts = blog.Posts.ToObservableCollection(); } }