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(); }
public UserInfoViewModel(SearchFlipViewModel parent, string screenName) { this._parent = parent; this._screenName = screenName; StoreHelper.GetUser(screenName) .Finally(() => Communicating = false) .Subscribe( user => { User = new UserViewModel(user); var ps = this._statuses; this._statuses = new UserStatusesViewModel(this); this.RaisePropertyChanged(() => Statuses); if (ps != null) { ps.Dispose(); } var pf = this._favorites; this._favorites = new UserFavoritesViewModel(this); this.RaisePropertyChanged(() => Favorites); if (pf != null) { pf.Dispose(); } var pfw = this._following; this._following = new UserFollowingViewModel(this); this.RaisePropertyChanged(() => Following); if (pfw != null) { pfw.Dispose(); } var pfr = this._followers; this._followers = new UserFollowersViewModel(this); this.RaisePropertyChanged(() => Followers); if (pfr != null) { pfr.Dispose(); } Observable.Start(() => AccountsStore.Accounts) .SelectMany(a => a) .Where(a => a.UserId != user.Id) .Select(a => new RelationControlViewModel(this, a.AuthenticateInfo, user)) .ObserveOn(DispatcherHolder.Dispatcher, DispatcherPriority.Render) .Subscribe(RelationControls.Add); }, ex => { parent.Messenger.Raise(new TaskDialogMessage(new TaskDialogOptions { Title = "ユーザー表示エラー", MainIcon = VistaTaskDialogIcon.Error, MainInstruction = "ユーザーを表示できません。", Content = ex.Message, CommonButtons = TaskDialogCommonButtons.Close })); User = null; parent.CloseResults(); }); }
public SearchResultViewModel(SearchFlipViewModel parent, SearchResultModel model) : base(model) { _parent = parent; _model = model; CompositeDisposable.Add(new EventListener <Action>( h => _model.FocusRequired += h, h => _model.FocusRequired -= h, SetFocus)); }
public UserInfoViewModel(SearchFlipViewModel parent, string screenName) { this._parent = parent; this._screenName = screenName; this.CompositeDisposable.Add( parent.ListenPropertyChanged(() => parent.DisplaySlimView, _ => RaisePropertyChanged(() => DisplaySlimView))); LoadUser(screenName); }
public UserResultViewModel(SearchFlipViewModel parent, string query) { this._parent = parent; this._query = query; LoadMore(); this.CompositeDisposable.Add(() => { foreach (var vm in _users) { vm.Dispose(); } _users.Clear(); }); }
public SearchResultViewModel(SearchFlipViewModel parent, string query, SearchOption option) { this._parent = parent; _query = query; _option = option; _timelineModel = new TimelineModel( _predicate = CreatePredicate(query, option), (id, c, _) => Fetch(id, c)); IsLoading = true; _timelineModel.ReadMore(null) .Finally(() => IsLoading = false) .Subscribe(); MainAreaViewModel.TimelineActionTargetOverride = this; }
private void SetFocus(FocusRequest req) { switch (req) { case FocusRequest.Search: SearchFlipViewModel.FocusToSearchBox(); break; case FocusRequest.Timeline: SearchFlipViewModel.Close(); var ctab = TabManager.CurrentFocusTab; if (ctab != null) { ctab.RequestFocus(); } break; case FocusRequest.Input: SearchFlipViewModel.Close(); this.InputViewModel.OpenInput(); this.InputViewModel.FocusToTextBox(); break; } }
public SearchCandidateViewModel(SearchFlipViewModel parent) { _parent = parent; }
public UserInfoViewModel(SearchFlipViewModel parent, string screenName) { this._parent = parent; this._screenName = screenName; var cd = new CompositeDisposable(); this.CompositeDisposable.Add(cd); cd.Add( StoreHelper.GetUser(screenName) .Finally(() => Communicating = false) .ObserveOnDispatcher() .Subscribe( user => { User = new UserViewModel(user); var ps = this._statuses; var usm = new UserTimelineModel(user.Id, TimelineType.User); this._statuses = new UserTimelineViewModel(this, usm); this.RaisePropertyChanged(() => Statuses); cd.Add(_statuses); if (ps != null) { ps.Dispose(); } var pf = this._favorites; var ufm = new UserTimelineModel(user.Id, TimelineType.Favorites); this._favorites = new UserTimelineViewModel(this, ufm); this.RaisePropertyChanged(() => Favorites); cd.Add(_favorites); if (pf != null) { pf.Dispose(); } var pfw = this._following; this._following = new UserFollowingViewModel(this); this.RaisePropertyChanged(() => Following); cd.Add(_following); if (pfw != null) { pfw.Dispose(); } var pfr = this._followers; this._followers = new UserFollowersViewModel(this); this.RaisePropertyChanged(() => Followers); cd.Add(_followers); if (pfr != null) { pfr.Dispose(); } Setting.Accounts.Collection .Where(a => a.Id != user.Id) .Select(a => new RelationControlViewModel(this, a, user)) .ForEach(RelationControls.Add); }, ex => { parent.Messenger.Raise(new TaskDialogMessage(new TaskDialogOptions { Title = "ユーザー表示エラー", MainIcon = VistaTaskDialogIcon.Error, MainInstruction = "ユーザーを表示できません。", Content = ex.Message, CommonButtons = TaskDialogCommonButtons.Close })); User = null; parent.CloseResults(); })); }
public UserResultViewModel(SearchFlipViewModel parent, string query) { this._parent = parent; this._query = query; LoadMore(); }
public UserInfoViewModel(SearchFlipViewModel parent, string screenName) { this._parent = parent; this._screenName = screenName; this.CompositeDisposable.Add( parent.ListenPropertyChanged(() => parent.DisplaySlimView) .Subscribe(_ => RaisePropertyChanged(() => DisplaySlimView))); this.CompositeDisposable.Add( StoreHelper.GetUser(screenName) .Finally(() => Communicating = false) .ObserveOnDispatcher() .Subscribe( user => { User = new UserViewModel(user); this.CompositeDisposable.Add(User); this.CompositeDisposable.Add(this._statuses = new UserTimelineViewModel(this, new UserTimelineModel(user.Id, TimelineType.User))); this.RaisePropertyChanged(() => Statuses); this.CompositeDisposable.Add(this._favorites = new UserTimelineViewModel(this, new UserTimelineModel(user.Id, TimelineType.Favorites))); this.RaisePropertyChanged(() => Favorites); this.CompositeDisposable.Add(this._following = new UserFollowingViewModel(this)); this.RaisePropertyChanged(() => Following); this.CompositeDisposable.Add(this._followers = new UserFollowersViewModel(this)); this.RaisePropertyChanged(() => Followers); Setting.Accounts.Collection .Where(a => a.Id != user.Id) .Select(a => new RelationControlViewModel(this, a, user)) .ForEach(RelationControls.Add); }, ex => { parent.Messenger.RaiseSafe(() => new TaskDialogMessage(new TaskDialogOptions { Title = SearchFlipResources.MsgUserInfoLoadErrorTitle, MainIcon = VistaTaskDialogIcon.Error, MainInstruction = SearchFlipResources.MsgUserInfoLoadErrorInst, Content = ex.Message, CommonButtons = TaskDialogCommonButtons.Close })); User = null; parent.CloseResults(); })); }