public WindowCommands GetRightWindowCommands() { var windowCommands = new WindowCommands(); var refreshButton = WindowCommandHelper.CreateWindowCommandButton("appbar_refresh_counterclockwise_down", "refresh"); refreshButton.Command = _commandManager.GetCommand("File.Refresh"); _commandManager.RegisterAction("File.Refresh", () => _messageService.ShowAsync("Refresh")); windowCommands.Items.Add(refreshButton); var saveButton = WindowCommandHelper.CreateWindowCommandButton("appbar_save", "save"); saveButton.Command = _commandManager.GetCommand("File.Save"); _commandManager.RegisterAction("File.Save", () => _messageService.ShowAsync("Save")); windowCommands.Items.Add(saveButton); var showWindowButton = WindowCommandHelper.CreateWindowCommandButton("appbar_new_window", "show dialog window"); showWindowButton.Command = new Command(() => _uiVisualizerService.ShowDialog <ExampleDialogViewModel>()); windowCommands.Items.Add(showWindowButton); var showDataWindowButton = WindowCommandHelper.CreateWindowCommandButton("appbar_new_window", "show data window"); showDataWindowButton.Command = new Command(() => _uiVisualizerService.ShowDialog <ExampleDataViewModel>()); windowCommands.Items.Add(showDataWindowButton); return(windowCommands); }
/// <summary> /// Method to invoke when the AddEmployee command is executed. /// </summary> private void OnAddEmployeeExecute() { var employee = new Employee() { Department = SelectedDepartment }; var typeFactory = TypeFactory.Default; var viewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <EmployeeViewModel>(employee); if (!(_uiVisualizerService.ShowDialog(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"); }
/// <summary> /// Method to invoke when the Help command is executed. /// </summary> private void OnHelpExecute() { 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")); _uiVisualizerService.ShowDialog<AboutViewModel>(aboutInfo); }
/// <summary> /// Executes the EditPropertiesCommand /// </summary> private void ExecuteEditPropertiesCommand() { try { //Clear old selected PropertyTypes and create new list to check //against when user finishes editing list of available/wanted Property types oldPropertyTypeValues.Clear(); foreach (SinglePropertyViewModel vm in PropertyVMs) { oldPropertyTypeValues.Add(vm, vm.PropertyType); } ////read in the currently available types var props = PropertyTypeHelper.ReadCurrentlyAvailablePropertyTypes(); propertyTypesVM.PropertyTypes.Clear(); propertyTypesVM.PropertyTypes = props; //allow user to edit list of Property Types, and write them to disk bool?result = uiVisualizerService.ShowDialog("PropertyListPopup", propertyTypesVM); if (result.HasValue && result.Value) { PropertyTypeHelper.WriteCurrentlyAvailablePropertyTypes(propertyTypesVM.PropertyTypes); } WriteOldPropertyValues(); } catch { messageBoxService.ShowError( "There was a problem obtaining the list of available property types"); } }
/// <summary> /// Method to invoke when the Add command is executed. /// </summary> private async void OnAddExecute() { var viewModel = new PersonViewModel(new Person()); if (await _uiVisualizerService.ShowDialog(viewModel) ?? false) { PersonCollection.Add(viewModel.Person); } }
/// <summary> /// Inits the commands. /// </summary> private void InitCommands() { ConnectDisconnectCommand = new SimpleCommand <object, object>(ConnectDisconnectCommandExecute); SendCommand = new SimpleCommand <object, object>(obj => IsConnected, SendCommandExecute); DisplayConnectionSettingsCommand = new SimpleCommand <object, object>(obj => !IsConnected, DisplayConnectionSettingsCommandExecute); AboutCommand = new SimpleCommand <object, object>(AboutCommandExecute); HelpCommand = new SimpleCommand <object, object>(obj => NavigateTo(Settings.Default.WebsiteHelp)); GiveFeedbackCommand = new SimpleCommand <object, object>(obj => NavigateTo(Settings.Default.WebsiteGiveFeedback)); CheckForUpdatesCommand = new SimpleCommand <object, object>(obj => _visualizerService.ShowDialog("UpdateViewModel", new UpdateViewModel(_versionService))); }
/// <summary> /// Method to invoke when the Add command is executed. /// </summary> private void OnAddExecute() { var typeFactory = TypeFactory.Default; var viewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <PersonViewModel>(new Person()); if (_uiVisualizerService.ShowDialog(viewModel) ?? false) { PersonCollection.Add(viewModel.Person); } }
private void SelectAuthDB() { var selectDb = new WizardSelectDatabaseViewModel(new WizardSelectDatabaseModel(), MySQLHost, MySQLPort, MySQLUsername, MySQLPassword); var result = _uiVisualizerService.ShowDialog(selectDb); if (result.HasValue && result.Value) { SelectedAuthDB = selectDb.SelectedDatabaseName; } }
private void ExecuteHelpCommand(Object parameter) { try { uiVisualizerService.ShowDialog("HelpPopup", null); } catch (Exception ex) { messageBoxService.ShowError(ex.InnerException.Message); } }
private async void OnCreateWorkspaceExecute() { var workspace = new Workspace(); if (_uiVisualizerService.ShowDialog <WorkspaceViewModel>(workspace) ?? false) { _workspaceManager.Add(workspace, true); await _workspaceManager.StoreAndSave(); } }
/// <summary> /// Executes the AddOrderCommand /// </summary> private void ExecuteAddOrderCommand() { AddOrderCommand.CommandSucceeded = false; addEditOrderVM.CurrentViewMode = ViewMode.AddMode; addEditOrderVM.CurrentCustomer = CurrentCustomer; bool?result = uiVisualizerService.ShowDialog("AddEditOrderPopup", addEditOrderVM); if (result.HasValue && result.Value) { CloseActivePopUpCommand.Execute(true); } AddOrderCommand.CommandSucceeded = true; }
/// <summary> /// Method to invoke when the AddBackupSet command is executed. /// </summary> private void OnAddBackupSetExecute() { var BackupSet = new BackupSet(); // Note that we use the type factory here because it will automatically take care of any dependencies // that the BackupSetViewModel will add in the future var typeFactory = this.GetTypeFactory(); var BackupSetViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <BackupSetViewModel>(BackupSet); if (_uiVisualizerService.ShowDialog(BackupSetViewModel) ?? false) { BackupSets.Add(BackupSet); } }
/// <summary> /// Method to invoke when the Add command is executed. /// </summary> private void OnAddExecute() { // Create view model for new person var viewModel = new PersonViewModel(new Person()); // Get UI visualizer service _uiVisualizerService.ShowDialog(viewModel, (sender, e) => { if (e.Result ?? false) { PersonCollection.Add(viewModel.Person); } }); }
public BackupSetViewModel(IBackupSet backupSet, IUIVisualizerService uiVisualizerService) { Argument.IsNotNull(() => backupSet); Argument.IsNotNull(() => uiVisualizerService); BackupSet = backupSet; _uiVisualizerService = uiVisualizerService; _timer = new Timer(new TimerCallback((o)=> { RefreshLog(); }), null, Timeout.Infinite, Timeout.Infinite); UpdateScheduleStatus(); BrowseSourceCommand = new Command(() => SourceDirectory = SetDirectory(SourceDirectory, "Select Source Directory")); BrowseDestinationCommand = new Command(() => DestinationDirectory = SetDirectory(DestinationDirectory, "Select Destination Directory")); ExcludeDirectoriesCommand = new Command(OnExcludeDirectoriesExecute, ()=>!String.IsNullOrEmpty(SourceDirectory)); RunBackupCommand = new Command(() => { if(BackupSet.DestinationType == BackupDestinationType.ExternalDrive) { var typeFactory = this.GetTypeFactory(); var driveSelectionViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion<DriveSelectionViewModel>(); driveSelectionViewModel.SetDefaultDrive(DestinationDirectory.Substring(0, 1)); if(_uiVisualizerService.ShowDialog(driveSelectionViewModel) == true ) { UpdateDestinationDriveLetter(driveSelectionViewModel.SelectedDrive.Name); } else { return; } } _timer.Change(1000, 1000); BackupSet.RunBackup(); } , () => CanRunBackup); CancelBackupCommand = new Command(() => { _timer.Change(Timeout.Infinite, Timeout.Infinite); BackupSet.CancelBackup(); } , () => CanCancelBackup); EditBackupSetCommand = new RelayCommand((o)=> { StateService.RequestBackupSetEdit((string)o); } ,(o) => ProcessingStatus == BackupProcessingStatus.NotStarted || ProcessingStatus == BackupProcessingStatus.Cancelled || ProcessingStatus == BackupProcessingStatus.Finished); FinishEditingBackupSetCommand = new RelayCommand((o) => { StateService.RequestBackupSetEdit((string)o); }); BackupSet.PropertyChanged += BackupSetPropertyChanged; }
public BackupSetViewModel(IBackupSet backupSet, IUIVisualizerService uiVisualizerService) { Argument.IsNotNull(() => backupSet); Argument.IsNotNull(() => uiVisualizerService); BackupSet = backupSet; _uiVisualizerService = uiVisualizerService; _timer = new Timer(new TimerCallback((o) => { RefreshLog(); }), null, Timeout.Infinite, Timeout.Infinite); UpdateScheduleStatus(); BrowseSourceCommand = new Command(() => SourceDirectory = SetDirectory(SourceDirectory, "Select Source Directory")); BrowseDestinationCommand = new Command(() => DestinationDirectory = SetDirectory(DestinationDirectory, "Select Destination Directory")); ExcludeDirectoriesCommand = new Command(OnExcludeDirectoriesExecute, () => !String.IsNullOrEmpty(SourceDirectory)); RunBackupCommand = new Command(() => { if (BackupSet.DestinationType == BackupDestinationType.ExternalDrive) { var typeFactory = this.GetTypeFactory(); var driveSelectionViewModel = typeFactory.CreateInstanceWithParametersAndAutoCompletion <DriveSelectionViewModel>(); driveSelectionViewModel.SetDefaultDrive(DestinationDirectory.Substring(0, 1)); if (_uiVisualizerService.ShowDialog(driveSelectionViewModel) == true) { UpdateDestinationDriveLetter(driveSelectionViewModel.SelectedDrive.Name); } else { return; } } _timer.Change(1000, 1000); BackupSet.RunBackup(); } , () => CanRunBackup); CancelBackupCommand = new Command(() => { _timer.Change(Timeout.Infinite, Timeout.Infinite); BackupSet.CancelBackup(); } , () => CanCancelBackup); EditBackupSetCommand = new RelayCommand((o) => { StateService.RequestBackupSetEdit((string)o); } , (o) => ProcessingStatus == BackupProcessingStatus.NotStarted || ProcessingStatus == BackupProcessingStatus.Cancelled || ProcessingStatus == BackupProcessingStatus.Finished); FinishEditingBackupSetCommand = new RelayCommand((o) => { StateService.RequestBackupSetEdit((string)o); }); BackupSet.PropertyChanged += BackupSetPropertyChanged; }
private void OnShowInstalledDialogExecute() { _dispatcherService.BeginInvoke(async() => { _uiVisualizerService.ShowDialog <AppInstalledViewModel>(); await CloseViewModelAsync(null); }); }
/// <summary> /// Method to invoke when the AddTab command is executed. /// </summary> private void OnAddTabExecute() { var vm = new CreateTabWindowViewModel(); if (_uiVisualizerService.ShowDialog(vm) ?? false) { _tabService.AddTab(vm.CloseWhenUnloaded); } }
private void OnBuildFilterExecute() { var vm = _viewModelFactory.CreateViewModel <SearchFilterBuilderViewModel>(null, null); if (_uiVisualizerService.ShowDialog(vm) ?? false) { Filter = vm.Filter; } }
public void ExecuteShowDataChangeWindowCommand(object parameter) { PersistDesignerItemData data = new PersistDesignerItemData(HostUrl); if (visualiserService.ShowDialog(data) == true) { this.HostUrl = data.HostUrl; } }
public void ExecuteShowDataChangeWindowCommand(object parameter) { SettingsDesignerItemData data = new SettingsDesignerItemData(Setting1); if (visualiserService.ShowDialog(data) == true) { this.Setting1 = data.Setting1; } }
/// <summary> /// Shows the window in modal state and creates the view model automatically using the specified model. /// </summary> /// <typeparam name="TViewModel">The type of the view model.</typeparam> /// <param name="uiVisualizerService">The UI visualizer service.</param> /// <param name="model">The model to be injected into the view model, can be <c>null</c>.</param> /// <param name="completedProc">The completed proc.</param> /// <returns>The dialog result.</returns> /// <exception cref="ArgumentNullException">The <paramref name="uiVisualizerService" /> is <c>null</c>.</exception> public static bool?ShowDialog <TViewModel>(this IUIVisualizerService uiVisualizerService, object model = null, EventHandler <UICompletedEventArgs> completedProc = null) where TViewModel : IViewModel { Argument.IsNotNull("uiVisualizerService", uiVisualizerService); var viewModelFactory = GetViewModelFactory(uiVisualizerService); var vm = viewModelFactory.CreateViewModel(typeof(TViewModel), model); return(uiVisualizerService.ShowDialog(vm, completedProc)); }
/// <summary> /// Shows the single license dialog including all company info. You will see the about box. /// </summary> public void ShowLicense() { Log.Debug("Showing license dialog with company info"); // Note: doesn't this cause deadlocks? _dispatcherService.Invoke(() => { var licenseInfo = _licenseInfoService.GetLicenseInfo(); _uiVisualizerService.ShowDialog <LicenseViewModel>(licenseInfo); }, true); }
public MainViewModel(IUIVisualizerService visualizerService, IViewAwareStatusWindow window, IMessageBoxService messageBoxService, IHartCommunicationLiteEx hartCommunication, IVersionService versionService) { _synchronizationContext = SynchronizationContext.Current; _settingsViewModel = new SettingsViewModel(); _visualizerService = visualizerService; _messageBoxService = messageBoxService; _hartCommunication = hartCommunication; _versionService = versionService; _versionService.GetOnlineVersionResult += (sender, onlineVersion) => { if (onlineVersion != new Version()) { Settings.Default.LastUpdateCheck = DateTime.Now; } if (versionService.GetCurrentVersion() < onlineVersion) { _synchronizationContext.Send(obj => _visualizerService.ShowDialog("UpdateViewModel", new UpdateViewModel(_versionService)), null); } }; window.ViewLoaded += () => { if (Settings.Default.ShowOnStartup) { _visualizerService.ShowDialog("SettingsViewModel", _settingsViewModel); } CheckUpdates(_versionService); }; window.ViewWindowClosed += () => { Settings.Default.Save(); Application.Current.Shutdown(); }; ReadSettings(); DataTransferModel = DataTransferModel.GetInstance(); InitCommands(); }
private void OnNewSchemeExecute() { if (_targetType == 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 (_uiVisualizerService.ShowDialog <EditFilterViewModel>(filterSchemeEditInfo) ?? false) { AvailableSchemes.Add(filterScheme); _filterSchemes.Schemes.Add(filterScheme); ApplyFilterScheme(filterScheme, true); _filterSchemeManager.UpdateFilters(); } }
/// <summary> /// Initializes the view model. Normally the initialization is done in the constructor, but sometimes this must be delayed /// to a state where the associated UI element (user control, window, ...) is actually loaded. /// <para/> /// This method is called as soon as the associated UI element is loaded. /// </summary> /// <remarks> /// It's not recommended to implement the initialization of properties in this method. The initialization of properties /// should be done in the constructor. This method should be used to start the retrieval of data from a web service or something /// similar. /// <para/> /// During unit tests, it is recommended to manually call this method because there is no external container calling this method. /// </remarks> protected override void Initialize() { var vm = new ProvideAnalyticsViewModel(); if (_uiVisualizerService.ShowDialog(vm) ?? false) { AuditingManager.RegisterAuditor(new GoogleAnalytics(vm.ApiKey, "Catel Analytics Example")); } else { _messageService.ShowError("Cannot provide analytics when no API is provided"); } }
public virtual void EnsureFailSafeStartup() { if (SuccessfullyStarted) { Log.Debug("Application was successfully started previously, starting application in normal mode"); return; } Log.Info("Application was not successfully started previously, starting application in fail-safe mode"); Log.Debug("Showing CrashWarningWindow dialog"); _uiVisualizerService.ShowDialog <CrashWarningViewModel>(); }
protected override void Execute(object parameter) { base.Execute(parameter); var settingsViewModelType = TypeCache.GetTypes(x => string.Equals(x.Name, ViewModelType)).FirstOrDefault(); if (settingsViewModelType == null) { throw Log.ErrorAndCreateException <InvalidOperationException>("Cannot find type '{0}'", ViewModelType); } var viewModel = _viewModelFactory.CreateViewModel(settingsViewModelType, null, null); _uiVisualizerService.ShowDialog(viewModel); }
private void OnShowLicenseUsageExecute() { var networkValidationResult = new NetworkValidationResult(); networkValidationResult.MaximumConcurrentUsers = 2; networkValidationResult.CurrentUsers.AddRange(new[] { new NetworkLicenseUsage("12", "192.168.1.100", "Jon", "Licence signature", DateTime.Now), new NetworkLicenseUsage("13", "192.168.1.101", "Jane", "Licence signature", DateTime.Now), new NetworkLicenseUsage("14", "192.168.1.102", "Samuel", "Licence signature", DateTime.Now), new NetworkLicenseUsage("15", "192.168.1.103", "Paula", "Licence signature", DateTime.Now) }); _uiVisualizerService.ShowDialog <NetworkLicenseUsageViewModel>(networkValidationResult); }
/// <summary> /// Show the AddImageRatingPopup using the IUIVisualizerService, passing /// it a ValidatingViewModel that should validate that a valid rating between /// 1-5 is entered by the user. If we get a valid rating then apply it to the /// currently selected ImageViewModel /// </summary> private void ExecuteAddImageRatingCommand(Object args) { ImageRatingViewModel imageRatingViewModel = new ImageRatingViewModel(messageBoxService); imageRatingViewModel.ImageRating.DataValue = ((ImageViewModel)loadedImagesCV.CurrentItem).Rating; bool?result = uiVisualizerService.ShowDialog("AddImageRatingPopup", imageRatingViewModel); if (result.HasValue && result.Value) { ((ImageViewModel)loadedImagesCV.CurrentItem).Rating = imageRatingViewModel.ImageRating.DataValue; } }
public virtual void ShowAbout() { var aboutInfo = _aboutInfoService.GetAboutInfo(); if (aboutInfo != null) { Log.Info("Showing about dialog"); _uiVisualizerService.ShowDialog <AboutViewModel>(aboutInfo); } else { Log.Warning("IAboutInfoService.GetAboutInfo() returned null, cannot show about window"); } }
private void OptimizeMetamodel(bool bShowMessageOnNoOpt) { MetamodelProcessor optOperations = new MetamodelProcessor(this.ModelContext.MetaModel, this.ModelContext as LibraryModelContext); List <BaseOptimization> opt = optOperations.GetOptimizations(); if (opt.Count == 0) { if (bShowMessageOnNoOpt) { IMessageBoxService msgBox = this.GlobalServiceProvider.Resolve <IMessageBoxService>(); msgBox.ShowInformation("No applicable optimizations found."); } return; } bool bRestartOpt = false; OptimizationMainViewModel vm = new OptimizationMainViewModel(this.ViewModelStore, optOperations, opt); IUIVisualizerService ui = this.ResolveService <IUIVisualizerService>(); bool?result = ui.ShowDialog("OptimizationControl", vm); if (result == false) { vm.Dispose(); return; } else { // apply optimization vm.ApplyCurrrentOptimization(); bRestartOpt = true; vm.Dispose(); } if (opt.Count > 0) { for (int i = opt.Count - 1; i >= 0; i--) { opt[i].Dispose(); } } if (bRestartOpt) { this.OptimizeMetamodel(false); } }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class. /// </summary> public MainWindowViewModel(IBackupSetService backupSetService, IMessageBoxService messageBoxService, IUIVisualizerService uiVisualizerService) { Argument.IsNotNull(() => backupSetService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageBoxService); _log.Info("In MainWindowViewModel constructor"); _backupSetService = backupSetService; _uiVisualizerService = uiVisualizerService; _messageBoxService = messageBoxService; ServiceSettings = new ServiceViewModel(); Themes = new[] { "Dark", "Light" }; CurrentThemeNumber = 0; AddBackupSet = new Command(OnAddBackupSetExecute); EditBackupSet = new Command(OnEditBackupSetExecute, OnEditBackupSetCanExecute); RemoveBackupSet = new Command(OnRemoveBackupSetCollectionExecute, OnRemoveBackupSetCollectionCanExecute); OpenLogDirectoryCommand = new Command(OnShowLogDirectoryCommand); ShowAboutDialogCommand = new Command(() => _uiVisualizerService.ShowDialog(new AboutViewModel())); ToggleThemeCommand = new Command(() => { CurrentThemeNumber++; if(CurrentThemeNumber > Themes.Length - 1) { CurrentThemeNumber = 0; } RaiseThemeChanged(Themes[CurrentThemeNumber]); }); FilterAllBackupsCommand = new Command(() => FilterBackupSets()); FilterOverdueBackupsCommand = new Command(() => FilterBackupSets(OVERDUE)); FilterErrorBackupsCommand = new Command(() => FilterBackupSets(ERROR)); Initialize(); }