protected virtual void UpdateTaskCore(TaskCommand taskCommand) { currentTaskCommand = taskCommand; if (taskCommand == TaskCommand.Cancel) { double timeToWait = 0; double tempTimeToWait = 0; if (double.TryParse(ConfigurationManager.AppSettings["TimeToWaitBeforeKillingProcess"], out tempTimeToWait)) { timeToWait = tempTimeToWait; } if (taskThread.IsAlive) { System.Timers.Timer timer = new System.Timers.Timer(timeToWait * 1000); timer.Start(); timer.Elapsed += (object sender, ElapsedEventArgs e) => { timer.Stop(); if (taskThread.IsAlive) { Environment.Exit(0); } }; } } }
public void UpdateTask(TaskCommand taskCommand) { if (executingTask != null) { UpdateTaskCore(taskCommand); } }
public LicenseViewModel(LicenseInfo licenseInfo, INavigationService navigationService, IProcessService processService, ILicenseService licenseService, ILicenseValidationService licenseValidationService, IUIVisualizerService uiVisualizerService, IMessageService messageService, ILanguageService languageService, ILicenseModeService licenseModeService) { Argument.IsNotNull(() => licenseInfo); Argument.IsNotNull(() => navigationService); Argument.IsNotNull(() => processService); Argument.IsNotNull(() => licenseService); Argument.IsNotNull(() => licenseValidationService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => languageService); Argument.IsNotNull(() => licenseModeService); _navigationService = navigationService; _processService = processService; _licenseService = licenseService; _licenseValidationService = licenseValidationService; _uiVisualizerService = uiVisualizerService; _messageService = messageService; _languageService = languageService; _licenseModeService = licenseModeService; LicenseInfo = licenseInfo; Title = licenseInfo.Title; XmlData = new ObservableCollection <XmlDataModel>(); Paste = new TaskCommand(OnPasteExecuteAsync); ShowClipboard = new TaskCommand(OnShowClipboardExecuteAsync); PurchaseLinkClick = new Command(OnPurchaseLinkClickExecute); AboutSiteClick = new Command(OnAboutSiteClickExecute); RemoveLicense = new TaskCommand(OnRemoveLicenseExecuteAsync, OnRemoveLicenseCanExecute); }
public PlotViewModel(Models.PlotModel plotModel) { _uiVisualizerService = ServiceLocator.Default.ResolveType <IUIVisualizerService>(); _logService = ServiceLocator.Default.ResolveType <ILoggingService>(); _kserv = ServiceLocator.Default.ResolveType <IKmotionService>(); _plotService = ServiceLocator.Default.ResolveType <IAvailablePlotsService>(); Messages = new List <string[]>(1024); _dataLog = new List <string[]>(20000); OxyPlotModel = new OxyPlot.PlotModel(); PlotModel = plotModel; StartStopCommand = new TaskCommand <bool>(OnStartStopCommandExecuteAsync, OnStartStopCommandCanExecute); Clear = new TaskCommand(OnClearExecute); ZeroCommand = new TaskCommand(OnZeroCommandExecuteAsync, OnZeroCommandCanExecute); SaveCommand = new TaskCommand(OnSaveCommandExecuteAsync, OnSaveCommandCanExecute); LoadCommand = new TaskCommand(OnLoadCommandExecuteAsync, OnLoadCommandCanExecute); ConfigCommand = new TaskCommand(OnConfigCommandExecuteAsync, OnConfigCommandCanExecute); ExportPngCommand = new TaskCommand(OnExportPngCommandExecute); // this instance is created on the UI thread //_context = SynchronizationContext.Current; _userInterfaceDispatcher = Dispatcher.CurrentDispatcher; _cancelSource = new CancellationTokenSource(); //syncing plots _plotService.AvailablePlots.Add(OxyPlotModel); //messages strings or hex dump of memory FromHex = false; }
public ConnectionStringEditViewModel(string connectionString, DbProvider provider, IMessageService messageService, IConnectionStringBuilderService connectionStringBuilderService, IUIVisualizerService uiVisualizerService, ITypeFactory typeFactory) { Argument.IsNotNull(() => connectionStringBuilderService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => typeFactory); Argument.IsNotNull(() => messageService); _messageService = messageService; _connectionStringBuilderService = connectionStringBuilderService; _uiVisualizerService = uiVisualizerService; _typeFactory = typeFactory; using (SuspendChangeNotifications()) { DbProvider = provider; } ConnectionString = provider != null?_connectionStringBuilderService.CreateConnectionString(provider, connectionString) : null; InitServers = new Command(() => InitServersAsync(), () => !IsServersRefreshing); RefreshServers = new Command(() => RefreshServersAsync(), () => !IsServersRefreshing); InitDatabases = new Command(() => InitDatabasesAsync(), () => !IsDatabasesRefreshing); RefreshDatabases = new Command(() => RefreshDatabasesAsync(), CanInitDatabases); TestConnection = new Command(OnTestConnection); ShowAdvancedOptions = new TaskCommand(OnShowAdvancedOptionsAsync, () => ConnectionString != null); }
public SelectOutputFolderViewModel() { Title = "Select an output folder"; SelectManualCommand = new TaskCommand(SelectManualExecute); SelectWithPresetCommand = new TaskCommand <string>(SelectWithPresetExecute); PresetOptions = GetOptions(); }
public TransmitterViewModel(Transmitter dataItem, IDialogService dialogService, MainViewModel mainViewModel) { DataItem = dataItem; _dialogService = dialogService; _mainViewModel = mainViewModel; Closable = true; DisplayName = DataItem.DisplayName; PortNumber = DataItem.PortNumber; TransmitterType = DataItem.TransmitterType; Broadcast = DataItem.Broadcast; IpAddress = DataItem.IpAddress; Encoding = DataItem.Encoding; SaveCommand = new TaskCommand(SaveExecute, d => !IsActive && CanSave); ToggleCommand = new TaskCommand(ToggleExecute, d => !CanSave || IsActive); NewMessageCommand = new TaskCommand(NewMessageExecute); ClearLogCommand = new TaskCommand(ClearLogExecute, d => Messages.Count > 0); Encodings = new ObservableCollection <SelectorOption <Encoding> >(EncodingOptionsFactory.GetAll()); WhenPropertyChanged.Subscribe(name => { if (new[] { nameof(DisplayName), nameof(PortNumber), nameof(TransmitterType), nameof(Broadcast), nameof(IpAddress), nameof(Encoding) }.Contains(name)) { CanSave = true; } if (name == nameof(IsActive)) { OnPropertyChanged(nameof(ToggleMessage)); } }); }
/// <summary> /// Load content for the screen. /// </summary> /// <param name="GraphicInfo"></param> /// <param name="factory"></param> /// <param name="contentManager"></param> protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager) { base.LoadContent(GraphicInfo, factory, contentManager); ///Uncoment to add your model SimpleModel simpleModel = new SimpleModel(factory, "Model/cenario"); ///Physic info (position, rotation and scale are set here) TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial()); ///Forward Shader (look at this shader construction for more info) ForwardXNABasicShader shader = new ForwardXNABasicShader(); ///Deferred material ForwardMaterial fmaterial = new ForwardMaterial(shader); ///The object itself IObject obj = new IObject(fmaterial, simpleModel, tmesh); ///Add to the world this.World.AddObject(obj); ///add a camera this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo)); ///task sample taskSample taskSample = new taskSample(); ///when ended, call this (syncronous -- specified in the itask implementation) function taskSample.Ended += new Action <ITask, IAsyncResult>(taskSample_Ended); ///create and send the task to the processor TaskCommand TaskCommand = new TaskCommand(taskSample); CommandProcessor.getCommandProcessor().SendCommandAssyncronous(TaskCommand); }
/// <summary> /// Initializes a new instance of the <see cref="EmployeesViewModel"/> class. /// </summary> public EmployeesViewModel(IMessageMediator messageMediator, IUIVisualizerService uiVisualizerService, IEmployeeRepository employeeRepository, IMessageService messageService) : base(messageMediator) { Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => employeeRepository); Argument.IsNotNull(() => messageService); _uiVisualizerService = uiVisualizerService; _employeeRepository = employeeRepository; _messageService = messageService; AddEmployee = new TaskCommand(OnAddEmployeeExecuteAsync); EditEmployee = new TaskCommand(OnEditEmployeeExecuteAsync, OnEditEmployeeCanExecute); DeleteEmployee = new TaskCommand(OnDeleteEmployeeExecuteAsync, OnDeleteEmployeeCanExecute); Employees = new FastObservableCollection<IEmployee>(); if (!ObjectHelper.IsNull(SelectedDepartment)) { Employees.AddRange(EmployeeRepository.GetAllEmployees(SelectedDepartment.Name)); } if (Employees.Count > 0) { SelectedEmployee = Employees[0]; } Mediator.Register<string>(this, OnSelectedDepartmentUpdated, "UpdateEmployees"); }
/// <summary> /// Initializes a new instance of the <see cref="EmployeesViewModel"/> class. /// </summary> public EmployeesViewModel(IMessageMediator messageMediator, IUIVisualizerService uiVisualizerService, IEmployeeRepository employeeRepository, IMessageService messageService) : base(messageMediator) { Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => employeeRepository); Argument.IsNotNull(() => messageService); _uiVisualizerService = uiVisualizerService; _employeeRepository = employeeRepository; _messageService = messageService; AddEmployee = new TaskCommand(OnAddEmployeeExecuteAsync); EditEmployee = new TaskCommand(OnEditEmployeeExecuteAsync, OnEditEmployeeCanExecute); DeleteEmployee = new TaskCommand(OnDeleteEmployeeExecuteAsync, OnDeleteEmployeeCanExecute); Employees = new FastObservableCollection <IEmployee>(); if (!ObjectHelper.IsNull(SelectedDepartment)) { Employees.AddRange(EmployeeRepository.GetAllEmployees(SelectedDepartment.Name)); } if (Employees.Count > 0) { SelectedEmployee = Employees[0]; } Mediator.Register <string>(this, OnSelectedDepartmentUpdated, "UpdateEmployees"); }
public MainViewModel(IPackagesUIService packagesUiService, IEchoService echoService, INuGetConfigurationService nuGetConfigurationService, INuGetFeedVerificationService feedVerificationService, IMessageService messageService, IPackagesUpdatesSearcherService packagesUpdatesSearcherService, IPackageBatchService packageBatchService, IUIVisualizerService uiVisualizerService) { Argument.IsNotNull(() => packagesUiService); Argument.IsNotNull(() => echoService); Argument.IsNotNull(() => nuGetConfigurationService); Argument.IsNotNull(() => feedVerificationService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => packageBatchService); Argument.IsNotNull(() => uiVisualizerService); _packagesUiService = packagesUiService; _nuGetConfigurationService = nuGetConfigurationService; _feedVerificationService = feedVerificationService; _messageService = messageService; _packagesUpdatesSearcherService = packagesUpdatesSearcherService; _packageBatchService = packageBatchService; _uiVisualizerService = uiVisualizerService; Echo = echoService.GetPackageManagementEcho(); AvailableUpdates = new ObservableCollection <IPackageDetails>(); ShowExplorer = new Command(OnShowExplorerExecute); AdddPackageSource = new TaskCommand(OnAdddPackageSourceExecute, OnAdddPackageSourceCanExecute); VerifyFeed = new TaskCommand(OnVerifyFeedExecute, OnVerifyFeedCanExecute); CheckForUpdates = new TaskCommand(OnCheckForUpdatesExecute); OpenUpdateWindow = new TaskCommand(OnOpenUpdateWindowExecute, OnOpenUpdateWindowCanExecute); Settings = new TaskCommand(OnSettingsExecute); }
public MainViewModel(IUIVisualizerService uiVisualizerService, IPleaseWaitService pleaseWaitService, ILanguageService languageService) { Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => pleaseWaitService); Argument.IsNotNull(() => languageService); _uiVisualizerService = uiVisualizerService; _pleaseWaitService = pleaseWaitService; _languageService = languageService; AvailableLanguages = new ObservableCollection <Language>(); AvailableLanguages.Add(new Language("English", "en-US")); AvailableLanguages.Add(new Language("Chinese (simplified)", "zh-HANS")); AvailableLanguages.Add(new Language("Dutch", "nl")); AvailableLanguages.Add(new Language("French", "fr")); AvailableLanguages.Add(new Language("German", "de")); AvailableLanguages.Add(new Language("Spanish", "es")); AvailableLanguages.Add(new Language("Turkish", "tr")); var currentLanguage = (from language in AvailableLanguages where Thread.CurrentThread.CurrentUICulture.Name.StartsWith(language.Code) select language).FirstOrDefault(); SelectedLanguage = currentLanguage ?? AvailableLanguages[0]; DataWindow = new TaskCommand(OnDataWindowExecuteAsync); Title = "MultiLingual example"; }
public void Task_Execute_ReturnsEmpty() { var command = new TaskCommand(_console, LoggerMock.GetLogger <TaskCommand>().Object); var resultMessage = command.Execute(); Assert.Equal("", resultMessage); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class. /// </summary> public MainWindowViewModel(ILicenseService licenseService, ILicenseValidationService licenseValidationService, IMessageService messageService, INetworkLicenseService networkLicenseService, ILicenseVisualizerService licenseVisualizerService, IUIVisualizerService uiVisualizerService) { Argument.IsNotNull(() => licenseService); Argument.IsNotNull(() => licenseValidationService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => networkLicenseService); Argument.IsNotNull(() => licenseVisualizerService); Argument.IsNotNull(() => uiVisualizerService); _licenseService = licenseService; _licenseValidationService = licenseValidationService; _messageService = messageService; _networkLicenseService = networkLicenseService; _licenseVisualizerService = licenseVisualizerService; _uiVisualizerService = uiVisualizerService; RemoveLicense = new Command(OnRemoveLicenseExecute); ValidateLicenseOnServer = new TaskCommand(OnValidateLicenseOnServerExecuteAsync, OnValidateLicenseOnServerCanExecute); ValidateLicenseOnLocalNetwork = new TaskCommand(OnValidateLicenseOnLocalNetworkExecuteAsync, OnValidateLicenseOnLocalNetworkCanExecute); ShowLicense = new Command(OnShowLicenseExecute); ShowLicenseUsage = new Command(OnShowLicenseUsageExecute); ServerUri = string.Format("http://localhost:1815/api/license/validate"); }
/*********** FONCTION EFFECTUE ¨PAR LES THREADS ASYNCRONE *******/ public async void Work() { /// Console.WriteLine(queue.Count + "= TAILLE INITIALE" ); while (true) { while (queue.Count >= 1) { if (this.threads.First().Equals(Thread.CurrentThread)) { TaskCommand taskTemplate = (TaskCommand)queue.First(); try { this.RemoveTask(taskTemplate); Console.WriteLine(String.Concat(" ********* Executed by ", Thread.CurrentThread.Name)); taskTemplate.Execute(); await _semaphoreSlim.WaitAsync(); } finally { _semaphoreSlim.Release(); Thread currentThread = threads.First(); threads.Remove(currentThread); Thread.Sleep(500); threads.Add(currentThread); } } } } }
public void RemoveTask(TaskCommand _task) { lock (queue) { queue.Remove(_task); } }
public void enqueue(TaskCommand _task) { lock (queue) { queue.Add(_task); } }
public DocumentViewModel(string path, IMessageService messageService, ISaveFileService saveFileService, IMessageMediator messageMediator) { this.messageService = messageService; this.saveFileService = saveFileService; this.messageMediator = messageMediator; SaveCommand = new TaskCommand(SaveAsync, () => HasChanges); SaveAsCommand = new TaskCommand(SaveFileAs); if (string.IsNullOrWhiteSpace(path)) { Name = "Document " + (++documentCounter) + ".txt"; HasChanges = true; } else { fullFileName = path; Name = Path.GetFileName(path); Text = File.ReadAllText(path); HasChanges = false; } }
public AboutViewModel(AboutInfo aboutInfo, IProcessService processService, IUIVisualizerService uiVisualizerService, IMessageService messageService, ILanguageService languageService) { Argument.IsNotNull(() => aboutInfo); Argument.IsNotNull(() => processService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => languageService); _processService = processService; _uiVisualizerService = uiVisualizerService; _messageService = messageService; _languageService = languageService; var buildDateTime = aboutInfo.BuildDateTime.Value; Title = aboutInfo.Name; Version = string.Format("v {0}", aboutInfo.DisplayVersion); BuildDateTime = string.Format(languageService.GetString("Orchestra_BuiltOn"), buildDateTime); UriInfo = aboutInfo.UriInfo; Copyright = aboutInfo.Copyright; CopyrightUrl = aboutInfo.CopyrightUri == null ? null : aboutInfo.CopyrightUri.ToString(); CompanyLogoUri = aboutInfo.CompanyLogoUri; ImageSourceUrl = aboutInfo.LogoImageSource; ShowLogButton = aboutInfo.ShowLogButton; AppIcon = aboutInfo.AppIcon; OpenUrl = new Command(OnOpenUrlExecute, OnOpenUrlCanExecute); OpenCopyrightUrl = new Command(OnOpenCopyrightUrlExecute, OnOpenCopyrightUrlCanExecute); ShowThirdPartyNotices = new TaskCommand(OnShowThirdPartyNoticesExecuteAsync); OpenLog = new TaskCommand(OnOpenLogExecuteAsync); ShowSystemInfo = new TaskCommand(OnShowSystemInfoExecuteAsync); EnableDetailedLogging = new Command(OnEnableDetailedLoggingExecute); }
public AboutViewModel(AboutInfo aboutInfo, IProcessService processService, IUIVisualizerService uiVisualizerService, IMessageService messageService, ILanguageService languageService) { Argument.IsNotNull(() => aboutInfo); Argument.IsNotNull(() => processService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => languageService); _processService = processService; _uiVisualizerService = uiVisualizerService; _messageService = messageService; _languageService = languageService; var assembly = aboutInfo.Assembly; var version = aboutInfo.DisplayVersion; var buildDateTime = aboutInfo.BuildDateTime.Value; Title = aboutInfo.Name; Version = string.Format("v {0}", aboutInfo.DisplayVersion); BuildDateTime = string.Format(languageService.GetString("Orchestra_BuiltOn"), buildDateTime); UriInfo = aboutInfo.UriInfo; Copyright = aboutInfo.Copyright; CompanyLogoUri = aboutInfo.CompanyLogoUri; ImageSourceUrl = aboutInfo.LogoImageSource; ShowLogButton = aboutInfo.ShowLogButton; AppIcon = aboutInfo.AppIcon; OpenUrl = new Command(OnOpenUrlExecute, OnOpenUrlCanExecute); OpenLog = new TaskCommand(OnOpenLogExecuteAsync); ShowSystemInfo = new Command(OnShowSystemInfoExecute); EnableDetailedLogging = new Command(OnEnableDetailedLoggingExecute); }
public FilterBuilderViewModel(IUIVisualizerService uiVisualizerService, IFilterSchemeManager filterSchemeManager, IFilterService filterService, IMessageService messageService, IServiceLocator serviceLocator, IReflectionService reflectionService, ILanguageService languageService) { Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => filterSchemeManager); Argument.IsNotNull(() => filterService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => serviceLocator); Argument.IsNotNull(() => reflectionService); Argument.IsNotNull(() => languageService); _uiVisualizerService = uiVisualizerService; _filterSchemeManager = filterSchemeManager; _filterService = filterService; _messageService = messageService; _serviceLocator = serviceLocator; _reflectionService = reflectionService; _languageService = languageService; NewSchemeCommand = new TaskCommand(OnNewSchemeExecuteAsync); EditSchemeCommand = new TaskCommand <FilterScheme>(OnEditSchemeExecuteAsync, OnEditSchemeCanExecute); ApplySchemeCommand = new TaskCommand(OnApplySchemeExecuteAsync, OnApplySchemeCanExecute); ResetSchemeCommand = new Command(OnResetSchemeExecute, OnResetSchemeCanExecute); DeleteSchemeCommand = new Command <FilterScheme>(OnDeleteSchemeExecute, OnDeleteSchemeCanExecute); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class. /// </summary> public MainWindowViewModel(ILicenseService licenseService, ILicenseValidationService licenseValidationService, IMessageService messageService, INetworkLicenseService networkLicenseService, ILicenseVisualizerService licenseVisualizerService, IUIVisualizerService uiVisualizerService) { Argument.IsNotNull(() => licenseService); Argument.IsNotNull(() => licenseValidationService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => networkLicenseService); Argument.IsNotNull(() => licenseVisualizerService); Argument.IsNotNull(() => uiVisualizerService); _licenseService = licenseService; _licenseValidationService = licenseValidationService; _messageService = messageService; _networkLicenseService = networkLicenseService; _licenseVisualizerService = licenseVisualizerService; _uiVisualizerService = uiVisualizerService; RemoveLicense = new Command(OnRemoveLicenseExecute); ValidateLicenseOnServer = new TaskCommand(OnValidateLicenseOnServerExecuteAsync, OnValidateLicenseOnServerCanExecute); ValidateLicenseOnLocalNetwork = new TaskCommand(OnValidateLicenseOnLocalNetworkExecuteAsync, OnValidateLicenseOnLocalNetworkCanExecute); ShowLicense = new Command(OnShowLicenseExecute); ShowLicenseUsage = new Command(OnShowLicenseUsageExecute); ServerUri = string.Format("http://localhost:1815/api/license/validate"); }
public MainViewModel(IPackagesUIService packagesUiService, IEchoService echoService, INuGetConfigurationService nuGetConfigurationService, INuGetFeedVerificationService feedVerificationService, IMessageService messageService, IPackagesUpdatesSearcherService packagesUpdatesSearcherService, IPackageBatchService packageBatchService, IUIVisualizerService uiVisualizerService) { Argument.IsNotNull(() => packagesUiService); Argument.IsNotNull(() => echoService); Argument.IsNotNull(() => nuGetConfigurationService); Argument.IsNotNull(() => feedVerificationService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => packageBatchService); Argument.IsNotNull(() => uiVisualizerService); _packagesUiService = packagesUiService; _nuGetConfigurationService = nuGetConfigurationService; _feedVerificationService = feedVerificationService; _messageService = messageService; _packagesUpdatesSearcherService = packagesUpdatesSearcherService; _packageBatchService = packageBatchService; _uiVisualizerService = uiVisualizerService; Echo = echoService.GetPackageManagementEcho(); AvailableUpdates = new ObservableCollection<IPackageDetails>(); ShowExplorer = new Command(OnShowExplorerExecute); AdddPackageSource = new TaskCommand(OnAdddPackageSourceExecute, OnAdddPackageSourceCanExecute); VerifyFeed = new TaskCommand(OnVerifyFeedExecute, OnVerifyFeedCanExecute); CheckForUpdates = new TaskCommand(OnCheckForUpdatesExecute); OpenUpdateWindow = new TaskCommand(OnOpenUpdateWindowExecute, OnOpenUpdateWindowCanExecute); Settings = new TaskCommand(OnSettingsExecute); }
public RibbonViewModel(IRegexService regexService, ICommandManager commandManager, INavigationService navigationService, IConfigurationService configurationService, IUIVisualizerService uiVisualizerService, IWorkspaceManager workspaceManager, IPleaseWaitService pleaseWaitService, IFilterService filterService) { Argument.IsNotNull(() => regexService); Argument.IsNotNull(() => commandManager); Argument.IsNotNull(() => navigationService); Argument.IsNotNull(() => configurationService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => workspaceManager); Argument.IsNotNull(() => pleaseWaitService); Argument.IsNotNull(() => filterService); _regexService = regexService; Filter = filterService.Filter; _navigationService = navigationService; _configurationService = configurationService; _uiVisualizerService = uiVisualizerService; _workspaceManager = workspaceManager; _pleaseWaitService = pleaseWaitService; _filterService = filterService; SaveWorkspace = new TaskCommand(OnSaveWorkspaceExecuteAsync, OnSaveWorkspaceCanExecute); CreateWorkspace = new TaskCommand(OnCreateWorkspaceExecuteAsync); ShowKeyboardMappings = new TaskCommand(OnShowKeyboardMappingsExecuteAsync); Title = AssemblyHelper.GetEntryAssembly().Title(); }
public AboutViewModel(AboutInfo aboutInfo, IProcessService processService, IUIVisualizerService uiVisualizerService, IMessageService messageService) { Argument.IsNotNull(() => aboutInfo); Argument.IsNotNull(() => processService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageService); _processService = processService; _uiVisualizerService = uiVisualizerService; _messageService = messageService; var assembly = aboutInfo.Assembly; var version = VersionHelper.GetCurrentVersion(assembly); var buildDateTime = assembly.GetBuildDateTime(); Title = assembly.Title(); Version = string.Format("v {0}", version); BuildDateTime = string.Format("Built on {0}", buildDateTime); UriInfo = aboutInfo.UriInfo; Copyright = assembly.Copyright(); CompanyLogoUri = aboutInfo.CompanyLogoUri; ImageSourceUrl = aboutInfo.LogoImageSource; ShowLogButton = aboutInfo.ShowLogButton; AppIcon = assembly.ExtractLargestIcon(); OpenUrl = new Command(OnOpenUrlExecute, OnOpenUrlCanExecute); OpenLog = new TaskCommand(OnOpenLogExecuteAsync); ShowSystemInfo = new Command(OnShowSystemInfoExecute); EnableDetailedLogging = new Command(OnEnableDetailedLoggingExecute); }
public ConnectionStringEditViewModel(string connectionString, DbProvider provider, IMessageService messageService, IConnectionStringBuilderService connectionStringBuilderService, IUIVisualizerService uiVisualizerService, ITypeFactory typeFactory, IDispatcherService dispatcherService) { Argument.IsNotNull(() => connectionStringBuilderService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => typeFactory); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => dispatcherService); _messageService = messageService; _connectionStringBuilderService = connectionStringBuilderService; _uiVisualizerService = uiVisualizerService; _typeFactory = typeFactory; _dispatcherService = dispatcherService; _initalDbProvider = provider; _initialConnectionString = connectionString; InitServers = new Command(() => InitServersAsync(), () => !IsServersRefreshing); RefreshServers = new Command(() => RefreshServersAsync(), () => !IsServersRefreshing); InitDatabases = new Command(() => InitDatabasesAsync(), () => !IsDatabasesRefreshing); RefreshDatabases = new Command(() => RefreshDatabasesAsync(), CanInitDatabases); TestConnection = new Command(OnTestConnection); ShowAdvancedOptions = new TaskCommand(OnShowAdvancedOptionsAsync, () => ConnectionString != null); _initializeTimer.Elapsed += OnInitializeTimerElapsed; }
public async Task TestCommandExceptions_SwallowExceptionsAsync() { var taskCommand = new TaskCommand(TestExecuteWithExceptionAsync) { SwallowExceptions = true }; Assert.IsFalse(taskCommand.IsExecuting); Assert.IsFalse(taskCommand.IsCancellationRequested); try { taskCommand.Execute(); Assert.IsTrue(taskCommand.IsExecuting); await taskCommand.Task; } catch (Exception ex) { Assert.Fail($"No exception expected, should be swallowed, but got '{ex}'"); } Assert.IsFalse(taskCommand.IsExecuting); }
/// <summary> /// Initializes a new instance of the <see cref="LicenseViewModel" /> class. /// </summary> /// <param name="licenseInfo">The single license model.</param> /// <param name="navigationService">The navigation service.</param> /// <param name="processService">The process service.</param> /// <param name="licenseService">The license service.</param> /// <param name="licenseValidationService">The license validation service.</param> /// <param name="uiVisualizerService">The uiVisualizer service.</param> /// <param name="messageService">The message service.</param> /// <exception cref="ArgumentNullException">The <paramref name="licenseInfo" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="navigationService" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="processService" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="licenseService" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="uiVisualizerService" /> is <c>null</c>.</exception> public LicenseViewModel(LicenseInfo licenseInfo, INavigationService navigationService, IProcessService processService, ILicenseService licenseService, ILicenseValidationService licenseValidationService, IUIVisualizerService uiVisualizerService, IMessageService messageService) { Argument.IsNotNull(() => licenseInfo); Argument.IsNotNull(() => navigationService); Argument.IsNotNull(() => processService); Argument.IsNotNull(() => licenseService); Argument.IsNotNull(() => licenseValidationService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageService); _navigationService = navigationService; _processService = processService; _licenseService = licenseService; _licenseValidationService = licenseValidationService; _uiVisualizerService = uiVisualizerService; _messageService = messageService; LicenseInfo = licenseInfo; Title = licenseInfo.Title; XmlData = new ObservableCollection<XmlDataModel>(); Paste = new TaskCommand(OnPasteExecuteAsync); ShowClipboard = new Command(OnShowClipboardExecute); PurchaseLinkClick = new Command(OnPurchaseLinkClickExecute); AboutSiteClick = new Command(OnAboutSiteClickExecute); RemoveLicense = new TaskCommand(OnRemoveLicenseExecuteAsync, OnRemoveLicenseCanExecute); }
public async Task TestCommandExceptions_DontSwallowExceptionsAsync() { var taskCommand = new TaskCommand(TestExecuteWithExceptionAsync) { SwallowExceptions = false }; Assert.IsFalse(taskCommand.IsExecuting); Assert.IsFalse(taskCommand.IsCancellationRequested); try { taskCommand.Execute(); Assert.IsTrue(taskCommand.IsExecuting); await taskCommand.Task; Assert.Fail("Expected exception"); } catch (Exception) { } Assert.IsFalse(taskCommand.IsExecuting); }
public AboutViewModel(AboutInfo aboutInfo, IProcessService processService, IUIVisualizerService uiVisualizerService, IMessageService messageService, ILanguageService languageService) { Argument.IsNotNull(() => aboutInfo); Argument.IsNotNull(() => processService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => languageService); _processService = processService; _uiVisualizerService = uiVisualizerService; _messageService = messageService; _languageService = languageService; var assembly = aboutInfo.Assembly; var version = VersionHelper.GetCurrentVersion(assembly); var buildDateTime = assembly.GetBuildDateTime(); Title = assembly.Title(); Version = string.Format("v {0}", version); BuildDateTime = string.Format(languageService.GetString("Orchestra_BuiltOn"), buildDateTime); UriInfo = aboutInfo.UriInfo; Copyright = assembly.Copyright(); CompanyLogoUri = aboutInfo.CompanyLogoUri; ImageSourceUrl = aboutInfo.LogoImageSource; ShowLogButton = aboutInfo.ShowLogButton; AppIcon = assembly.ExtractLargestIcon(); OpenUrl = new Command(OnOpenUrlExecute, OnOpenUrlCanExecute); OpenLog = new TaskCommand(OnOpenLogExecuteAsync); ShowSystemInfo = new Command(OnShowSystemInfoExecute); EnableDetailedLogging = new Command(OnEnableDetailedLoggingExecute); }
public ReceiverViewModel(Receiver dataItem) { Closable = true; DataItem = dataItem; DisplayName = DataItem.DisplayName; PortNumber = DataItem.PortNumber; ReceiverType = DataItem.ReceiverType; IpAddress = DataItem.IpAddress; Broadcast = DataItem.Broadcast; Encoding = DataItem.Encoding; SaveCommand = new TaskCommand(SaveExecute, d => !IsActive && CanSave); ToggleCommand = new TaskCommand(ToggleExecute, d => !CanSave || IsActive); ClearMessagesCommand = new TaskCommand(ClearMessagesExecute, d => Messages.Count > 0); Encodings = new ObservableCollection <SelectorOption <Encoding> >(EncodingOptionsFactory.GetAll()); WhenPropertyChanged.Subscribe(name => { if (new[] { nameof(DisplayName), nameof(PortNumber), nameof(ReceiverType), nameof(IpAddress), nameof(Broadcast), nameof(Encoding) }.Contains(name)) { CanSave = true; } if (name == nameof(IsActive)) { OnPropertyChanged(nameof(ToggleMessage)); } }); }
public RibbonViewModel(INavigationService navigationService, IUIVisualizerService uiVisualizerService, ICommandManager commandManager, IRecentlyUsedItemsService recentlyUsedItemsService, IProcessService processService, IMessageService messageService, ISelectDirectoryService selectDirectoryService, IDirectoryService directoryService) { Argument.IsNotNull(() => navigationService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => commandManager); Argument.IsNotNull(() => recentlyUsedItemsService); Argument.IsNotNull(() => processService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => selectDirectoryService); Argument.IsNotNull(() => directoryService); _navigationService = navigationService; _uiVisualizerService = uiVisualizerService; _recentlyUsedItemsService = recentlyUsedItemsService; _processService = processService; _messageService = messageService; _selectDirectoryService = selectDirectoryService; _directoryService = directoryService; OpenProject = new TaskCommand(OnOpenProjectExecuteAsync); OpenRecentlyUsedItem = new TaskCommand <string>(OnOpenRecentlyUsedItemExecuteAsync); OpenInExplorer = new TaskCommand <string>(OnOpenInExplorerExecuteAsync); UnpinItem = new Command <string>(OnUnpinItemExecute); PinItem = new Command <string>(OnPinItemExecute); ShowKeyboardMappings = new TaskCommand(OnShowKeyboardMappingsExecuteAsync); commandManager.RegisterCommand("File.Open", OpenProject, this); var assembly = AssemblyHelper.GetEntryAssembly(); Title = assembly.Title(); }
static DefaultRadGridContextMenuCommands() { var servicelocator = ServiceLocator.Default; ViewModelFactory = servicelocator.ResolveType <IViewModelFactory>(); UIVisualizerService = servicelocator.ResolveType <IUIVisualizerService>(); //SaveFileService = servicelocator.ResolveType<ISaveFileService>(); //OpenFileService = servicelocator.ResolveType<IOpenFileService>(); //StorageService = servicelocator.ResolveType<IStorageService>(); SortAscendingCommand = new Command <HeaderCommandParameter>(OnSortAscendingExecute); SortDescendingCommand = new Command <HeaderCommandParameter>(OnSortDescendingExecute); SortClearingCommand = new Command <HeaderCommandParameter>(OnSortClearingExecute); GroupByCommand = new Command <HeaderCommandParameter>(OnGroupByExecute); UnGroupByCommand = new Command <HeaderCommandParameter>(OnUnGroupByExecute); DeleteFiltersCommand = new Command <HeaderCommandParameter>(OnDeleteFiltersExecute); //ExportGridCommand = new Command<RadGridView>(OnExportGridCommand, CanExecuteExportGrid); //SaveSettingsCommand = new Command<HeaderCommandParameter>(OnSaveSettingsCommandExecute, CanSaveSettingsCommandExecute); //LoadSettingsCommand = new Command<HeaderCommandParameter>(OnLoadSettingsCommandExecute, CanLoadSettingsCommandExecute); ClearSettingsCommand = new Command <HeaderCommandParameter>(OnClearSettingsCommandExecute); SetDefaultCommand = new Command <HeaderCommandParameter>(OnSetDefaultCommandExecute); ChangeColorCommand = new TaskCommand <HeaderCommandParameter>(OnChangeColorCommandExecute); ChangeFontCommand = new TaskCommand <HeaderCommandParameter>(OnChangeFontCommandExecute); PropertiesCommand = new TaskCommand <HeaderCommandParameter>(OnPropertiesCommandExecute); //BaseStyle = Application.Current.FindResource("GridViewCellCoreStyle") as System.Windows.Style; }
public PageActionBarViewModel(IManagerPage managerPage, IProgressManager progressManager, INuGetPackageManager projectManager, IExtensibleProjectLocator projectLocator, IPackageCommandService packageCommandService, IPackageOperationContextService packageOperationContextService, IMessageService messageService) { Argument.IsNotNull(() => managerPage); Argument.IsNotNull(() => projectManager); Argument.IsNotNull(() => progressManager); Argument.IsNotNull(() => projectLocator); Argument.IsNotNull(() => packageCommandService); Argument.IsNotNull(() => packageOperationContextService); Argument.IsNotNull(() => messageService); _parentManagerPage = managerPage; _projectManager = projectManager; _projectLocator = projectLocator; _progressManager = progressManager; _packageCommandService = packageCommandService; _packageOperationContextService = packageOperationContextService; _messageService = messageService; BatchUpdate = new TaskCommand(BatchUpdateExecuteAsync, BatchUpdateCanExecute); BatchInstall = new TaskCommand(BatchInstallExecuteAsync, BatchInstallCanExecute); CheckAll = new TaskCommand(CheckAllExecuteAsync); CanBatchInstall = _parentManagerPage.CanBatchInstallOperations; CanBatchUpdate = _parentManagerPage.CanBatchUpdateOperations; }
/// <summary> /// Initializes a new instance of the <see cref="BehaviorsWindowViewModel"/> class. /// </summary> public BehaviorsWindowViewModel(IMessageService messageService) { _messageService = messageService; DoubleClickToCommandExample = new TaskCommand(OnDoubleClickToCommandExampleExecuteAsync); EventToCommandForLostFocus = new TaskCommand(OnEventToCommandForLostFocusExecuteAsync); KeyPressToCommandExample = new TaskCommand(OnKeyPressToCommandExampleExecuteAsync); }
public MainViewModel() { GoToFingerPaintingCommand = new TaskCommand(OnGoToFingerPainting); GoToLocalVideoCommand = new TaskCommand(OnGoToLocalVideo); GoToLocalSoundCommand = new TaskCommand(OnGoToLocalSound); GoToDragAndDropCommand = new TaskCommand(GoToDragAndDrop); GoToShapesCommand = new TaskCommand(GoToShapes); }
/// <summary> /// Initializes a new instance of the <see cref="BehaviorsWindowViewModel"/> class. /// </summary> public BehaviorsWindowViewModel(IMessageService messageService) { _messageService = messageService; DoubleClickToCommandExample = new TaskCommand(OnDoubleClickToCommandExampleExecuteAsync); EventToCommandForLostFocus = new TaskCommand(OnEventToCommandForLostFocusExecuteAsync); KeyPressToCommandExample = new TaskCommand(OnKeyPressToCommandExampleExecuteAsync); }
public MainViewModel(IWizardService wizardService) { Argument.IsNotNull(() => wizardService); _wizardService = wizardService; ShowWizard = new TaskCommand(OnShowWizardExecuteAsync); Title = "Orc.Wizard example"; }
public TrackDetailsViewModel(IGoogleAnalyticsService googleAnalyticsService) { Argument.IsNotNull(() => googleAnalyticsService); _googleAnalyticsService = googleAnalyticsService; Send = new TaskCommand(OnSendExecuteAsync, OnSendCanExecute); Category = "category"; Action = "action"; }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class. /// </summary> public MainWindowViewModel(IUIVisualizerService uiVisualizerService, ITabService tabService) { _uiVisualizerService = uiVisualizerService; _tabService = tabService; _timer.Tick += OnTimerTick; _timer.Interval = new TimeSpan(0, 0, 0, 0, 500); _timer.Start(); AddTab = new TaskCommand(OnAddTabExecuteAsync); }
public MainViewModel(IWizardService wizardService, ITypeFactory typeFactory) { Argument.IsNotNull(() => wizardService); Argument.IsNotNull(() => typeFactory); _wizardService = wizardService; _typeFactory = typeFactory; ShowWizard = new TaskCommand(OnShowWizardExecuteAsync); Title = "Orc.Wizard example"; }
public WorkspacesViewModel(IWorkspaceManager workspaceManager, IUIVisualizerService uiVisualizerService) { Argument.IsNotNull(() => workspaceManager); Argument.IsNotNull(() => uiVisualizerService); _workspaceManager = workspaceManager; _uiVisualizerService = uiVisualizerService; AvailableWorkspaces = new FastObservableCollection<IWorkspace>(); EditWorkspace = new Command<IWorkspace>(OnEditWorkspaceExecute, OnEditWorkspaceCanExecute); RemoveWorkspace = new TaskCommand<IWorkspace>(OnRemoveWorkspaceExecuteAsync, OnRemoveWorkspaceCanExecute); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class. /// </summary> public MainWindowViewModel(IUIVisualizerService uiVisualizerService, IMessageService messageService) { _uiVisualizerService = uiVisualizerService; _messageService = messageService; Add = new TaskCommand(OnAddExecuteAsync); Edit = new TaskCommand(OnEditExecuteAsync, OnEditCanExecute); Remove = new TaskCommand(OnRemoveExecuteAsync, OnRemoveCanExecute); PersonCollection = new ObservableCollection<Person>(); PersonCollection.Add(new Person { Gender = Gender.Male, FirstName = "Geert", MiddleName = "van", LastName = "Horrik" }); PersonCollection.Add(new Person { Gender = Gender.Male, FirstName = "Fred", MiddleName = "", LastName = "Retteket" }); }
public RibbonViewModel(IWorkspaceManager workspaceManager, IViewModelFactory viewModelFactory, IUIVisualizerService uiVisualizerService, ISelectDirectoryService selectDirectoryService) { _workspaceManager = workspaceManager; _viewModelFactory = viewModelFactory; _uiVisualizerService = uiVisualizerService; _selectDirectoryService = selectDirectoryService; AddWorkspace = new TaskCommand(OnAddWorkspaceExecuteAsync); SaveWorkspace = new TaskCommand(OnSaveWorkspaceExecuteAsync, OnSaveWorkspaceCanExecute); EditWorkspace = new Command(OnEditWorkspaceExecute, OnEditWorkspaceCanExecute); RemoveWorkspace = new TaskCommand(OnRemoveWorkspaceExecuteAsync, OnRemoveWorkspaceCanExecute); ChooseBaseDirectory = new TaskCommand(OnChooseBaseDirectoryAsync); }
public FamilyWindowViewModel(Family family, IUIVisualizerService uiVisualizerService, IMessageService messageService) { Argument.IsNotNull(() => family); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageService); Family = family; _uiVisualizerService = uiVisualizerService; _messageService = messageService; AddPerson = new TaskCommand(OnAddPersonExecuteAsync); EditPerson = new TaskCommand(OnEditPersonExecuteAsync, OnEditPersonCanExecute); RemovePerson = new TaskCommand(OnRemovePersonExecuteAsync, OnRemovePersonCanExecute); }
/// <summary> /// Initializes a new instance of the <see cref="ClipBoardViewModel"/> class. /// </summary> public ClipBoardViewModel() { Title = "Clipboard"; Exit = new TaskCommand(OnExitExecuteAsync); var clipBoardData = Clipboard.GetText(); if (string.IsNullOrWhiteSpace(clipBoardData)) { ClipBoardText = "There is no text on your clipboard to display!"; } else { ClipBoardText = clipBoardData; } }
public ShellViewModel(ITaskRunnerService taskRunnerService, ICommandManager commandManager) { Argument.IsNotNull(() => taskRunnerService); Argument.IsNotNull(() => commandManager); _taskRunnerService = taskRunnerService; Run = new TaskCommand(OnRunExecuteAsync, OnRunCanExecute); commandManager.RegisterCommand("Runner.Run", Run, this); SuspendValidation = true; Title = taskRunnerService.Title; taskRunnerService.TitleChanged += (sender, args) => Title = taskRunnerService.Title; }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class. /// </summary> public MainWindowViewModel(IUIVisualizerService uiVisualizerService, IMessageService messageService, IMementoService mementoService) { _uiVisualizerService = uiVisualizerService; _messageService = messageService; _mementoService = mementoService; Add = new TaskCommand(OnAddExecuteAsync); Edit = new TaskCommand(OnEditExecuteAsync, OnEditCanExecute); Remove = new TaskCommand(OnRemoveExecuteAsync, OnRemoveCanExecute); Undo = new Command(() => _mementoService.Undo(), () => _mementoService.CanUndo); Redo = new Command(() => _mementoService.Redo(), () => _mementoService.CanRedo); PersonCollection = new ObservableCollection<Person> {new Person {Gender = Gender.Male, FirstName = "Geert", MiddleName = "van", LastName = "Horrik"}, new Person {Gender = Gender.Male, FirstName = "Fred", MiddleName = "", LastName = "Retteket"}}; _mementoService.RegisterCollection(PersonCollection); }
public WizardViewModel(IWizard wizard, IMessageService messageService, ILanguageService languageService) { Argument.IsNotNull(() => wizard); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => languageService); DeferValidationUntilFirstSaveCall = true; Wizard = wizard; _messageService = messageService; _languageService = languageService; Finish = new TaskCommand(OnFinishExecuteAsync, OnFinishCanExecute); Cancel = new TaskCommand(OnCancelExecuteAsync, OnCancelCanExecuteAsync); GoToNext = new TaskCommand(OnGoToNextExecuteAsync, OnGoToNextCanExecute); GoToPrevious = new TaskCommand(OnGoToPreviousExecuteAsync, OnGoToPreviousCanExecute); }
public CrashWarningViewModel(IAppDataService appDataService, IMessageService messageService, INavigationService navigationService) { Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => navigationService); Argument.IsNotNull(() => navigationService); Argument.IsNotNull(() => appDataService); _appDataService = appDataService; _messageService = messageService; _navigationService = navigationService; _assembly = AssemblyHelper.GetEntryAssembly(); Continue = new TaskCommand(OnContinueExecuteAsync); ResetUserSettings = new TaskCommand(OnResetUserSettingsExecuteAsync); BackupAndReset = new TaskCommand(OnResetAndBackupExecuteAsync); }
public MessageBoxViewModel(IMessageService messageService, IClipboardService clipboardService) { Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => clipboardService); _messageService = messageService; _clipboardService = clipboardService; CopyToClipboard = new Command(OnCopyToClipboardExecute); OkCommand = new TaskCommand(OnOkCommandExecuteAsync); YesCommand = new TaskCommand(OnYesCommandExecuteAsync); NoCommand = new TaskCommand(OnNoCommandExecuteAsync); CancelCommand = new TaskCommand(OnCancelCommandExecuteAsync); EscapeCommand = new TaskCommand(OnEscapeCommandExecuteAsync); Result = MessageResult.None; }
public async Task TestCommandCancellation() { var taskCommand = new TaskCommand(TestExecute); Assert.IsFalse(taskCommand.IsExecuting); Assert.IsFalse(taskCommand.IsCancellationRequested); taskCommand.Execute(); Assert.IsTrue(taskCommand.IsExecuting); await Task.Delay(TimeSpan.FromSeconds(1)); taskCommand.Cancel(); await Task.Delay(TimeSpan.FromSeconds(1)); Assert.IsFalse(taskCommand.IsExecuting); Assert.IsFalse(taskCommand.IsCancellationRequested); }
public void TestCommandCancellation() { var taskCommand = new TaskCommand(TestExecuteAsync); Assert.IsFalse(taskCommand.IsExecuting); Assert.IsFalse(taskCommand.IsCancellationRequested); taskCommand.Execute(); Assert.IsTrue(taskCommand.IsExecuting); ThreadHelper.Sleep(1000); taskCommand.Cancel(); ThreadHelper.Sleep(1000); Assert.IsFalse(taskCommand.IsExecuting); Assert.IsFalse(taskCommand.IsCancellationRequested); }
public KeyboardMappingsOverviewViewModel(ICommandManager commandManager, ICommandInfoService commandInfoService, IUIVisualizerService uiVisualizerService, ILanguageService languageService, IViewExportService viewExportService, IKeyboardMappingsService keyboardMappingsService) { Argument.IsNotNull(() => commandManager); Argument.IsNotNull(() => commandInfoService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => languageService); Argument.IsNotNull(() => viewExportService); Argument.IsNotNull(() => keyboardMappingsService); _commandManager = commandManager; _commandInfoService = commandInfoService; _uiVisualizerService = uiVisualizerService; _languageService = languageService; _viewExportService = viewExportService; _keyboardMappingsService = keyboardMappingsService; Print = new Command(OnPrintExecute); Customize = new TaskCommand(OnCustomizeExecuteAsync); }
public NotificationViewModel(INotification notification, INotificationService notificationService) { Argument.IsNotNull(() => notification); Notification = notification; IsClosable = notification.IsClosable; Title = notification.Title; Message = notification.Message; Command = notification.Command; ShowTime = notification.ShowTime; BorderBrush = notification.BorderBrush ?? notificationService.DefaultBorderBrush; BackgroundBrush = notification.BackgroundBrush ?? notificationService.DefaultBackgroundBrush; FontBrush = notification.FontBrush ?? notificationService.DefaultFontBrush; AppIcon = ExtractLargestIcon(); PauseTimer = new Command(OnPauseTimerExecute); ResumeTimer = new Command(OnResumeTimerExecute); ClosePopup = new TaskCommand(OnClosePopupExecuteAsync); }
/// <summary> /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class. /// </summary> public MainWindowViewModel(IProjectManager projectManager, IOpenFileService openFileService, ISaveFileService saveFileService, IProcessService processService, IMessageService messageService) { Argument.IsNotNull(() => projectManager); Argument.IsNotNull(() => openFileService); Argument.IsNotNull(() => saveFileService); Argument.IsNotNull(() => processService); _projectManager = projectManager; _openFileService = openFileService; _saveFileService = saveFileService; _processService = processService; _messageService = messageService; LoadProject = new TaskCommand(OnLoadProjectExecuteAsync); RefreshProject = new TaskCommand(OnRefreshProjectExecuteAsync, OnRefreshProjectCanExecute); SaveProject = new TaskCommand(OnSaveProjectExecuteAsync, OnSaveProjectCanExecute); SaveProjectAs = new TaskCommand(OnSaveProjectAsExecuteAsync, OnSaveProjectAsCanExecute); CloseProject = new Command(OnCloseProjectExecute, OnCloseProjectCanExecute); OpenFile = new Command(OnOpenFileExecute, OnOpenFileCanExecute); }
public PersonsViewModel(IFlyoutService flyoutService, IMessageService messageService, IDispatcherService dispatcherService) { Argument.IsNotNull(() => flyoutService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => dispatcherService); _flyoutService = flyoutService; _messageService = messageService; _dispatcherService = dispatcherService; Persons = new ObservableCollection<Person>(); Persons.Add(new Person { FirstName = "John", LastName = "Doe" }); Add = new Command(OnAddExecute); Edit = new Command(OnEditExecute, OnEditCanExecute); Remove = new TaskCommand(OnRemoveExecuteAsync, OnRemoveCanExecute); }
public FilterBuilderViewModel(IUIVisualizerService uiVisualizerService, IFilterSchemeManager filterSchemeManager, IFilterService filterService, IMessageService messageService, IServiceLocator serviceLocator) { Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => filterSchemeManager); Argument.IsNotNull(() => filterService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => serviceLocator); _uiVisualizerService = uiVisualizerService; _filterSchemeManager = filterSchemeManager; _filterService = filterService; _messageService = messageService; _serviceLocator = serviceLocator; NewSchemeCommand = new Command(OnNewSchemeExecute); EditSchemeCommand = new TaskCommand<FilterScheme>(OnEditSchemeExecuteAsync, OnEditSchemeCanExecute); ApplySchemeCommand = new TaskCommand(OnApplySchemeExecuteAsync, OnApplySchemeCanExecute); ResetSchemeCommand = new Command(OnResetSchemeExecute, OnResetSchemeCanExecute); DeleteSchemeCommand = new Command<FilterScheme>(OnDeleteSchemeExecute, OnDeleteSchemeCanExecute); }
public ExplorerViewModel(IRepositoryNavigatorService repositoryNavigatorService, ISearchSettingsService searchSettingsService, IPackageCommandService packageCommandService, IPleaseWaitService pleaseWaitService, IPackageQueryService packageQueryService, ISearchResultService searchResultService, IDispatcherService dispatcherService, IPackagesUpdatesSearcherService packagesUpdatesSearcherService, IPackageBatchService packageBatchService, INuGetConfigurationService nuGetConfigurationService, IConfigurationService configurationService) { Argument.IsNotNull(() => repositoryNavigatorService); Argument.IsNotNull(() => searchSettingsService); Argument.IsNotNull(() => packageCommandService); Argument.IsNotNull(() => pleaseWaitService); Argument.IsNotNull(() => packageQueryService); Argument.IsNotNull(() => searchResultService); Argument.IsNotNull(() => dispatcherService); Argument.IsNotNull(() => packagesUpdatesSearcherService); Argument.IsNotNull(() => packageBatchService); Argument.IsNotNull(() => nuGetConfigurationService); Argument.IsNotNull(() => configurationService); _repositoryNavigatorService = repositoryNavigatorService; _packageCommandService = packageCommandService; _pleaseWaitService = pleaseWaitService; _packageQueryService = packageQueryService; _dispatcherService = dispatcherService; _packagesUpdatesSearcherService = packagesUpdatesSearcherService; _packageBatchService = packageBatchService; _nuGetConfigurationService = nuGetConfigurationService; _configurationService = configurationService; SearchSettings = searchSettingsService.SearchSettings; SearchResult = searchResultService.SearchResult; AvailableUpdates = new ObservableCollection<IPackageDetails>(); PackageAction = new TaskCommand<IPackageDetails>(OnPackageActionExecuteAsync, OnPackageActionCanExecute); CheckForUpdates = new TaskCommand(OnCheckForUpdatesExecute); OpenUpdateWindow = new TaskCommand(OnOpenUpdateWindowExecuteAsync); AccentColorHelper.CreateAccentColorResourceDictionary(); }
public KeyboardMappingsCustomizationViewModel(IKeyboardMappingsService keyboardMappingsService, ICommandManager commandManager, ICommandInfoService commandInfoService, ILanguageService languageService, IMessageService messageService) { Argument.IsNotNull(() => keyboardMappingsService); Argument.IsNotNull(() => commandManager); Argument.IsNotNull(() => commandInfoService); Argument.IsNotNull(() => languageService); Argument.IsNotNull(() => messageService); _keyboardMappingsService = keyboardMappingsService; _commandManager = commandManager; _commandInfoService = commandInfoService; _languageService = languageService; _messageService = messageService; Commands = new FastObservableCollection<ICommandInfo>(); CommandFilter = string.Empty; SelectedCommand = string.Empty; Reset = new TaskCommand(OnResetExecuteAsync); Remove = new Command(OnRemoveExecute, OnRemoveCanExecute); Assign = new TaskCommand(OnAssignExecuteAsync, OnAssignCanExecute); }