当前位置: 首页>>代码示例>>C#>>正文


C# ReactiveProperty.Where方法代码示例

本文整理汇总了C#中ReactiveProperty.Where方法的典型用法代码示例。如果您正苦于以下问题:C# ReactiveProperty.Where方法的具体用法?C# ReactiveProperty.Where怎么用?C# ReactiveProperty.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReactiveProperty的用法示例。


在下文中一共展示了ReactiveProperty.Where方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MainWindowViewModel

        public MainWindowViewModel()
        {
            Op = new Operation(
                //new MockWorker() ??
                //new NetshWorker() ??
                new NativeWifiWorker() as IWlanWorker);

            this.Profiles = Op.Profiles.ToReadOnlyReactiveCollection(x => new ProfileItemViewModel(x));

            #region AutoReloadEnabled/Suspended/ConfigMode

            IsAutoReloadEnabled = Op
                .ToReactivePropertyAsSynchronized(x => x.IsAutoReloadEnabled);

            IsSuspended = Op
                .ToReactivePropertyAsSynchronized(x => x.IsSuspended);

            IsConfigMode = new ReactiveProperty<bool>();

            IsAutoReloadEnabled
                .Merge(IsSuspended)
                .Where(x => x)
                .Subscribe(_ => IsConfigMode.Value = false);

            IsConfigMode
                .Where(x => x)
                .Subscribe(_ => IsAutoReloadEnabled.Value = false);

            #endregion

            #region Load

            IsLoading = Op.IsLoading
                .Where(_ => !Op.IsWorking.Value)
                //.Select(x => Observable.Empty<bool>()
                //	.Delay(TimeSpan.FromMilliseconds(10))
                //	.StartWith(x))
                //.Concat()
                .ObserveOnUIDispatcher()
                .ToReadOnlyReactiveProperty();

            ReloadCommand = IsLoading
                .Select(x => !x)
                .ToReactiveCommand();
            ReloadCommand
                .Subscribe(async _ => await Op.LoadProfilesAsync(true));

            Profiles
                .ObserveElementObservableProperty(x => x.Position)
                .Throttle(TimeSpan.FromMilliseconds(10))
                .ObserveOn(SynchronizationContext.Current)
                .Subscribe(_ => ProfilesView.Refresh()); // ListCollectionView.Refresh method seems not thread-safe.

            #endregion

            #region Work

            IsNotWorking = Op.IsWorking
                .Select(x => !x)
                .StartWith(true) // This is necessary for initial query.
                .ObserveOnUIDispatcher()
                .ToReadOnlyReactiveProperty();

            // Query for a profile which is selected.
            var querySelectedProfiles = Profiles
                .ObserveElementObservableProperty(x => x.IsSelected)
                .Where(x => x.Value)
                .Select(x => x.Instance)
                .Publish();

            // Query for the selected profile which is connected or disconnected.
            var queryConnectedProfiles = Profiles
                .ObserveElementObservableProperty(x => x.IsConnected)
                .Where(x => x.Instance.IsSelected.Value)
                .Select(x => x.Instance)
                .Publish();

            // Query for the selected profile which changes to be available or unavailable.
            var queryAvailableProfiles = Profiles
                .ObserveElementObservableProperty(x => x.IsAvailable)
                .Where(x => x.Instance.IsSelected.Value)
                .Select(x => x.Instance)
                .Publish();

            #region MoveUp

            var queryMoveUp = querySelectedProfiles
                .Select(x => x.Position.Value > 0);

            MoveUpCommand = new[] { IsNotWorking, queryMoveUp }
                .CombineLatestValuesAreAllTrue()
                .ToReactiveCommand();
            MoveUpCommand
                .Subscribe(async _ => await Op.MoveUpProfileAsync());

            #endregion

            #region MoveDown

            var queryMoveDown = querySelectedProfiles
//.........这里部分代码省略.........
开发者ID:emoacht,项目名称:WlanProfileViewer,代码行数:101,代码来源:MainWindowViewModel.cs

示例2: Init

        public void Init()
        {
            disposable = new CompositeDisposable(
                isSelected,
                LateUpdateObservable,
                OnClickObservable,
                noteColor_,
                noteType);

            var editPresenter = EditNotesPresenter.Instance;
            noteType = this.ObserveEveryValueChanged(_ => note.type).ToReactiveProperty();

            disposable.Add(noteType.Where(_ => !isSelected.Value)
                .Merge(isSelected.Select(_ => noteType.Value))
                .Select(type => type == NoteTypes.Long)
                .Subscribe(isLongNote => noteColor_.Value = isLongNote ? longNoteColor : singleNoteColor));

            disposable.Add(isSelected.Where(selected => selected)
                .Subscribe(_ => noteColor_.Value = selectedStateColor));

            var mouseDownObservable = OnClickObservable
                .Select(_ => EditState.NoteType.Value)
                .Where(_ => NoteCanvas.ClosestNotePosition.Value.Equals(note.position));

            disposable.Add(mouseDownObservable.Where(editType => editType == NoteTypes.Single)
                .Where(editType => editType == noteType.Value)
                .Subscribe(_ => editPresenter.RequestForRemoveNote.OnNext(note)));

            disposable.Add(mouseDownObservable.Where(editType => editType == NoteTypes.Long)
                .Where(editType => editType == noteType.Value)
                .Subscribe(_ =>
                {
                    if (EditData.Notes.ContainsKey(EditState.LongNoteTailPosition.Value) && note.prev.Equals(NotePosition.None))
                    {
                        var currentTailNote = new Note(EditData.Notes[EditState.LongNoteTailPosition.Value].note);
                        currentTailNote.next = note.position;
                        editPresenter.RequestForChangeNoteStatus.OnNext(currentTailNote);

                        var selfNote = new Note(note);
                        selfNote.prev = currentTailNote.position;
                        editPresenter.RequestForChangeNoteStatus.OnNext(selfNote);
                    }
                    else
                    {
                        if (EditData.Notes.ContainsKey(note.prev) && !EditData.Notes.ContainsKey(note.next))
                            EditState.LongNoteTailPosition.Value = note.prev;

                        editPresenter.RequestForRemoveNote.OnNext(new Note(note.position, EditState.NoteType.Value, note.next, note.prev));
                        RemoveLink();
                    }
                }));

            var longNoteUpdateObservable = LateUpdateObservable
                .Where(_ => noteType.Value == NoteTypes.Long);

            disposable.Add(longNoteUpdateObservable
                .Where(_ => EditData.Notes.ContainsKey(note.next))
                .Select(_ => ConvertUtils.NoteToCanvasPosition(note.next))
                .Merge(longNoteUpdateObservable
                    .Where(_ => EditState.NoteType.Value == NoteTypes.Long)
                    .Where(_ => EditState.LongNoteTailPosition.Value.Equals(note.position))
                    .Select(_ => ConvertUtils.ScreenToCanvasPosition(Input.mousePosition)))
                .Select(nextPosition => new Line(
                    ConvertUtils.CanvasToScreenPosition(ConvertUtils.NoteToCanvasPosition(note.position)),
                    ConvertUtils.CanvasToScreenPosition(nextPosition),
                    isSelected.Value || EditData.Notes.ContainsKey(note.next) && EditData.Notes[note.next].isSelected.Value ? selectedStateColor
                        : 0 < nextPosition.x - ConvertUtils.NoteToCanvasPosition(note.position).x ? longNoteColor : invalidStateColor))
                .Subscribe(line => GLLineDrawer.Draw(line)));
        }
开发者ID:setchi,项目名称:NoteEditor,代码行数:69,代码来源:NoteObject.cs

示例3: InitializeThumnailBar

        /// <summary>
        /// サムネイルバー用プロパティの初期化
        /// </summary>
        private void InitializeThumnailBar()
        {
            //検索結果画像一覧
            Images = webImageStore.Images
                .ToReadOnlyReactiveCollection(source => new WebImageViewModel(source, App.VisionApiSubscriptionKey, logger));

            //選択画像
            SelectedImage = new ReactiveProperty<WebImageViewModel>();
            SelectedImage.Where(x => x != null).Subscribe(async item =>
            {
                //サムネイルを選択したら実行する処理
                //フルサイズ画像のダウンロードと画像の解析を実行
                await item.DownloadImageDetailsAsync();
            }).AddTo(disposables);
        }
开发者ID:pierre3,项目名称:ReactiveBingViewer,代码行数:18,代码来源:MainWindowViewModel.cs

示例4: Life

 public Life(int initialPoint)
 {
     currentPoint = new ReactiveProperty<int>(initialPoint);
     lifeOverStream = currentPoint.Where(x => x <= 0).Take(1).AsObservable();
 }
开发者ID:adarapata,项目名称:action-game-scripts,代码行数:5,代码来源:Life.cs


注:本文中的ReactiveProperty.Where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。