public void Send() { if (!CanSend) { // could not send. RaisePropertyChanged(() => CanSend); _parent.FocusToTextBox(); return; } if (!CheckInput()) { return; } SendCore(InputData); ClearInput(); _parent.FocusToTextBox(); }
public AccountSelectorViewModel(InputViewModel parent) { _parent = parent; this._accountSelectionFlip = new AccountSelectionFlipViewModel(); this.AccountSelectionFlip.Closed += () => { // After selection accounts, return focus to text box // if input area is opened. if (_parent.IsOpening) { _parent.FocusToTextBox(); } }; this.AccountSelectionFlip.SelectedAccountsChanged += () => { InputModel.AccountSelector.Accounts.Clear(); Setting.Accounts.Collection .Where(a => AccountSelectionFlip.SelectedAccounts.Contains(a)) .ForEach(InputModel.AccountSelector.Accounts.Add); }; CompositeDisposable.Add(this.AccountSelectionFlip); CompositeDisposable.Add( ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.AccountSelector.Accounts, a => new TwitterAccountViewModel(a), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add( InputModel.AccountSelector.Accounts.ListenCollectionChanged() .Subscribe(_ => { RaisePropertyChanged(() => AuthInfoGridRowColumn); this.RaisePropertyChanged(() => AuthInfoScreenNames); })); CompositeDisposable.Add(this._accounts = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.AccountSelector.Accounts, account => new TwitterAccountViewModel(account), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(this._accounts .ListenCollectionChanged() .Subscribe(_ => { this.RaisePropertyChanged(() => AuthInfoGridRowColumn); RaisePropertyChanged(() => IsBindingAuthInfoExisted); })); CompositeDisposable.Add( InputModel.AccountSelector.ListenPropertyChanged( () => InputModel.AccountSelector.IsSynchronizedWithTab) .Subscribe(_ => RaisePropertyChanged(() => IsSynchronizedWithTab))); }