public AccountSelectorViewModel() { this.CompositeDisposable.Add(_accounts = ViewModelHelper.CreateReadOnlyDispatcherCollection( AccountsStore.Accounts, _ => new SelectableAccountViewModel(this, _.AuthenticateInfo, RaiseSelectedAccountsChanged), DispatcherHelper.UIDispatcher)); }
public StreamManagerViewModel() { _selectedIndex = 0; _streams = new ReadOnlyDispatcherCollection<StreamViewModel>( new DispatcherCollection<StreamViewModel>( new ObservableCollection<StreamViewModel>( Enumerable.Range(0, 3).Select(idx => new StreamViewModel())), App.Current.Dispatcher)); }
public RelocatingSquadronsWindowViewModel(LandBase landBase) { this.Title = "配置転換中の航空機一覧"; this.RelocatingSquadrons = ViewModelHelper.CreateReadOnlyDispatcherCollection( landBase.RelocatingSquadrons, x => new RelocatingSquadronViewModel(x), DispatcherHelper.UIDispatcher); }
public StreamViewModel() { _name = "StreamName"; _status = StreamStateType.UnLoaded; CompositeDisposable.Add((IDisposable)(Items = new ReadOnlyDispatcherCollection<ViewModel>( new DispatcherCollection<ViewModel>( new ObservableCollection<ViewModel>( Enumerable.Range(0, 3).Select(idx => new ActivityViewModel())), App.Current.Dispatcher)))); ResumeButton = new ResumeButtonViewModel(); }
public StreamManagerViewModel(Account account) { _selectedIndex = -1; _accountModel = account; _streamManagerModel = account.Stream; _streams = ViewModelHelper.CreateReadOnlyDispatcherCollection( _streamManagerModel.Streams, item => new StreamViewModel(item), App.Current.Dispatcher); CompositeDisposable.Add(_thisPropChangedEventListener = new PropertyChangedEventListener(this)); _thisPropChangedEventListener.Add(() => IsActive, IsActive_PropertyChanged); }
public TagTreeItem() { this._childrenro = ViewModelHelper.CreateReadOnlyDispatcherCollection<ServerTagTestData, TagTreeItem>( _children, prop => new TagTreeItem { Name = prop.Name, HasChildServer = prop.IsChild, _TagId = prop.Id }, DispatcherHelper.UIDispatcher); }
public CategoryTreeItem() { _childrenro = ViewModelHelper.CreateReadOnlyDispatcherCollection <ServerCategoryTestData, CategoryTreeItem>( _children, prop => new CategoryTreeItem { _CategoryId = prop.Id, Name = prop.Name, HasChildServer = prop.IsChild.HasValue ? prop.IsChild.Value : false }, DispatcherHelper.UIDispatcher); }
public MainAreaViewModel() { CompositeDisposable.Add( _columns = ViewModelHelper.CreateReadOnlyDispatcherCollection( MainAreaModel.Columns, cm => new ColumnViewModel(this, cm), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add( Observable.FromEvent( h => MainAreaModel.OnCurrentFocusColumnChanged += h, h => MainAreaModel.OnCurrentFocusColumnChanged -= h) .Select(_ => MainAreaModel.CurrentFocusColumnIndex) .Subscribe(UpdateFocusFromModel)); }
public ActivityViewModel() { ActorIcon = SampleData.DataLoader.LoadImage("accountIcon00.png").Result; ActivityUrl = new Uri("https://plus.google.com"); IsEnableCommentsHeader = true; IsCheckedCommentsHeader = false; IsOpenedCommentList = false; IsLoadingCommentList = true; CommentLength = 5; PostUserName = "******"; PostDate = "00:00"; _comments = new ReadOnlyDispatcherCollection<CommentViewModel>( new DispatcherCollection<CommentViewModel>( new ObservableCollection<CommentViewModel>( Enumerable.Range(0, 2).Select(_ => new CommentViewModel())), App.Current.Dispatcher)); PostContentInline = new StyleElement(StyleType.None, new[] { new TextElement("Activity Content Text") }); }
public ColumnViewModel(MainAreaViewModel parent, ColumnModel model) { _parent = parent; _model = model; this.CompositeDisposable.Add( _tabs = ViewModelHelper.CreateReadOnlyDispatcherCollection( model.Tabs, _ => new TabViewModel(this, _), DispatcherHelper.UIDispatcher)); this.CompositeDisposable.Add( Observable.FromEvent( h => _model.OnCurrentFocusColumnChanged += h, h => _model.OnCurrentFocusColumnChanged -= h) .Select(_ => _model.CurrentFocusTabIndex) .Subscribe(UpdateFocusFromModel)); if (_tabs.Count > 0) { Focused = _tabs[0]; } }
/// <summary> /// Initializes a new instance of the MainViewModel class. /// </summary> public MainViewModel() { if (ViewModelUtility.IsDesginMode) { _selectedAccountIndex = 0; _isAccountSelectorMode = true; _noSelectableAccount = false; Accounts = new ReadOnlyDispatcherCollection<AccountViewModel>( new DispatcherCollection<AccountViewModel>( new ObservableCollection<AccountViewModel>( Enumerable.Range(0, 2).Select(idx => new AccountViewModel())), App.Current.Dispatcher)); } else { _selectedAccountIndex = int.MinValue; _isAccountSelectorMode = false; _noSelectableAccount = false; _accountManagerModel = AccountManager.Current; CompositeDisposable.Add(Accounts = ViewModelHelper.CreateReadOnlyDispatcherCollection( _accountManagerModel.Accounts, model => new AccountViewModel(model, this), App.Current.Dispatcher)); } }
/// <summary> /// for design-time support. /// </summary> public BackpanelViewModel() { _events = ViewModelHelper.CreateReadOnlyDispatcherCollection( BackpanelModel.TwitterEvents, tev => new TwitterEventViewModel(tev), DispatcherHelper.UIDispatcher); CompositeDisposable.Add(new EventListener<Action<BackpanelEventBase>>( _ => BackpanelModel.OnEventRegistered += _, _ => BackpanelModel.OnEventRegistered -= _, ev => { lock (_syncLock) { _waitingEvents.Enqueue(ev); Monitor.Pulse(_syncLock); } })); CompositeDisposable.Add(() => { lock (_syncLock) { _isDisposed = true; Monitor.Pulse(_syncLock); } }); }
public LauncherCoreViewModel() : base(new LauncherCore()) { Apps = ViewModelHelper.CreateReadOnlyDispatcherCollection(Model.Apps, (ai) => new AppInfoViewModel(ai), DispatcherHelper.UIDispatcher); CompositeDisposable.Add(() => Apps.Dispose()); }
/// <summary> /// Constructor /// </summary> public InputAreaViewModel() { _accountSelector = new AccountSelectorViewModel(); _accountSelector.OnClosed += () => { // After selection accounts, return focus to text box // if input area is opened. if (IsOpening) { FocusToTextBox(); } }; CompositeDisposable.Add(_bindingHashtags = ViewModelHelper.CreateReadOnlyDispatcherCollection( InputAreaModel.BindingHashtags, _ => new BindHashtagViewModel(_, () => UnbindHashtag(_)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(new CollectionChangedEventListener( _bindingHashtags, (_, __) => RaisePropertyChanged(() => IsBindingHashtagExisted))); _bindableHashtagCandidates = new DispatcherCollection<BindHashtagViewModel>(DispatcherHelper.UIDispatcher); CompositeDisposable.Add(new CollectionChangedEventListener( _bindableHashtagCandidates, (_, __) => RaisePropertyChanged(() => IsBindableHashtagExisted))); CompositeDisposable.Add(_draftedInputs = ViewModelHelper.CreateReadOnlyDispatcherCollection( InputAreaModel.Drafts, _ => new TweetInputInfoViewModel(this, _, vm => InputAreaModel.Drafts.Remove(vm)), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(new CollectionChangedEventListener(_draftedInputs, (o, ev) => { RaisePropertyChanged(() => DraftCount); RaisePropertyChanged(() => IsDraftsExisted); })); CompositeDisposable.Add(_bindingAuthInfos = ViewModelHelper.CreateReadOnlyDispatcherCollection( InputAreaModel.BindingAuthInfos, _ => new AuthenticateInfoViewModel(_), DispatcherHelper.UIDispatcher)); CompositeDisposable.Add(new CollectionChangedEventListener( _bindingAuthInfos, (_, __) => RaisePropertyChanged(() => IsBindingAuthInfoExisted))); bool accountSelectReflecting = false; _accountSelector.OnSelectedAccountsChanged += () => { if (!_isSuppressAccountChangeRelay) { // write-back accountSelectReflecting = true; InputAreaModel.BindingAuthInfos.Clear(); _accountSelector.SelectedAccounts .ForEach(InputAreaModel.BindingAuthInfos.Add); accountSelectReflecting = false; _baseSelectedAccounts = InputAreaModel.BindingAuthInfos.Select(_ => _.Id).ToArray(); } InputInfo.AuthInfos = AccountSelector.SelectedAccounts; RaisePropertyChanged(() => AuthInfoGridRowColumn); UpdateTextCount(); RaisePropertyChanged(() => IsPostLimitPredictionEnabled); }; CompositeDisposable.Add(_accountSelector); CompositeDisposable.Add( new CollectionChangedEventListener( InputAreaModel.BindingAuthInfos, (_, __) => { RaisePropertyChanged(() => IsPostLimitPredictionEnabled); if (accountSelectReflecting) return; _baseSelectedAccounts = InputAreaModel.BindingAuthInfos .Select(a => a.Id) .ToArray(); ApplyBaseSelectedAccounts(); UpdateTextCount(); })); CompositeDisposable.Add( new EventListener<Action<IEnumerable<AuthenticateInfo>, string, CursorPosition, TwitterStatus>>( _ => InputAreaModel.OnSetTextRequested += _, _ => InputAreaModel.OnSetTextRequested -= _, (infos, body, cursor, inReplyTo) => { OpenInput(false); if (!CheckClearInput(body)) return; if (infos != null) { OverrideSelectedAccounts(infos); } InReplyTo = new StatusViewModel(inReplyTo); switch (cursor) { case CursorPosition.Begin: Messenger.RaiseAsync(new TextBoxSetCaretMessage(0)); break; case CursorPosition.End: Messenger.RaiseAsync(new TextBoxSetCaretMessage(InputText.Length)); break; } })); CompositeDisposable.Add( new EventListener<Action<IEnumerable<AuthenticateInfo>, TwitterUser>>( _ => InputAreaModel.OnSendDirectMessageRequested += _, _ => InputAreaModel.OnSendDirectMessageRequested -= _, (infos, user) => { OpenInput(false); CheckClearInput(); OverrideSelectedAccounts(infos); DirectMessageTo = new UserViewModel(user); })); _geoWatcher = new GeoCoordinateWatcher(GeoPositionAccuracy.Default); _geoWatcher.StatusChanged += (_, e) => { if (e.Status != GeoPositionStatus.Ready) { IsLocationEnabled = true; } else { IsLocationEnabled = false; AttachedLocation = null; } }; CompositeDisposable.Add(_geoWatcher); _geoWatcher.Start(); }
/// <summary> /// VM用のコレクションを生成します。 /// </summary> private void CreateReadOnlyDispatcherCollection() { _databases = ViewModelHelper.CreateReadOnlyDispatcherCollection(_client.Databases, s => new DatabaseViewModel(s), DispatcherHelper.UIDispatcher); _filterings = ViewModelHelper.CreateReadOnlyDispatcherCollection(_client.Filterings, m => new FilteringViewModel(m), DispatcherHelper.UIDispatcher); _groups = ViewModelHelper.CreateReadOnlyDispatcherCollection(_client.Groups, m => new GroupViewModel(m), DispatcherHelper.UIDispatcher); _libraries = ViewModelHelper.CreateReadOnlyDispatcherCollection(_client.Libraries, m => new LibraryViewModel(m), DispatcherHelper.UIDispatcher); _playings = ViewModelHelper.CreateReadOnlyDispatcherCollection(_client.Playings, m => new PlayingViewModel(m), DispatcherHelper.UIDispatcher); }