public AboutViewModel() { CatCommand = new RelayCommand(Cat); CopyLinkCommand = new RelayCommand( (o) => Clipboard.SetText(o as string)); OpenLinkCommand = new RelayCommand( (o) => System.Diagnostics.Process.Start(o as string)); }
public MainWindowViewModel(IInteractionService message, IComicService comicManager, IPropertiesService properties) { Interaction = message; ComicManager = comicManager; Properties = properties; AddComicCommand = new RelayCommand(AddComic, (o) => !Downloading); AddRandomComicCommand = new AsyncRelayCommand(AddRandomComic); AddCurrentComicCommand = new AsyncRelayCommand(AddCurrentComic, (o) => !Downloading); RemoveComicCommand = new RelayCommand(RemoveComic, () => SelectedComic != null); ClearComicsCommand = new RelayCommand(() => Comics.Clear()); LoadedCommand = new AsyncRelayCommand(Loaded); ClosedCommand = new AsyncRelayCommand(Closed); AboutCommand = new RelayCommand(About); ConfigurationCommand = new RelayCommand(Configuration); CopyLinkCommand = new RelayCommand( (o) => Interaction.SetClipboardText(string.Format(o as string, SelectedComic.Number)), (o) => SelectedComic != null && o is string); DeleteCacheCommand = new RelayCommand( () => SelectedComic?.DeleteCache(), () => SelectedComic != null); OpenLinkCommand = new RelayCommand( (o) => Interaction.StartProcess(string.Format(o as string, SelectedComic.Number)), (o) => SelectedComic != null && o is string); PropertyChanged += (o, e) => { if (e.PropertyName == "SelectedComic") { RemoveComicCommand.RaiseCanExecuteChanged(); DeleteCacheCommand.RaiseCanExecuteChanged(); OpenLinkCommand.RaiseCanExecuteChanged(); CopyLinkCommand.RaiseCanExecuteChanged(); } if (e.PropertyName == "Downloading") { AddComicCommand.RaiseCanExecuteChanged(); AddCurrentComicCommand.RaiseCanExecuteChanged(); AddRandomComicCommand.RaiseCanExecuteChanged(); } }; }
public ConfigurationViewModel(IInteractionService message, IComicService comicManager, IPropertiesService properties) { Interaction = message; ComicManager = comicManager; Properties = properties; LoadFromProperties(); OkCommand = new RelayCommand(Ok, (o) => !Busy); CancelCommand = new RelayCommand(Cancel, (o) => !Busy); ResetCommand = new RelayCommand(Reset); ClearCacheCommand = new AsyncRelayCommand(ClearCache, (o) => !Busy); PropertyChanged += (o, e) => { if (e.PropertyName == "Busy") { OkCommand.RaiseCanExecuteChanged(); CancelCommand.RaiseCanExecuteChanged(); ClearCacheCommand.RaiseCanExecuteChanged(); } }; }