private void BuildContextMenuCommands() { SelectedStartCommand = new AwaitableRelayCommand( async() => await StartListenersAsync(GetHighlightedListenerAsList()), () => HighlightedListener != null ); SelectedStopCommand = new AwaitableRelayCommand( async() => await AskStopListenersAsync(GetHighlightedListenerAsList()), () => HighlightedListener != null ); }
public TerminalViewModel(MainWindowViewModel parent, string content_id, string title, string tooltip, string image_name) : base(parent, content_id, title, tooltip, image_name) { this.Document = new TextDocument(); this.PortNames = new ObservableCollection <string>(); this.RefreshPortNamesCommand = new RelayCommand(RefreshPortNamesExecute, RefreshPortNamesCanExecute); this.ConnectCommand = new RelayCommand(ConnectExecute, ConnectCanExecute); this.SendCommand = new RelayCommand(SendExecute, SendCanExecute); this.ClearAllCommand = new RelayCommand(ClearAllExecute); this.SoftResetCommand = new RelayCommand(SoftResetExecute, SoftResetCanExecute); this.HardResetCommand = new RelayCommand(HardResetExecute, HardResetCanExecute); this.ChipIdCommand = new RelayCommand(ChipIdExecute, ChipIdCanExecute); this.HeapCommand = new RelayCommand(HeapExecute, HeapCanExecute); this.InfoCommand = new AwaitableRelayCommand(InfoExecute, InfoCanExecute); // Refresh port names RefreshPortNamesExecute(); if (this.PortNames.Count > 0) { if (this.PortNames.Contains(Settings.Default.PortName)) { this.PortName = Settings.Default.PortName; } else { this.PortName = this.PortNames[0]; } } // Refresh baud rates this.BaudRates = new int[] { 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200, 230400 }; this.BaudRate = Settings.Default.BaudRate; // Timeout this.Timeout = Settings.Default.Timeout; // Send command history this.SendHistoryLength = Settings.Default.SendHistoryLength; this.SendHistory = new ObservableCollection <string>(); if (Settings.Default.SendHistory != null) { this.SendHistory.AddRange(Settings.Default.SendHistory.Cast <string>()); } // Image of connect button this.ConnectImageSource = WindowUtils.GetImage("Image_Connect"); this.IsDisconnected = true; }
private void BuildCommands() { ReloadCommand = new AwaitableRelayCommand( async() => { await InitializeCoreAsync(); }, () => Initialized); RefreshInfosCommand = new AwaitableRelayCommand( async() => { await RefreshListenersInfoAsync(false); }, () => Initialized); ApplyFilterCommand = new AwaitableRelayCommand( async() => { await UpdateFilterResultAsync(); }, () => Initialized); SelectAllCommand = CreateCommand( () => { foreach (ListenerInfo o in ListenersFilterView) { o.Selected = true; } }, () => Initialized); SelectNoneCommand = CreateCommand( () => { foreach (ListenerInfo o in ListenersFilterView) { o.Selected = false; } }, () => Initialized); InvertSelectionCommand = CreateCommand( () => { foreach (ListenerInfo o in ListenersFilterView) { o.Selected = !o.Selected; } }, () => Initialized); BuildContextMenuCommands(); }
public SpiffsViewModel(MainWindowViewModel parent, string content_id, string title, string tooltip, string image_name) : base(parent, content_id, title, tooltip, image_name) { // Register to PropertyChanged event of TerminalViewModel this.Terminal = parent.Terminal; this.Terminal.PropertyChanged += Terminal_PropertyChanged; this.Files = new ObservableCollection <FileViewModel>(); this.RefreshCommand = new AwaitableRelayCommand(RefreshExecute, RefreshCanExecute); this.FormatCommand = new AwaitableRelayCommand(FormatExecute, FormatCanExecute); this.OpenFileCommand = new AwaitableRelayCommand(OpenFileExecute, OpenFileCanExecute); this.DownloadFileToDiskCommand = new AwaitableRelayCommand(DownloadFileToDiskExecute, DownloadFileToDiskCanExecute); this.UploadFileFromDiskCommand = new AwaitableRelayCommand(UploadFileFromDiskExecute, UploadFileFromDiskCanExecute); this.PrintFileCommand = new RelayCommand(PrintFileExecute, PrintFileCanExecute); this.ExecuteFileCommand = new RelayCommand(ExecuteFileExecute, ExecuteFileCanExecute); this.CompileFileCommand = new AwaitableRelayCommand(CompileFileExecute, CompileFileCanExecute); this.RenameFileCommand = new AwaitableRelayCommand(RenameFileExecute, RenameFileCanExecute); this.DeleteFileCommand = new AwaitableRelayCommand(DeleteFileExecute, DeleteFileCanExecute); }
private void BuildContextMenuCommands() { SelectedStartCommand = new AwaitableRelayCommand( async() => await StartChannelsAsync(GetHighlightedChannelAsList()), () => HighlightedChannel != null ); SelectedStopCommand = new AwaitableRelayCommand( async() => await AskStopChannels(GetHighlightedChannelAsList()), () => HighlightedChannel != null ); SelectedResetCommand = new AwaitableRelayCommand( async() => await AskResetChannels(GetHighlightedChannelAsList()), () => HighlightedChannel != null ); SelectedResolveCommand = new AwaitableRelayCommand( async() => await AskResolveChannels(GetHighlightedChannelAsList()), () => HighlightedChannel != null ); }
private void BuildContextMenuCommands() { SelectedBrowseCommand = new AwaitableRelayCommand( async() => await BrowseQueuesAsync(GetHighlightedQueueAsList()), () => HighlightedQueue?.GetStatus != null ); SelectedGetAllowCommand = new AwaitableRelayCommand( async() => await SetGetStatusAsync(GetPutStatus.Allowed, GetHighlightedQueueAsList()), () => HighlightedQueue?.GetStatus != null && HighlightedQueue.GetStatus == GetPutStatus.Inhibited ); SelectedGetInhibitCommand = new AwaitableRelayCommand( async() => await SetGetStatusAsync(GetPutStatus.Inhibited, GetHighlightedQueueAsList()), () => HighlightedQueue?.GetStatus != null && HighlightedQueue.GetStatus == GetPutStatus.Allowed ); SelectedPutAllowCommand = new AwaitableRelayCommand( async() => await SetPutStatusAsync(GetPutStatus.Allowed, GetHighlightedQueueAsList()), () => HighlightedQueue?.PutStatus != null && HighlightedQueue.PutStatus == GetPutStatus.Inhibited ); SelectedPutInhibitCommand = new AwaitableRelayCommand( async() => await SetPutStatusAsync(GetPutStatus.Inhibited, GetHighlightedQueueAsList()), () => HighlightedQueue?.PutStatus != null && HighlightedQueue.PutStatus == GetPutStatus.Allowed ); SelectedClearWithDeleteCommand = new AwaitableRelayCommand( async() => await EmptyQueuesAsync(false, GetHighlightedQueueAsList()), () => HighlightedQueue?.GetStatus != null ); SelectedClearWithTruncateCommand = new AwaitableRelayCommand( async() => await EmptyQueuesAsync(true, GetHighlightedQueueAsList()), () => HighlightedQueue != null && HighlightedQueue.SupportTruncate && HighlightedQueue.GetStatus.HasValue ); SelectedPutMessageCommand = CreateCommand( PutMessageInQueue, () => HighlightedQueue?.PutStatus != null ); }
private void BuildCommands() { RefreshCommand = new AwaitableRelayCommand( async() => await RefreshAsync(false), () => Initialized && !HasErrors && LocalIdle); RefreshContinueCommand = new AwaitableRelayCommand( async() => await RefreshAsync(true), () => Initialized && !HasErrors && Messages.Count > 0 && LocalIdle); SearchCommand = new AwaitableRelayCommand( async() => await SearchAsync(), () => Initialized && !HasErrors && Messages.Count > 0 && LocalIdle); SelectAllCommand = CreateCommand( () => { foreach (var m in Messages) { m.Selected = true; } }, () => Initialized); SelectNoneCommand = CreateCommand( () => { foreach (var m in Messages) { m.Selected = false; } }, () => Initialized); InvertSelectionCommand = CreateCommand( () => { foreach (var m in Messages) { m.Selected = !m.Selected; } }, () => Initialized); DeleteCommand = new AwaitableRelayCommand( async() => await DeleteMessagesAsync(GetSelectedMessages()) , () => Initialized && Messages.SelectedCount > 0 ); TruncateCommand = new AwaitableRelayCommand( async() => await EmptyQueueAsync(true) , () => Initialized && Queue != null && Queue.SupportTruncate && Messages.TotalCount > 0); EmptyCommand = new AwaitableRelayCommand( () => EmptyQueueAsync(false) , () => Initialized && Messages.TotalCount > 0); ForwardCommand = new AwaitableRelayCommand( async() => await ForwardMessagesAsync(GetSelectedMessages()) , () => Initialized && Messages.SelectedCount > 0); ExportCommand = new AwaitableRelayCommand( () => AskExportMessagesAsync() , () => Initialized && Messages.SelectedCount > 0); SetGetAllowCommand = CreateCommand( () => Queue.SetGetStatus(GetPutStatus.Allowed), () => Initialized && Queue != null && Queue.GetStatus == GetPutStatus.Inhibited); SetGetInhibitCommand = CreateCommand( () => Queue.SetGetStatus(GetPutStatus.Inhibited), () => Initialized && Queue != null && Queue.GetStatus == GetPutStatus.Allowed); SetPutAllowCommand = CreateCommand( () => Queue.SetPutStatus(GetPutStatus.Allowed), () => Initialized && Queue != null && Queue.PutStatus == GetPutStatus.Inhibited); SetPutInhibitCommand = CreateCommand( () => Queue.SetPutStatus(GetPutStatus.Inhibited), () => Initialized && Queue != null && Queue.PutStatus == GetPutStatus.Allowed); CopyRawDataToClipboardCommand = CreateCommand( () => CopyRawDataToClipboard(CurrentMessage.Text), () => CurrentMessage != null); PutMessageCommand = CreateCommand( OpenPutMessageView, () => Initialized && Queue?.PutStatus != null && Queue.PutStatus.Value == GetPutStatus.Allowed); UnloadQueueCommand = new AwaitableRelayCommand( async() => await AskDumpQueueAsync(), () => Initialized && Queue?.GetStatus != null); LoadQueueCommand = new AwaitableRelayCommand( async() => await AskLoadDumpAsync(), () => Initialized && Queue?.PutStatus != null); LoadParserConfigurationCommand = new AwaitableRelayCommand( async() => await LoadParserConfigurationAsync() , () => Initialized); }
private void BuildCommands() { ReloadCommand = CreateCommand( async() => { await InitializeCoreAsync(); }, () => Initialized && !(ObjectProvider.Filter is StaticQueueList)); RefreshInfosCommand = new AwaitableRelayCommand( async() => { await RefreshQueuesInfoAsync(false); }, () => Initialized); ApplyFilterCommand = new AwaitableRelayCommand( async() => { await UpdateFilterResultAsync(); }, () => Initialized); SetGetAllowCommand = new AwaitableRelayCommand( async() => { await SetGetStatusAsync(GetPutStatus.Allowed, Queues.SelectedItems()); }, () => QueuesSupportGet(false, false, Queues.SelectedItems())); SetGetInhibitCommand = new AwaitableRelayCommand( async() => { await SetGetStatusAsync(GetPutStatus.Inhibited, Queues.SelectedItems()); }, () => QueuesSupportGet(false, false, Queues.SelectedItems())); SetPutAllowCommand = new AwaitableRelayCommand( async() => { await SetPutStatusAsync(GetPutStatus.Allowed, Queues.SelectedItems()); }, () => QueuesSupportPut(false, false, Queues.SelectedItems())); SetPutInhibitCommand = new AwaitableRelayCommand( async() => { await SetPutStatusAsync(GetPutStatus.Inhibited, Queues.SelectedItems()); }, () => QueuesSupportPut(false, false, Queues.SelectedItems())); EmptyWithDeleteCommand = new AwaitableRelayCommand( async() => { await EmptyQueuesAsync(false, Queues.SelectedItems()); }, () => QueuesSupportGet(false, true, Queues.SelectedItems())); EmptyWithTruncateCommand = new AwaitableRelayCommand( async() => { await EmptyQueuesAsync(true, Queues.SelectedItems()); }, () => QueuesSupportTruncate(false, Queues.SelectedItems())); BrowseCommand = new AwaitableRelayCommand( async() => { await BrowseQueuesAsync(Queues.SelectedItems()); }, () => QueuesSupportGet(true, false, Queues.SelectedItems())); SelectAllCommand = CreateCommand( () => { foreach (QueueInfo q in QueuesFilterView) { q.Selected = true; } }, () => Initialized); SelectNoneCommand = CreateCommand( () => { foreach (QueueInfo q in QueuesFilterView) { q.Selected = false; } }, () => Initialized); InvertSelectionCommand = CreateCommand( () => { foreach (QueueInfo q in QueuesFilterView) { q.Selected = !q.Selected; } }, () => Initialized); BuildContextMenuCommands(); }