/// <summary> /// Method to invoke when the AddEmployee command is executed. /// </summary> private async Task OnAddEmployeeExecuteAsync() { var employee = new Employee() { Department = SelectedDepartment }; var typeFactory = TypeFactory.Default; var viewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <EmployeeViewModel>(employee); if (!(await _uiVisualizerService.ShowDialogAsync(viewModel) ?? false)) { return; } _employeeRepository.AddEmployee(employee); if (employee.Department == SelectedDepartment) { Employees.Add(employee); } MessageMediator.SendMessage(employee.Department, "UpdateSelectedDepartmentFromEM"); Mediator.SendMessage(string.Format("Employee {0} {1} is added in department {2}", employee.FirstName, employee.LastName, employee.Department.Name), "UpdateNotification"); }
public Task <MessageResult> ShowAsync(string message, string caption = "", string helpLink = null, MessageButton button = MessageButton.OK, MessageImage icon = MessageImage.None) { var tcs = new TaskCompletionSource <MessageResult>(); #pragma warning disable AvoidAsyncVoid _dispatcherService.BeginInvoke(async() => #pragma warning restore AvoidAsyncVoid { var previousCursor = Mouse.OverrideCursor; Mouse.OverrideCursor = null; var vm = _viewModelFactory.CreateViewModel <HelpLinkMessageBoxViewModel>(null, null); vm.Message = message; vm.Button = button; vm.Icon = icon; vm.HelpLink = helpLink; vm.SetTitle(caption); await _uiVisualizerService.ShowDialogAsync(vm); Mouse.OverrideCursor = previousCursor; tcs.TrySetResult(vm.Result); }); return(tcs.Task); }
private async Task ViewModelOnSavingAsync(object sender, SavingEventArgs e) { _closingViewModel = new ProgressWindowViewModel(); _closingViewModel.Title = "Saving..."; _closingViewModel.SetOwnerWindow(this); _visualizerService.ShowDialogAsync(_closingViewModel); }
private async Task OnNewSchemeExecuteAsync() { if (_targetType is null) { Log.Warning("Target type is unknown, cannot get any type information to create filters"); return; } var filterScheme = new FilterScheme(_targetType); var filterSchemeEditInfo = new FilterSchemeEditInfo(filterScheme, RawCollection, AllowLivePreview, EnableAutoCompletion); if (!(await _uiVisualizerService.ShowDialogAsync <EditFilterViewModel>(filterSchemeEditInfo) ?? false)) { return; } if (_filterSchemes is null || _filterSchemeManager is null) { return; } _filterSchemes.Schemes.Add(filterScheme); UpdateFilterGroups(); ApplyFilterScheme(filterScheme, true); await _filterSchemeManager.UpdateFiltersAsync(); }
/// <summary> /// Method to invoke when the Help command is executed. /// </summary> private async Task OnHelpExecuteAsync() { var aboutInfo = new AboutInfo(new Uri("pack://application:,,,/Resources/Images/CompanyLogo.png", UriKind.RelativeOrAbsolute), "/Orchestra.Examples.Ribbon.Microsoft;component/Resources/Images/CompanyLogo.png", new UriInfo("http://www.catelproject.com", "Product website")); await _uiVisualizerService.ShowDialogAsync <AboutViewModel>(aboutInfo); }
/// <summary> /// Method to invoke when the Add command is executed. /// </summary> private async Task OnAddExecuteAsync() { var viewModel = new PersonViewModel(new Person()); if (await _uiVisualizerService.ShowDialogAsync(viewModel) ?? false) { PersonCollection.Add(viewModel.Person); } }
private async Task OnAddExecuteAsync() { var person = new Person(); if (await _uiVisualizerService.ShowDialogAsync <PersonViewModel>(person) ?? false) { PersonCollection.Add(person); } }
/// <summary> /// Method to invoke when the Add command is executed. /// </summary> private async Task OnAddAxisExecuteAsync() { var viewModel = new AxisDefinitionViewModel(new AxisDefinitionModel()); if (await _uiVisualizerService.ShowDialogAsync(viewModel) ?? false) { Axes.Add(viewModel.AxisDefinitionModel); ViewModelCommandManager.InvalidateCommands(true); } }
/// <summary> /// Method to invoke when the Add command is executed. /// </summary> private async Task OnAddExecuteAsync() { var typeFactory = TypeFactory.Default; var viewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <PersonViewModel>(new Person()); if (await _uiVisualizerService.ShowDialogAsync(viewModel) ?? false) { PersonCollection.Add(viewModel.Person); } }
/// <summary> /// Method to invoke when the ShowKeyboardMappings command is executed. /// </summary> private async Task OnAddTypeCommandExecuteAsync() { var type = new Type(); type.TypeName = "New Type"; var viewModel = _viewModelFactory.CreateViewModel <TypeViewModel>(type); viewModel.Title = "Add Type"; viewModel.SavedAsync += ViewModelOnSavedAsync; await _visualizerService.ShowDialogAsync(viewModel); }
private async Task OnCreateWorkspaceExecuteAsync() { var workspace = new Workspace(); if (await _uiVisualizerService.ShowDialogAsync <WorkspaceViewModel>(workspace) ?? false) { await _workspaceManager.AddAsync(workspace, true); await _workspaceManager.StoreAndSaveAsync(); } }
private async Task OnAddCommandExecuteAsync() { var logFilter = new LogFilter(); if (await _uiVisualizerService.ShowDialogAsync <LogFilterEditorViewModel>(logFilter) ?? false) { LogFilters.Add(logFilter); SelectedLogFilter = logFilter; Validate(true); } }
private async Task OnCreateEnrollmentCommandExecuteAsync() { var isCancel = await uiVisualizerService.ShowDialogAsync <EnrollmentDetailsViewModel>() ?? false; if (isCancel) { await UpdateDatesAsync(); await UpdateEnrollmentsAsync(); SelectedEnrollment = Enrollments.LastOrDefault(); } }
private static Task OnChangeFontCommandExecute(HeaderCommandParameter parameter) { Argument.IsNotNull(() => parameter); var manageFontModel = new ManageFontModel { Grid = parameter.Grid }; var viewModel = ViewModelFactory.CreateViewModel <ManageFontViewModel>(manageFontModel); return(UIVisualizerService.ShowDialogAsync(viewModel, OnManageFontCompleted)); }
private async Task OnAddCommandExecuteAsync() { var logFilterGroup = new LogFilterGroup(); if (await _uiVisualizerService.ShowDialogAsync <LogFilterGroupEditorViewModel>(logFilterGroup) ?? false) { FilterGroups.Add(logFilterGroup); await SaveFilterGroupsAsync(); Updated.SafeInvoke(this); } }
private async Task OnAddCustomerCommandExecuteAsync() { var customer = new Customer(); var typeFactory = this.GetTypeFactory(); var viewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <CustomerAddWindowViewModel>(customer); if (await _uiVisualizerService.ShowDialogAsync(viewModel) ?? false) { customer.Save(); Customers.Add(customer); } }
/// <summary> /// Method to invoke when the AddFamily command is executed. /// </summary> private async Task OnAddFamilyExecuteAsync() { var family = new Family(); // Note that we use the type factory here because it will automatically take care of any dependencies // that the FamilyWindowViewModel will add in the future var typeFactory = this.GetTypeFactory(); var familyWindowViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <FamilyWindowViewModel>(family); if (await _uiVisualizerService.ShowDialogAsync(familyWindowViewModel) ?? false) { Families.Add(family); } }
private async Task OnAddProductCommandExecuteAsync() { var product = new Product(); var typeFactory = this.GetTypeFactory(); var viewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <ProductAddWindowViewModel>(product); if (await _uiVisualizerService.ShowDialogAsync(viewModel) ?? false) { product.Save(); Products.Add(product); } }
/// <summary> /// Method to invoke when the AddPerson command is executed. /// </summary> private async Task OnAddPersonExecuteAsync() { var person = new Person(); person.LastName = FamilyName; // Note that we use the type factory here because it will automatically take care of any dependencies // that the PersonViewModel will add in the future var typeFactory = this.GetTypeFactory(); var personViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <PersonViewModel>(person); if (await _uiVisualizerService.ShowDialogAsync(personViewModel) ?? false) { Persons.Add(person); } }
private async Task OnShowPackageSourceSettingsExecuteAsync() { var nugetSettingsVm = _typeFactory.CreateInstanceWithParametersAndAutoCompletion <NuGetSettingsViewModel>(); if (nugetSettingsVm is not null) { var result = await _uIVisualizerService.ShowDialogAsync(nugetSettingsVm); if (result ?? false) { //update available feeds ActiveFeeds = new ObservableCollection <INuGetSource>(GetActiveFeedsFromSettings()); } } }
private void OnOpenLookUpExecute() { Type tVm = Type.GetType(TypeVM); var tVMCtor = tVm.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); uiVisualizerService.ShowDialogAsync((IViewModel)tVMCtor, ReturnValue); }
internal async Task CheckDirectoriesAsync() { var dodgy = new List <string>(); using (new CursorOverride(Cursors.Wait)) { var files = ListFiles(); foreach (var file in files) { if (!legitDirectories.Contains(file.Path)) { dodgy.Add(file.Path); } } } if (dodgy.Count == 0) { MessageBox.Show("Nothing dodgy", "WebWriter AntiHacker", MessageBoxButton.OK, MessageBoxImage.Information); } else { IUIVisualizerService uIVisualiserService = ServiceLocator.Default.ResolveType <IUIVisualizerService>(); if (!(uIVisualiserService is null)) { await uIVisualiserService.ShowDialogAsync <DodgyStuffViewModel>(dodgy); } } }
public override Task <MessageResult> ShowAsync(string message, string caption = "", MessageButton button = MessageButton.OK, MessageImage icon = MessageImage.None) { Argument.IsNotNullOrWhitespace("message", message); Log.Info("Showing message to the user:\n\n{0}", this.GetAsText(message, button)); var tcs = new TaskCompletionSource <MessageResult>(); #pragma warning disable AvoidAsyncVoid _dispatcherService.BeginInvoke(async() => #pragma warning restore AvoidAsyncVoid { var previousCursor = Mouse.OverrideCursor; Mouse.OverrideCursor = null; var vm = _viewModelFactory.CreateViewModel <MessageBoxViewModel>(null, null); vm.Message = message; vm.Button = button; vm.Icon = icon; vm.SetTitle(caption); await _uiVisualizerService.ShowDialogAsync(vm); Mouse.OverrideCursor = previousCursor; Log.Info("Result of message: {0}", vm.Result); tcs.TrySetResult(vm.Result); }); return(tcs.Task); }
private async Task OnEditSnapshotExecuteAsync(ISnapshot snapshot) { var modelValidation = snapshot as IValidatable; void OnSnapshotValidating(object sender, ValidationEventArgs e) { if (_snapshotManager.Snapshots.Any(x => x.Title.EqualsIgnoreCase(snapshot.Title) && x != snapshot)) { e.ValidationContext.Add(FieldValidationResult.CreateError("Title", _languageService.GetString("Snapshots_SnapshotWithCurrentTitleAlreadyExists"))); } } if (modelValidation is not null) { modelValidation.Validating += OnSnapshotValidating; } if (await _uiVisualizerService.ShowDialogAsync <SnapshotViewModel>(snapshot) ?? false) { if (modelValidation is not null) { modelValidation.Validating -= OnSnapshotValidating; } await _snapshotManager.SaveAsync(); } }
public Task <bool?> ShowWizardAsync(IWizard wizard) { Argument.IsNotNull(() => wizard); Log.Debug("Showing wizard '{0}'", wizard.GetType().GetSafeFullName(false)); return(_uiVisualizerService.ShowDialogAsync <WizardViewModel>(wizard)); }
private void OnShowInstalledDialogExecute() { // Dispatch since we close the vm _dispatcherService.BeginInvoke(async() => { await _uiVisualizerService.ShowDialogAsync <AppInstalledViewModel>(); await CloseViewModelAsync(null); }); }
private async Task OnChangeDbProviderAsync() { var dbProviderListViewModel = _typeFactory.CreateInstanceWithParametersAndAutoCompletion <DbConnectionProviderListViewModel>(DbProvider); if (await _uiVisualizerService.ShowDialogAsync(dbProviderListViewModel) ?? false) { DbProvider = dbProviderListViewModel.DbProvider; } }
private async Task OnAddOrderCommandExecuteAsync() { var order = new Order(); var typeFactory = this.GetTypeFactory(); var viewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <OrderAddWindowViewModel>(order); if (await _uiVisualizerService.ShowDialogAsync(viewModel) ?? false) { order.OrderDate = DateTime.Now; order.Save(); Orders.Add(order); SelectedOrder = order; ShowProductsInOrderCommand.Execute(); } }
private async Task OnBuildFilterExecuteAsync() { var vm = _viewModelFactory.CreateViewModel <SearchFilterBuilderViewModel>(null, null); if (await _uiVisualizerService.ShowDialogAsync(vm) ?? false) { Filter = vm.Filter; } }
/// <summary> /// Method to invoke when the AddTab command is executed. /// </summary> private async Task OnAddTabExecuteAsync() { var vm = new CreateTabWindowViewModel(); if (await _uiVisualizerService.ShowDialogAsync(vm) ?? false) { _tabService.AddTab(vm.CloseWhenUnloaded); } }