Beispiel #1
0
 public MainWindowViewModel()
 {
     CompositeDisposable.Add(_backstageViewModel  = new BackstageViewModel());
     CompositeDisposable.Add(this._inputViewModel = new InputViewModel());
     CompositeDisposable.Add(_mainAreaViewModel   = new MainAreaViewModel());
     CompositeDisposable.Add(_globalAccountSelectionFlipViewModel = new AccountSelectionFlipViewModel());
     CompositeDisposable.Add(_settingFlipViewModel          = new SettingFlipViewModel(this));
     CompositeDisposable.Add(_tabConfigurationFlipViewModel = new TabConfigurationFlipViewModel());
     CompositeDisposable.Add(_searchFlipViewModel           = new SearchFlipViewModel());
     CompositeDisposable.Add(Observable
                             .FromEvent <FocusRequest>(
                                 h => MainWindowModel.FocusRequested += h,
                                 h => MainWindowModel.FocusRequested -= h)
                             .Subscribe(SetFocus));
     CompositeDisposable.Add(Observable
                             .FromEvent <bool>(
                                 h => MainWindowModel.BackstageTransitionRequested += h,
                                 h => MainWindowModel.BackstageTransitionRequested -= h)
                             .Subscribe(this.TransitionBackstage));
     CompositeDisposable.Add(Setting.BackgroundImagePath.ListenValueChanged(
                                 _ =>
     {
         RaisePropertyChanged(() => BackgroundImageUri);
         RaisePropertyChanged(() => BackgroundImage);
     }));
     CompositeDisposable.Add(Setting.BackgroundImageTransparency.ListenValueChanged(
                                 _ => RaisePropertyChanged(() => BackgroundImageOpacity)));
     CompositeDisposable.Add(Setting.RotateWindowContent.ListenValueChanged(
                                 _ => RaisePropertyChanged(() => RotateWindowContent)));
     this._backstageViewModel.Initialize();
 }
Beispiel #2
0
 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)));
 }