public InputCoreViewModel(InputViewModel parent) { this._parent = parent; this._provider = new InputAreaSuggestItemProvider(); CompositeDisposable.Add( this._bindingHashtags = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.BindingHashtags, tag => new BindHashtagViewModel(tag, () => UnbindHashtag(tag)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_bindingHashtags .ListenCollectionChanged() .Subscribe(_ => { InputData.BoundTags = _bindingHashtags.Select(h => h.Hashtag).ToArray(); RaisePropertyChanged(() => IsBindingHashtagExisted); })); _bindableHashtagCandidates = new DispatcherCollection<BindHashtagViewModel>(DispatcherHelper.UIDispatcher); CompositeDisposable.Add(_bindableHashtagCandidates .ListenCollectionChanged() .Subscribe(_ => RaisePropertyChanged(() => IsBindableHashtagExisted))); CompositeDisposable.Add(_draftedInputs = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.Drafts, _ => new InputDataViewModel(this, _, vm => InputModel.InputCore.Drafts.Remove(vm)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_draftedInputs .ListenCollectionChanged() .Subscribe(_ => { RaisePropertyChanged(() => DraftCount); RaisePropertyChanged(() => IsDraftsExisted); })); // listen setting changed CompositeDisposable.Add( Setting.SuppressTagBindingInReply.ListenValueChanged( _ => RaisePropertyChanged(() => IsBindHashtagEnabled))); // listen text control CompositeDisposable.Add(new EventListener<Action<CursorPosition>>( h => InputModel.SetCursorRequest += h, h => InputModel.SetCursorRequest -= h, SetCursor)); var plistener = new PropertyChangedEventListener(InputModel.InputCore); plistener.Add(() => InputModel.InputCore.CurrentInputData, (_, e) => InputDataChanged()); CompositeDisposable.Add(plistener); // initialize clipboard watcher. ClipboardWatcher watcher; CompositeDisposable.Add(watcher = new ClipboardWatcher()); watcher.ClipboardChanged += (o, e) => RaisePropertyChanged(() => IsClipboardContentImage); watcher.StartWatching(); Setting.DisableGeoLocationService.ValueChanged += this.UpdateGeoLocationService; this.UpdateGeoLocationService(Setting.DisableGeoLocationService.Value); }
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))); }
public InputCoreViewModel(InputViewModel parent) { this._parent = parent; this._provider = new InputAreaSuggestItemProvider(); CompositeDisposable.Add( this._bindingHashtags = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.BindingHashtags, tag => new BindHashtagViewModel(tag, () => UnbindHashtag(tag)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_bindingHashtags .ListenCollectionChanged() .Subscribe(_ => { InputData.BoundTags = _bindingHashtags.Select(h => h.Hashtag).ToArray(); RaisePropertyChanged(() => IsBindingHashtagExisted); })); _bindableHashtagCandidates = new DispatcherCollection <BindHashtagViewModel>(DispatcherHelper.UIDispatcher); CompositeDisposable.Add(_bindableHashtagCandidates .ListenCollectionChanged() .Subscribe(_ => RaisePropertyChanged(() => IsBindableHashtagExisted))); CompositeDisposable.Add(_draftedInputs = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.Drafts, _ => new InputDataViewModel(this, _, vm => InputModel.InputCore.Drafts.Remove(vm)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_draftedInputs .ListenCollectionChanged() .Subscribe(_ => { RaisePropertyChanged(() => DraftCount); RaisePropertyChanged(() => IsDraftsExisted); })); // listen setting changed CompositeDisposable.Add( Setting.SuppressTagBindingInReply.ListenValueChanged( _ => RaisePropertyChanged(() => IsBindHashtagEnabled))); // listen text control CompositeDisposable.Add(new EventListener <Action <CursorPosition> >( h => InputModel.SetCursorRequest += h, h => InputModel.SetCursorRequest -= h, SetCursor)); var plistener = new PropertyChangedEventListener(InputModel.InputCore); plistener.Add(() => InputModel.InputCore.CurrentInputData, (_, e) => InputDataChanged()); CompositeDisposable.Add(plistener); // create temporary directory and reserve deletion before exit app. do { _tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); } while (Directory.Exists(_tempDir)); Directory.CreateDirectory(_tempDir); App.ApplicationExit += () => { try { Directory.Delete(this._tempDir, true); } // ReSharper disable once EmptyGeneralCatchClause catch (Exception) { // I think that is sign from God that I must not delete that folder if failed. } }; // initialize clipboard watcher. ClipboardWatcher watcher; CompositeDisposable.Add(watcher = new ClipboardWatcher()); watcher.ClipboardChanged += (o, e) => RaisePropertyChanged(() => IsClipboardContentImage); watcher.StartWatching(); Setting.DisableGeoLocationService.ValueChanged += this.UpdateGeoLocationService; this.UpdateGeoLocationService(Setting.DisableGeoLocationService.Value); }
public InputCoreViewModel(InputViewModel parent) { this._parent = parent; this._provider = new InputAreaSuggestItemProvider(); CompositeDisposable.Add( this._bindingHashtags = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.BindingHashtags, tag => new BindHashtagViewModel(tag, () => UnbindHashtag(tag)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_bindingHashtags .ListenCollectionChanged() .Subscribe(_ => { InputData.BoundTags = _bindingHashtags.Select(h => h.Hashtag).ToArray(); RaisePropertyChanged(() => IsBindingHashtagExisted); })); _bindableHashtagCandidates = new DispatcherCollection<BindHashtagViewModel>(DispatcherHelper.UIDispatcher); CompositeDisposable.Add(_bindableHashtagCandidates .ListenCollectionChanged() .Subscribe(_ => RaisePropertyChanged(() => IsBindableHashtagExisted))); CompositeDisposable.Add(_draftedInputs = ViewModelHelperRx.CreateReadOnlyDispatcherCollectionRx( InputModel.InputCore.Drafts, _ => new InputDataViewModel(this, _, vm => InputModel.InputCore.Drafts.Remove(vm)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(_draftedInputs .ListenCollectionChanged() .Subscribe(_ => { RaisePropertyChanged(() => DraftCount); RaisePropertyChanged(() => IsDraftsExisted); })); // listen setting changed CompositeDisposable.Add( Setting.SuppressTagBindingInReply.ListenValueChanged( _ => RaisePropertyChanged(() => IsBindHashtagEnabled))); // listen text control CompositeDisposable.Add(new EventListener<Action<CursorPosition>>( h => InputModel.SetCursorRequest += h, h => InputModel.SetCursorRequest -= h, SetCursor)); var plistener = new PropertyChangedEventListener(InputModel.InputCore); plistener.Add(() => InputModel.InputCore.CurrentInputData, (_, e) => InputDataChanged()); CompositeDisposable.Add(plistener); // create temporary directory and reserve deletion before exit app. do { _tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); } while (Directory.Exists(_tempDir)); Directory.CreateDirectory(_tempDir); App.ApplicationExit += () => { try { Directory.Delete(this._tempDir, true); } // ReSharper disable once EmptyGeneralCatchClause catch (Exception) { // I think that is sign from God that I must not delete that folder if failed. } }; // initialize clipboard watcher. ClipboardWatcher watcher; CompositeDisposable.Add(watcher = new ClipboardWatcher()); watcher.ClipboardChanged += (o, e) => RaisePropertyChanged(() => IsClipboardContentImage); watcher.StartWatching(); Setting.DisableGeoLocationService.ValueChanged += this.UpdateGeoLocationService; this.UpdateGeoLocationService(Setting.DisableGeoLocationService.Value); }
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))); this._backstageViewModel.Initialize(); }