예제 #1
0
        public void NotifyCase()
        {
            var n = new BusyNotifier();

            var d = n.ProcessStart();

            var observeNotifyIsBusyCounter = 0;
            var latestNotifyIsBusyValue    = false;

            n.Subscribe(x =>
            {
                observeNotifyIsBusyCounter++;
                latestNotifyIsBusyValue = x;
            });

            observeNotifyIsBusyCounter.Is(1);
            latestNotifyIsBusyValue.IsTrue();
            n.IsBusy.IsTrue();

            d.Dispose();

            observeNotifyIsBusyCounter.Is(2);
            latestNotifyIsBusyValue.IsFalse();
            n.IsBusy.IsFalse();
        }
예제 #2
0
 private async void OtherTakeLongTimeAsync()
 {
     using (BusyNotifier.ProcessStart())
     {
         await Task.Run(() => Model.TakeLongTimeTask2());
     }
 }
        public TypingConfirmContentViewModel(AppContextService appService)
            : base(appService)
        {
            this.cts = new CancellationTokenSource();
            this.cts.AddTo(this.Disposables);
            this.busyNotifier = new BusyNotifier();

            this.DialogViewModel = new ReactivePropertySlim <StartingPracticeDialogViewModel>().AddTo(this.Disposables);
            this.IsDialogOpen    = new ReactivePropertySlim <bool>().AddTo(this.Disposables);

            this.Initialize(appService);
        }
예제 #4
0
        public BusyNotifierViewModel(BusyNotifierModel _model)
        {
            Model = _model;

            BusyNotifierStatus = BusyNotifier.Select(item => item ? "処理中" : "処理していない").ToReactiveProperty().AddTo(DisposeCollection);

            TakeLongTimeCommand = BusyNotifier.Select(b => !b).ToReactiveCommand().AddTo(DisposeCollection);
            TakeLongTimeCommand.Subscribe(TakeLongTimeAsync).AddTo(DisposeCollection);

            OtherTakeLongTimeCommand = BusyNotifier.Select(b => !b).ToReactiveCommand().AddTo(DisposeCollection);
            OtherTakeLongTimeCommand.Subscribe(TakeLongTimeAsync).AddTo(DisposeCollection);
            OtherTakeLongTimeCommand.Subscribe(OtherTakeLongTimeAsync).AddTo(DisposeCollection);
        }
예제 #5
0
        public void MultipleCase()
        {
            var n = new BusyNotifier();
            var notifyPropertyChangedCounter = 0;

            n.PropertyChanged += (_, e) =>
            {
                if (e.PropertyName == nameof(BusyNotifier.IsBusy))
                {
                    notifyPropertyChangedCounter++;
                }
            };
            var observeNotifyIsBusyCounter = 0;
            var latestNotifyIsBusyValue    = false;

            n.Subscribe(x =>
            {
                observeNotifyIsBusyCounter++;
                latestNotifyIsBusyValue = x;
            });

            notifyPropertyChangedCounter.Is(0);
            observeNotifyIsBusyCounter.Is(1);
            latestNotifyIsBusyValue.IsFalse();

            var d1 = n.ProcessStart();
            var d2 = n.ProcessStart();

            notifyPropertyChangedCounter.Is(1);
            observeNotifyIsBusyCounter.Is(2);
            latestNotifyIsBusyValue.IsTrue();
            n.IsBusy.IsTrue();

            d1.Dispose();

            notifyPropertyChangedCounter.Is(1);
            observeNotifyIsBusyCounter.Is(2);
            latestNotifyIsBusyValue.IsTrue();
            n.IsBusy.IsTrue();

            d2.Dispose();

            notifyPropertyChangedCounter.Is(2);
            observeNotifyIsBusyCounter.Is(3);
            latestNotifyIsBusyValue.IsFalse();
            n.IsBusy.IsFalse();
        }
        public void MultipleCase()
        {
            var n = new BusyNotifier();
            var notifyPropertyChangedCounter = 0;
            n.PropertyChanged += (_, e) =>
            {
                if (e.PropertyName == nameof(BusyNotifier.IsBusy))
                {
                    notifyPropertyChangedCounter++;
                }
            };
            var observeNotifyIsBusyCounter = 0;
            var latestNotifyIsBusyValue = false;
            n.Subscribe(x =>
            {
                observeNotifyIsBusyCounter++;
                latestNotifyIsBusyValue = x;
            });

            notifyPropertyChangedCounter.Is(0);
            observeNotifyIsBusyCounter.Is(1);
            latestNotifyIsBusyValue.IsFalse();

            var d1 = n.ProcessStart();
            var d2 = n.ProcessStart();

            notifyPropertyChangedCounter.Is(1);
            observeNotifyIsBusyCounter.Is(2);
            latestNotifyIsBusyValue.IsTrue();
            n.IsBusy.IsTrue();

            d1.Dispose();

            notifyPropertyChangedCounter.Is(1);
            observeNotifyIsBusyCounter.Is(2);
            latestNotifyIsBusyValue.IsTrue();
            n.IsBusy.IsTrue();

            d2.Dispose();

            notifyPropertyChangedCounter.Is(2);
            observeNotifyIsBusyCounter.Is(3);
            latestNotifyIsBusyValue.IsFalse();
            n.IsBusy.IsFalse();
        }
예제 #7
0
        public DeviceSelectDialogViewModel()
        {
            _disposables = new CompositeDisposable();

            LocalAddress = SwMainApi.GetAllLocalIPv4Addresses().FirstOrDefault();
            var ver = Assembly.GetCallingAssembly().GetName().Version;

            AppVersion = $"{ver.Major}.{ver.Minor}.{ver.Build}";

            _devices = new ObservableCollection <DiscoverResult>();
            Devices  = _devices.ToReadOnlyReactiveCollection().AddTo(_disposables);

            _discoverBusy         = new BusyNotifier();
            DiscoverDeviceCommand = _discoverBusy.Inverse().ToReactiveCommand().AddTo(_disposables);
            DiscoverDeviceCommand.Delay(new TimeSpan(100)).Subscribe(_ => DiscoverDevice()).AddTo(_disposables);

            IsSearchIpMode = new ReactiveProperty <bool>(false).AddTo(_disposables);
            IsSearchIpMode.Subscribe(b => {
                if (b)
                {
                    // Enter mode: clear fail flag.
                    _searchFailed.OnNext(false);
                }
                else if (DiscoverDeviceCommand.CanExecute())
                {
                    // Exit mode: rescan devices.
                    DiscoverDeviceCommand.Execute();
                }
            }).AddTo(_disposables);

            _searchFailed   = new BehaviorSubject <bool>(false).AddTo(_disposables);
            SearchFailed    = _searchFailed.ToReadOnlyReactiveProperty().AddTo(_disposables);
            SearchIpAddr    = new ReactiveProperty <string>().SetValidateAttribute(() => SearchIpAddr).AddTo(_disposables);
            SearchIpCommand = Observable.CombineLatest(SearchIpAddr.ObserveHasErrors, _discoverBusy, (e, c) => !e && !c)
                              .ToReactiveCommand().AddTo(_disposables);
            SearchIpCommand.Subscribe(_ => SearchIp()).AddTo(_disposables);
        }
        public void NotifyCase()
        {
            var n = new BusyNotifier();

            var d = n.ProcessStart();

            var observeNotifyIsBusyCounter = 0;
            var latestNotifyIsBusyValue = false;
            n.Subscribe(x =>
            {
                observeNotifyIsBusyCounter++;
                latestNotifyIsBusyValue = x;
            });

            observeNotifyIsBusyCounter.Is(1);
            latestNotifyIsBusyValue.IsTrue();
            n.IsBusy.IsTrue();

            d.Dispose();

            observeNotifyIsBusyCounter.Is(2);
            latestNotifyIsBusyValue.IsFalse();
            n.IsBusy.IsFalse();
        }