private void InitCommands() { ConnectCmd = new ManualRelayCommand( async () => { try { await _clientModel.Connect(_options.Ip, int.Parse(_options.Port)); } catch (Exception e) { Trace.WriteLine(e); AddSystemMessage("Couldn't connect: " + e.Message); } }, ValidateConnectionInfo); SendCmd = new RelayCommand(SendMessage, x => !string.IsNullOrWhiteSpace(MessageTextToSend) && Connected); UserOptionsCmd = new RelayCommand(() => DialogService.Instance.ShowDialog(new UserOptionsViewModel(_options,OnUserOptionsSave))); DragAndDropCmd = new RelayCommand(o => { IDataObject ido = o as IDataObject; string[] files = (string[])ido?.GetData(DataFormats.FileDrop); if (files == null || files.Length == 0) return; _clientModel.FileTransferRequest(new FileInfo(files[0])); }, o => Connected); }
public UserOptionsViewModel(Options opts, Action execute) { Opts = opts; execute += PerformClosing; SaveCmd = new RelayCommand(execute); Title = "User Options"; }