コード例 #1
0
 public AccountSelectorViewModel()
 {
     this.CompositeDisposable.Add(_accounts = ViewModelHelper.CreateReadOnlyDispatcherCollection(
         AccountsStore.Accounts,
         _ => new SelectableAccountViewModel(this, _.AuthenticateInfo, RaiseSelectedAccountsChanged),
         DispatcherHelper.UIDispatcher));
 }
コード例 #2
0
 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));
 }
コード例 #3
0
        public RelocatingSquadronsWindowViewModel(LandBase landBase)
        {
            this.Title = "配置転換中の航空機一覧";

            this.RelocatingSquadrons = ViewModelHelper.CreateReadOnlyDispatcherCollection(
                landBase.RelocatingSquadrons,
                x => new RelocatingSquadronViewModel(x),
                DispatcherHelper.UIDispatcher);
        }
コード例 #4
0
ファイル: StreamViewModel.cs プロジェクト: namoshika/Metrooz
 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();
 }
コード例 #5
0
        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);
        }
コード例 #6
0
		public TagTreeItem()
		{
			this._childrenro = ViewModelHelper.CreateReadOnlyDispatcherCollection<ServerTagTestData, TagTreeItem>(
				_children,
				prop => new TagTreeItem
				{
					Name = prop.Name,
					HasChildServer = prop.IsChild,
					_TagId = prop.Id
				},
				DispatcherHelper.UIDispatcher);
		}
コード例 #7
0
 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);
 }
コード例 #8
0
 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));
 }
コード例 #9
0
 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") });
 }
コード例 #10
0
ファイル: ColumnViewModel.cs プロジェクト: Aeri912/StarryEyes
 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];
     }
 }
コード例 #11
0
ファイル: MainViewModel.cs プロジェクト: namoshika/Metrooz
 /// <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));
     }
 }
コード例 #12
0
 /// <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);
         }
     });
 }
コード例 #13
0
 public LauncherCoreViewModel() : base(new LauncherCore())
 {
     Apps = ViewModelHelper.CreateReadOnlyDispatcherCollection(Model.Apps, (ai) => new AppInfoViewModel(ai), DispatcherHelper.UIDispatcher);
     CompositeDisposable.Add(() => Apps.Dispose());
 }
コード例 #14
0
        /// <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();
        }
コード例 #15
0
ファイル: HomeViewModel.cs プロジェクト: finalstream/Movselex
        /// <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);
        }