コード例 #1
0
 public RpNames()
 {
     //姓と名の変更を購読して、フルネームにする
     NameRorps = Observable
                 .CombineLatest(NameRp, NameRps, (x, y) => $"{x}={y}")
                 .ToReadOnlyReactivePropertySlim();
 }
コード例 #2
0
 public TimerModel()
 {
     _timer = new ReactiveTimer(TimeSpan.FromSeconds(1));
     CurrentDateTimeOffset = _timer.Select(_ => DateTimeOffset.Now)
                             .ToReadOnlyReactivePropertySlim();
     _timer.Start();
 }
コード例 #3
0
 public StringLengthCounterModel()
 {
     this.Text2 =
         Text1
         .Select(x => string.IsNullOrEmpty(x) ? "0文字" : x.Length + "文字")
         .ToReadOnlyReactivePropertySlim();
 }
コード例 #4
0
        /// <summary>Viewを表示した後呼び出されます。</summary>
        /// <param name="navigationContext">Navigation Requestの情報を表すNavigationContext。</param>
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            if (this.physical != null)
            {
                return;
            }
            this.physical = this.getPhysicalData(navigationContext);

            var mode = ReactivePropertyMode.Default | ReactivePropertyMode.IgnoreInitialValidationError;

            // 測定日
            this.MeasurementDate = this.physical
                                   .ToReactivePropertyAsSynchronized(x => x.MeasurementDate, mode, true)
                                   .SetValidateNotifyError(v => this.getMeasurementDateError(v))
                                   .AddTo(this.disposables);
            // 身長
            this.Height = this.physical
                          .ToReactivePropertyAsSynchronized(x => x.Height, ignoreValidationErrorValue: true)
                          .SetValidateAttribute(() => this.Height)
                          .AddTo(this.disposables);
            // 体重
            this.Weight = this.physical
                          .ToReactivePropertyAsSynchronized(x => x.Weight, ignoreValidationErrorValue: true)
                          .SetValidateAttribute(() => this.Weight)
                          .AddTo(this.disposables);
            // BMI
            this.Bmi = this.physical.ObserveProperty(x => x.Bmi)
                       .ToReadOnlyReactivePropertySlim()
                       .AddTo(this.disposables);

            // View へ反映
            this.RaisePropertyChanged(null);
        }
コード例 #5
0
ファイル: Item.cs プロジェクト: YatsuhaSawada/UmaTool
 public ItemViewModel(Item item)
 {
     Name = item
            .Name
            .ObserveOnUIDispatcher()
            .ToReadOnlyReactivePropertySlim().AddTo(Disposable);
 }
コード例 #6
0
        public GoogleLoginService(IAccountService accountService, IAuthService authService)
        {
            _accountService = accountService;
            _authService    = authService;

            IsLoggingIn = _loggingInNotifier.ToReadOnlyReactivePropertySlim();
        }
コード例 #7
0
 public ReactivePropertyViewModelBase()
 {
     // 全エラーリスト
     AllErrors = this.ForValidation().SetupReactiveProperties()
                 .GetAllErrorsObservable()
                 .ToReadOnlyReactivePropertySlim().AddTo(Disposer);
 }
コード例 #8
0
        public MainWindowModel(
            ISelectExecuteFileService selectExecuteFileService,
            IShortcutService shortcutService,
            IDialogService dialogService,
            IOpenExolorerService openExolorerService)
        {
            _selectExecuteFileService = selectExecuteFileService;
            _shortcutService          = shortcutService;
            _dialogService            = dialogService;
            _openExolorerService      = openExolorerService;

            _wathcer = new FileSystemWatcher(StartupPath, "*.*")
            {
                EnableRaisingEvents = true
            };
            StartupShortcuts = new[]
            {
                _wathcer.CreatedAsObservable(),
                    _wathcer.ChangedAsObservable(),
                    _wathcer.DeletedAsObservable(),
                    _wathcer.RenamedAsObservable()
            }
            .Merge()
            .Select(_ => GetStartupShorcuts())
            .ToReadOnlyReactivePropertySlim(GetStartupShorcuts());
        }
コード例 #9
0
        public FileListViewModelFiles(FileEntity fileEntity)
        {
            FileDetail
                = new ReactivePropertySlim <FileEntity>(fileEntity)
                  .ToReadOnlyReactivePropertySlim()
                  .AddTo(disposables);

            LogicalFileName = FileDetail.Value.LogicalFileName
                              .ToReadOnlyReactivePropertySlim <string>()
                              .AddTo(disposables);

            PhysicalFileName
                = new ReactivePropertySlim <string>(fileEntity.PhysicalFileName.Value.DisplayValue)
                  .ToReadOnlyReactivePropertySlim()
                  .AddTo(disposables);

            FileSize
                = new ReactivePropertySlim <string>(fileEntity.FileSize.Value.DisplayValueWithUnit)
                  .ToReadOnlyReactivePropertySlim()
                  .AddTo(disposables);

            Comment
                = new ReactivePropertySlim <string>(fileEntity.Comment.Value.DisplayValueWithoutNewline)
                  .ToReadOnlyReactivePropertySlim <string>()
                  .AddTo(disposables);
        }
コード例 #10
0
        /// <summary>Viewを表示した後呼び出されます。</summary>
        /// <param name="navigationContext">Navigation Requestの情報を表すNavigationContext。</param>
        void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
        {
            if (this.testPoint != null)
            {
                return;
            }
            this.testPoint = navigationContext.Parameters["TargetData"] as TestPointInformation;

            this.TestDate = this.testPoint
                            .ToReactivePropertyAsSynchronized(x => x.TestDate)
                            .AddTo(this.disposables);
            this.JapaneseScore = this.testPoint
                                 .ToReactivePropertyAsSynchronized(x => x.JapaneseScore)
                                 .AddTo(this.disposables);
            this.MathematicsScore = this.testPoint
                                    .ToReactivePropertyAsSynchronized(x => x.MathematicsScore)
                                    .AddTo(this.disposables);
            this.EnglishScore = this.testPoint
                                .ToReactivePropertyAsSynchronized(x => x.EnglishScore)
                                .AddTo(this.disposables);
            this.Average = this.testPoint.ObserveProperty(x => x.Average)
                           .ToReadOnlyReactivePropertySlim()
                           .AddTo(this.disposables);

            this.RaisePropertyChanged(nameof(this.TestDate));
            this.RaisePropertyChanged(nameof(this.JapaneseScore));
            this.RaisePropertyChanged(nameof(this.MathematicsScore));
            this.RaisePropertyChanged(nameof(this.EnglishScore));
            this.RaisePropertyChanged(nameof(this.Average));
        }
コード例 #11
0
        /// <summary>Viewを表示した後呼び出されます。</summary>
        /// <param name="navigationContext">Navigation Requestの情報を表すNavigationContext。</param>
        void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
        {
            if (this.physical != null)
            {
                return;
            }

            this.physical = this.getPhysicalData(navigationContext);

            //var physicalInfo = this.getPhysicalData(navigationContext);

            //this.physical.MeasurementDate = physicalInfo.MeasurementDate;
            //this.physical.Height = physicalInfo.Height;
            //this.physical.Weight = physicalInfo.Weight;


            this.MeasurementDate = this.physical
                                   .ToReactivePropertyAsSynchronized(x => x.MeasurementDate)
                                   .AddTo(this.disposables);
            this.Height = this.physical
                          .ToReactivePropertyAsSynchronized(x => x.Height)
                          .AddTo(this.disposables);
            this.Weight = this.physical
                          .ToReactivePropertyAsSynchronized(x => x.Weight)
                          .AddTo(this.disposables);
            this.Bmi = this.physical.ObserveProperty(x => x.Bmi)
                       .ToReadOnlyReactivePropertySlim()
                       .AddTo(this.disposables);

            this.RaisePropertyChanged(null);
        }
コード例 #12
0
        internal ToolTipViewModel(ToolTipModel toolTip)
        {
            IsOpen = toolTip
                     .ObserveProperty(x => x.IsOpen)
                     .ToReadOnlyReactivePropertySlim()
                     .AddTo(disposable);

            Title = toolTip
                    .ObserveProperty(x => x.Title)
                    .ToReadOnlyReactivePropertySlim()
                    .AddTo(disposable);

            Icon = toolTip
                   .ObserveProperty(x => x.Icon)
                   .ToReadOnlyReactivePropertySlim()
                   .AddTo(disposable);

            Text = toolTip
                   .ObserveProperty(x => x.Text)
                   .ToReadOnlyReactivePropertySlim()
                   .AddTo(disposable);

            X = toolTip
                .ObserveProperty(x => x.X)
                .ToReadOnlyReactivePropertySlim()
                .AddTo(disposable);

            Y = toolTip
                .ObserveProperty(x => x.Y)
                .ToReadOnlyReactivePropertySlim()
                .AddTo(disposable);
        }
コード例 #13
0
        /// <summary>Viewを表示した後呼び出されます。</summary>
        /// <param name="navigationContext">Navigation Requestの情報を表すNavigationContext。</param>
        void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
        {
            // 既にViewが作成されている場合は何もしない
            // (Viewを切り替える度に初期化する羽目になる)
            if (this._testPointInfo != null)
            {
                return;
            }

            // 呼び出し元から渡されたparameterを取り出す
            this._testPointInfo = navigationContext.Get <Models.TestPointInformation>();

            // ViewModel <=> Modelを双方向bindする
            this.TestDate = this._testPointInfo.TestDate
                            .ToReactivePropertyAsSynchronized(x => x.Value)
                            .AddTo(this._disposables);
            this.JapaneseScore = this._testPointInfo.JapaneseScore
                                 .ToReactivePropertyAsSynchronized(x => x.Value)
                                 .AddTo(this._disposables);
            this.MathematicsScore = this._testPointInfo.MathematicsScore
                                    .ToReactivePropertyAsSynchronized(x => x.Value)
                                    .AddTo(this._disposables);
            this.EnglishScore = this._testPointInfo.EnglishScore
                                .ToReactivePropertyAsSynchronized(x => x.Value)
                                .AddTo(this._disposables);
            // 平均点は読み取り専用なので片方向のみ
            this.Average = this._testPointInfo.Average
                           .AddTo(this._disposables);

            // 変更通知を出して値を更新する
            // - constructor以外でReactivePropertyを初期化するのに必要
            this.RaisePropertyChanged(null);
        }
コード例 #14
0
        /// <summary>Viewを表示した後呼び出されます。</summary>
        /// <param name="navigationContext">Navigation Requestの情報を表すNavigationContext。</param>
        public void OnNavigatedTo(NavigationContext navigationContext)
        {
            if (this.testPoint != null)
            {
                return;
            }
            this.testPoint = navigationContext.Parameters["TargetData"] as TestPointInformation;

            this.TestDate = this.testPoint
                            .ToReactivePropertyAsSynchronized(x => x.TestDate)
                            .SetValidateNotifyError(v => this.getTestDateError(v))
                            .AddTo(this.disposables);
            this.JapaneseScore = this.testPoint
                                 .ToReactivePropertyAsSynchronized(x => x.JapaneseScore)
                                 .SetValidateAttribute(() => this.JapaneseScore)
                                 .AddTo(this.disposables);
            this.MathematicsScore = this.testPoint
                                    .ToReactivePropertyAsSynchronized(x => x.MathematicsScore)
                                    .SetValidateAttribute(() => this.MathematicsScore)
                                    .AddTo(this.disposables);
            this.EnglishScore = this.testPoint
                                .ToReactivePropertyAsSynchronized(x => x.EnglishScore)
                                .SetValidateAttribute(() => this.EnglishScore)
                                .AddTo(this.disposables);
            this.Average = this.testPoint.ObserveProperty(x => x.Average)
                           .ToReadOnlyReactivePropertySlim()
                           .AddTo(this.disposables);

            this.RaisePropertyChanged(null);
        }
コード例 #15
0
 internal ListViewColumnHeaderViewModel(ListViewColumnHeaderModel column)
 {
     Text = column
            .ObserveProperty(x => x.Text)
            .ToReadOnlyReactivePropertySlim()
            .AddTo(disposable);
 }
コード例 #16
0
        /// <summary>Viewを表示した後呼び出されます。</summary>
        /// <param name="navigationContext">Navigation Requestの情報を表すNavigationContext。</param>
        void INavigationAware.OnNavigatedTo(NavigationContext navigationContext)
        {
            if (this.physical != null)
            {
                return;
            }
            this.physical = navigationContext.Parameters["TargetData"] as PhysicalInformation;

            this.MeasurementDate = this.physical
                                   .ToReactivePropertyAsSynchronized(x => x.MeasurementDate)
                                   .AddTo(this.disposables);
            this.Height = this.physical
                          .ToReactivePropertyAsSynchronized(x => x.Height)
                          .AddTo(this.disposables);
            this.Weight = this.physical
                          .ToReactivePropertyAsSynchronized(x => x.Weight)
                          .AddTo(this.disposables);
            this.Bmi = this.physical.ObserveProperty(x => x.Bmi)
                       .ToReadOnlyReactivePropertySlim()
                       .AddTo(this.disposables);

            this.RaisePropertyChanged(nameof(this.MeasurementDate));
            this.RaisePropertyChanged(nameof(this.Height));
            this.RaisePropertyChanged(nameof(this.Weight));
            this.RaisePropertyChanged(nameof(this.Bmi));
        }
        public OpenShiftMasterEndpointSettingsViewModel()
        {
            model   = OpenShiftMastersModel.Instance;
            Masters = model.Masters.ToReadOnlyReactiveCollection(m => new OpenShiftMasterViewModel(m));

            AddItemCommand = new ReactiveCommand()
                             .WithSubscribe(async() =>
            {
                var newMaster = new OpenShiftMasterModel();
                model.AddItem(newMaster);
                var added          = await Masters.ObserveAddChanged().FirstAsync();
                SelectedItem.Value = added;
            })
                             .AddTo(Disposable);

            RemoveItemCommand = SelectedItem
                                .Select(item => item != null)
                                .ToReactiveCommand()
                                .WithSubscribe(() => model.DeleteItem(SelectedItem.Value.Model))
                                .AddTo(Disposable);

            CanSave = Masters.Select(m => m.HasErrors).CombineLatestValuesAreAllFalse().ToReactiveProperty();

            IsSelected = SelectedItem
                         .Select(item => item != null)
                         .ToReadOnlyReactivePropertySlim(false);
        }
コード例 #18
0
        public EventToReactiveViewModel()
        {
            MousePosition = new ReactivePropertySlim <string>();

            OpenFileCommand = new ReactiveCommand <string>();
            OpenedFile      = OpenFileCommand.Select(x => $"You selected {x}")
                              .ToReadOnlyReactivePropertySlim()
                              .AddTo(Disposables);
        }
コード例 #19
0
 public ShellViewModel(DocumentManager documentManager)
 {
     DocumentManager = documentManager;
     SwitchDocumentEditModeCommand = new ReactiveCommand()
                                     .WithSubscribe(() => DocumentManager.SwitchEditMode());
     IsFullScreen = DocumentManager.DocumentEditMode
                    .Select(x => x == DocumentEditMode.FullScreen)
                    .ToReadOnlyReactivePropertySlim();
 }
コード例 #20
0
        public ExporterViewModel()
        {
            InitialFileName = SelectedYear.CombineLatest(SelectedMonth, (year, month) => $"工数管理_{year}年{month:00}月分")
                              .ToReadOnlyReactivePropertySlim();

            UseWorkingHourApiImport.Value = string.IsNullOrEmpty(_ExporterModel.WorkingHourImportUrl) == false;

            var paramConfig = UserConfigurationManager.Instance.GetConfiguration <ImportParamConfig>(ConfigKey.ImportParam);

            ImportKey.Value = paramConfig?.Param ?? "";
        }
コード例 #21
0
 public CalendarControlViewModel(IRegionManager regionManager, IEventAggregator eventAggregator, IPowerLogService powerLog, IPreferenceService preference) :
     base(regionManager)
 {
     EventAggregator = eventAggregator;
     Preference      = preference;
     PowerLogService = powerLog;
     DisplayDate     = powerLog.ScannedDate.ToReactiveProperty().AddTo(Disposable);
     SelectedDate.Subscribe(OnSelectedDateChanged);
     ScanCompleted = powerLog.ScanCompleted.ToReadOnlyReactivePropertySlim().AddTo(Disposable);
     ScanCompleted.Subscribe(OnScanCompletedChanged).AddTo(Disposable);
 }
コード例 #22
0
        public ArchiveManagerViewModel()
        {
            TargetDateTime = _Model.TargetDate
                             .ToReactivePropertyAsSynchronized(d => d.Value)
                             .AddTo(CompositeDisposable);

            WorkingTimeRecords = _Model.DailyWorkRecordHeaders
                                 .ToReadOnlyReactiveCollection()
                                 .AddTo(CompositeDisposable);

            NoResults = _Model.NoResults.ToReadOnlyReactivePropertySlim();
        }
コード例 #23
0
        public MainWindowViewModel()
        {
            _compositeDisposable = new CompositeDisposable();
            _calculator          = new Calculator();
            NumberCommand        = new ReactiveCommand <int>()
                                   .AddTo(_compositeDisposable);
            NumberCommand.Subscribe(x => _calculator.Input(x))
            .AddTo(_compositeDisposable);

            Display = _calculator.ObserveProperty(x => x.DisplayString)
                      .ToReadOnlyReactivePropertySlim()
                      .AddTo(_compositeDisposable);
        }
コード例 #24
0
        public ItemService(IAccountService accountService)
        {
            _accountService = accountService;
            _firestore      = CrossCloudFirestore.Current.Instance;

            Item    = _item.ToReadOnlyReactivePropertySlim();
            Owner   = _owner.ToReadOnlyReactivePropertySlim();
            IsLiked = _isLiked.ToReadOnlyReactivePropertySlim();
            IsOwner = Observable.CombineLatest(Item, _accountService.UserId, (item, userId) => item != null && item.OwnerId == userId)
                      .ToReadOnlyReactivePropertySlim();
            IsLoaded   = _isLoaded.ToReadOnlyReactivePropertySlim();
            IsDeleting = _deletingNotifier.ToReadOnlyReactivePropertySlim();
        }
コード例 #25
0
 public TodoItemsViewModel(TodoApp todoApp, IMessageBroker messageBroker)
 {
     _todoApp       = todoApp;
     _messageBroker = messageBroker;
     TodoItems      = _messageBroker.ToObservable <TargetViewChangedEvent>()
                      .Select(x => x.TargetViewType)
                      .Select(x => (IEnumerable <TodoItem>)(x switch
     {
         TargetViewType.All => _todoApp.AllTodoItems,
         TargetViewType.Active => _todoApp.ActiveTodoItems,
         TargetViewType.Completed => _todoApp.CompletedTodoitems,
         _ => throw new InvalidOperationException(),
     }))
コード例 #26
0
        public TestPointInformation(int id, string testDate)
        {
            this.Id       = id;
            this.TestDate = new ReactivePropertySlim <string>(testDate);

            // 平均点を計算する
            this.Average = Observable.Merge(
                this.JapaneseScore,
                this.MathematicsScore,
                this.EnglishScore
                )
                           .Select(_ => (this.JapaneseScore.Value + this.MathematicsScore.Value + this.EnglishScore.Value) / 3.0)
                           .ToReadOnlyReactivePropertySlim();
        }
コード例 #27
0
        public PhysicalInformation(int id)
        {
            this.Id = id;
            this.MeasurementDate = new ReactivePropertySlim <DateTime?>(null);
            this.Height          = new ReactivePropertySlim <double>(0.0);
            this.Weight          = new ReactivePropertySlim <double>(0.0);

            // BMIを計算する
            this.Bmi = this.Height
                       .CombineLatest(this.Weight, (height, weight) =>
                                      height == 0 ? 0
                  : Math.Round(weight / Math.Pow(height / 100, 2), 1, MidpointRounding.AwayFromZero))
                       .ToReadOnlyReactivePropertySlim();
        }
コード例 #28
0
        public EmailLoginService(IAccountService accountService)
        {
            _accountService = accountService;

            CanLogin = new[]
            {
                Email.Select(s => !string.IsNullOrEmpty(s)),
                Password.Select(s => !string.IsNullOrEmpty(s))
            }
            .CombineLatestValuesAreAllTrue()
            .ToReadOnlyReactivePropertySlim();

            IsLoggingIn = _loggingInNotifier.ToReadOnlyReactivePropertySlim();
        }
コード例 #29
0
        public BasicUsagesWindowVewModel()
        {
            Input  = new ReactiveProperty <string>();
            Output = Input.Delay(TimeSpan.FromSeconds(1))
                     .Select(x => x?.ToUpper())
                     .ToReadOnlyReactiveProperty()
                     .AddTo(Disposables);

            InputSlim  = new ReactivePropertySlim <string>();
            OutputSlim = InputSlim.Delay(TimeSpan.FromSeconds(1))
                         .Select(x => x?.ToUpper())
                         .ObserveOnUIDispatcher()
                         .ToReadOnlyReactivePropertySlim() // TODO:???必要なのか?
                         .AddTo(Disposables);
        }
コード例 #30
0
        public TodoApp()
        {
            _todoItems         = new ObservableCollection <TodoItem>();
            AllTodoItems       = new ReadOnlyObservableCollection <TodoItem>(_todoItems);
            ActiveTodoItems    = AllTodoItems.ToFilteredReadOnlyObservableCollection(x => !x.Completed.Value).AddTo(_disposables);
            CompletedTodoitems = AllTodoItems.ToFilteredReadOnlyObservableCollection(x => x.Completed.Value).AddTo(_disposables);

            IsCompletedAllItems = AllTodoItems.ObserveElementProperty(x => x.Completed)
                                  .ToUnit()
                                  .Merge(AllTodoItems.CollectionChangedAsObservable().ToUnit())
                                  .Throttle(TimeSpan.FromMilliseconds(10))
                                  .Select(_ => AllTodoItems.Count != 0 && AllTodoItems.All(x => x.Completed.Value))
                                  .ToReadOnlyReactivePropertySlim()
                                  .AddTo(_disposables);
        }