/// <summary> /// Initializes a new instance of the <see cref="AppearanceManager"/> class. /// </summary> private AppearanceManager() { DarkThemeCommand = new RelayCommand(o => ThemeSource = DarkThemeSource, o => !DarkThemeSource.Equals(ThemeSource)); LightThemeCommand = new RelayCommand(o => ThemeSource = LightThemeSource, o => !LightThemeSource.Equals(ThemeSource)); SetThemeCommand = new RelayCommand(o => { var uri = NavigationHelper.ToUri(o); if (uri != null) { ThemeSource = uri; } }, o => o is Uri || o is string); LargeFontSizeCommand = new RelayCommand(o => FontSize = FontSize.Large); SmallFontSizeCommand = new RelayCommand(o => FontSize = FontSize.Small); AccentColorCommand = new RelayCommand(o => { if (o is Color) { AccentColor = (Color)o; } else { // parse color from string var str = o as string; if (str != null) { AccentColor = (Color)ColorConverter.ConvertFromString(str); } } }, o => o is Color || o is string); }
/// <summary> /// Initializes a new instance of the <see cref="AppearanceManager"/> class. /// </summary> private AppearanceManager() { DarkThemeCommand = new RelayCommand(o => ThemeSource = DarkThemeSource, o => !DarkThemeSource.Equals(ThemeSource)); LightThemeCommand = new RelayCommand(o => ThemeSource = LightThemeSource, o => !LightThemeSource.Equals(ThemeSource)); SetThemeCommand = new RelayCommand(o => { if (o is Uri) { ThemeSource = (Uri)o; } else { var str = o as string; if (str != null) { Uri source; if (Uri.TryCreate(str, UriKind.RelativeOrAbsolute, out source)) { ThemeSource = source; } } } }, o => o is Uri || o is string); LargeFontSizeCommand = new RelayCommand(o => FontSize = FontSize.Large); SmallFontSizeCommand = new RelayCommand(o => FontSize = FontSize.Small); AccentColorCommand = new RelayCommand(o => { if (o is Color) { AccentColor = (Color)o; } else { // parse color from string var str = o as string; if (str != null) { AccentColor = (Color)ColorConverter.ConvertFromString(str); } } }, o => o is Color || o is string); }
public ParamsViewModel() { this.collectionViewSource = new CollectionViewSource(); this.collectionViewSource.Source = TransactionDataContext.GetInstance().DataCollection; this.collectionViewSource.Filter += collectionViewSource_Filter; this.AddNewRowCommand = new RelayCommand(arg => this.AddNewRow(arg)); }
public ChannelConnectionViewModel() { LoginCommand = new RelayCommand(param => LoginExecute(), param => CanExecuteLoginCommand); this.Username = "******"; this.Channel = "#o"; this.Server = "irc.mizure.net"; this.Port = "6667"; }
public MainViewModel() { _countdown.PropertyChanged += TriggerPropertyChange; _countdown.CompletedChanged += CompletedChangedTriggered; _sound.Open(_soundFileUri); _sound.MediaEnded += Repeat; StartCommand = new RelayCommand(StartCommandHandler, () => !IsCompleted); StopCommand = new RelayCommand(StopCommandHandler, () => !IsCompleted); GoToResetModeCommand = new RelayCommand(GoToResetModeCommandHandler); ResetCommand = new RelayCommand<TimeSpan>(ResetCommandHandler); RestartCommand = new RelayCommand(RestartCommandHandler); SwitchThemeCommand = new RelayCommand(SwitchThemeCommandHandler); CloseCommand = new RelayCommand(CloseCommandHandler); //for the sake of debugging the sound #if DEBUG _countdown.Reset(TimeSpan.FromSeconds(2)); _countdown.Start(); #endif }
public ProtocolViewModel(ProtocolRunner runner, CascadeProtocolRuntimeEnvironment environment) { _runner = runner; _environment = environment; NextStepCommand = new RelayCommand(_ => _runner.NextStep()); StartProcessCommand = new RelayCommand(_ => { _runner.Start(); _runner.NextStep(); }); _screenCapture = new ScreenCapture("images"); _runner.StepStarted += RunnerOnStepStarted; _runner.StepFinished += RunnerOnStepFinished; AliceKey = environment.AliceKey.Select(item => new KeyItemViewModel(item)).ToList(); BobKey = environment.BobKey.Select(item => new KeyItemViewModel(item)).ToList(); ErrorItems = environment.BobKey.Where((model, i) => environment.AliceKey[i].Value != model.Value) .Select(model => new KeyItemViewModel(model)) .ToList(); const int numberOfPasses = 4; AliceBlocks = new BlockSetViewModel[numberOfPasses]; for (var i = 0; i < numberOfPasses; ++i) { AliceBlocks[i] = new BlockSetViewModel { Blocks = environment.AliceBlocks[i].Select(block => new BlockViewModel(block, AliceKey)).ToList() }; } BobBlocks = new BlockSetViewModel[numberOfPasses]; for (var i = 0; i < numberOfPasses; ++i) { BobBlocks[i] = new BlockSetViewModel { Blocks = environment.BobBlocks[i].Select(block => new BlockViewModel(block, BobKey)).ToList() }; } }
public MainWindow() { InitializeComponent(); m_notifyIcon = MyNotifyIcon; m_openCommand = new RelayCommand(x => { if (WindowState == WindowState.Minimized) { WindowState = WindowState.Normal; ShowInTaskbar = true; } else if (WindowState == WindowState.Normal) { Activate(); } }, x => WindowState == WindowState.Minimized || WindowState == WindowState.Normal); m_notifyIcon.DoubleClickCommand = m_openCommand; m_notifyIcon.TrayBalloonTipClicked += TrayBalloonTipClicked; DataContext = Model = new AppModel(m_notifyIcon, TaskbarItemInfo); Loaded += OnLoaded; }
/// <summary> /// Initializes a new instance of the <see cref="ConnectViewModel"/> class. /// </summary> public ConnectViewModel() { SelectedAuthentication = Authentications[0]; SelectedEngine = Engines[0]; SelectedServer = Servers[0]; PropertyChanged += OnPropertyChanged; ConnectCommand = new RelayCommand(o => { var message = new StringBuilder(); var ok = true; // Validate inputs. if (string.IsNullOrEmpty(SelectedServer)) { ok = false; message.AppendLine("Server empty."); } if (string.IsNullOrEmpty(SelectedAuthentication)) { ok = false; message.AppendLine("Authentication empty."); } if (SelectedAuthentication == SQL_SERVER_AUTHENTICATION) { if (string.IsNullOrEmpty(Username)) { ok = false; message.AppendLine("Username empty."); } if (string.IsNullOrEmpty(Password)) { ok = false; message.AppendLine("Password empty."); } } if (!ok) { ModernDialog.ShowMessage(message.ToString(), "Error", MessageBoxButton.OK); return; } ConnStringBuilder = new SqlConnectionStringBuilder { DataSource = SelectedServer }; if (SelectedAuthentication == WINDOWS_AUTHENTICATION) { ConnStringBuilder.IntegratedSecurity = true; } else { ConnStringBuilder.UserID = Username; ConnStringBuilder.Password = Password; } // Try connecting the database. using (var conn = new SqlConnection(ConnStringBuilder.ConnectionString)) { try { conn.Open(); var routedCommand = NavigationCommands.GoToPage; routedCommand.Execute("Pages/Home.xaml", AppManagement.Current.AppMainWindow); } catch (Exception ex) { ModernDialog.ShowMessage(ex.Message, "Error", MessageBoxButton.OK); } } }); }
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 setupRelayCommands() { SelectTargetFolder = new RelayCommand((_) => selectTargetFolder()); SelectSourceFolder = new RelayCommand((_) => selectSourceFolder()); ProcessMain = new RelayCommand((_) => processMain_Async()); SaveSettings = new RelayCommand((_) => SaveUserSettings()); }
internal ProcessTemplateDefinitionsObject() { AddNewCommand = new RelayCommand(o => this.AddNew()); Storage.StorageUpdate += this.Storage_StorageUpdate; Load(); }
public SampleFormViewModel() { devise = "EUR"; calculatePrice(); Save = new RelayCommand((a) => save() , validate); AllDevise = Service.getAllDevises(); devise = AllDevise.IndexOf(devise) != -1 ? devise : AllDevise.FirstOrDefault(); Requesting = false; Panier = Service.getPanier(); Messenger.Default.Register<ActionEvent>(this, (e) => { if (e == ActionEvent.BagChanged) { calculatePrice(); RaisePropertyChanged(nameof(NbItems)); } }); }