• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ReactiveList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ReactiveList的典型用法代码示例。如果您正苦于以下问题:C# ReactiveList类的具体用法?C# ReactiveList怎么用?C# ReactiveList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ReactiveList类属于命名空间,在下文中一共展示了ReactiveList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: IssueMilestonesViewModel

        public IssueMilestonesViewModel(
            Func<Task<IReadOnlyList<Milestone>>> loadMilestones,
            Func<Task<Milestone>> loadSelectedFunc,
            Func<Milestone, Task> saveFunc)
        {
            var milestones = new ReactiveList<Milestone>();
            Milestones = milestones.CreateDerivedCollection(x => CreateItemViewModel(x));

            this.WhenAnyValue(x => x.Selected)
                .Subscribe(x => {
                    foreach (var a in Milestones)
                        a.IsSelected = a.Number == x?.Number;
                });

            DismissCommand = ReactiveCommand.Create();

            SaveCommand = ReactiveCommand.CreateAsyncTask(_ => {
                DismissCommand.ExecuteIfCan();
                return _selected != _previouslySelected ? saveFunc(_selected) : Task.FromResult(0);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {
                _previouslySelected = Selected = await loadSelectedFunc();
                milestones.Reset(await loadMilestones());
            });
        }
开发者ID:runt18,项目名称:CodeHub,代码行数:26,代码来源:IssueMilestonesViewModel.cs


示例2: LanguagesViewModel

        public LanguagesViewModel(IJsonSerializationService jsonSerializationService, INetworkActivityService networkActivity)
        {
            var languages = new ReactiveList<LanguageModel>();

            Languages = languages.CreateDerivedCollection(
                x => new LanguageItemViewModel(x.Name, x.Slug), 
                x => x.Name.StartsWith(SearchKeyword ?? string.Empty, StringComparison.OrdinalIgnoreCase), 
                signalReset: this.WhenAnyValue(x => x.SearchKeyword));

            Languages
                .Changed.Select(_ => Unit.Default)
                .Merge(this.WhenAnyValue(x => x.SelectedLanguage).Select(_ => Unit.Default))
                .Select(_ => SelectedLanguage)
                .Where(x => x != null)
                .Subscribe(x =>
                {
                    foreach (var l in Languages)
                        l.Selected = l.Slug == x.Slug;
                });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async t =>
            {
                var trendingData = await BlobCache.LocalMachine.DownloadUrl(LanguagesUrl, absoluteExpiration: DateTimeOffset.Now.AddDays(1));
                var langs = jsonSerializationService.Deserialize<List<LanguageModel>>(System.Text.Encoding.UTF8.GetString(trendingData));
                langs.Insert(0, DefaultLanguage);
                languages.Reset(langs);
            });

            LoadCommand.TriggerNetworkActivity(networkActivity);
            LoadCommand.ExecuteIfCan();
        }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:31,代码来源:LanguagesViewModel.cs


示例3: BaseCommitsViewModel

        protected BaseCommitsViewModel()
	    {
            Title = "Commits";

            var gotoCommitCommand = ReactiveCommand.Create();
            gotoCommitCommand.OfType<CommitItemViewModel>().Subscribe(x =>
            {
                var vm = this.CreateViewModel<CommitViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                vm.Node = x.Commit.Sha;
                NavigateTo(vm);
            });

            var commits = new ReactiveList<CommitItemViewModel>();
            Commits = commits.CreateDerivedCollection(
                x => x, 
                x => x.Description.ContainsKeyword(SearchKeyword) || x.Name.ContainsKeyword(SearchKeyword), 
                signalReset: this.WhenAnyValue(x => x.SearchKeyword));

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
                commits.SimpleCollectionLoad(CreateRequest(), 
                    x => new CommitItemViewModel(x, gotoCommitCommand.ExecuteIfCan),
                    x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x())));
	    }
开发者ID:zdd910,项目名称:CodeHub,代码行数:25,代码来源:BaseCommitsViewModel.cs


示例4: LibraryGroupViewModel

        protected LibraryGroupViewModel(string header, string addHeader = null, string icon = null) {
            Header = header;
            AddHeader = addHeader;
            Icon = icon;
            if (!Execute.InDesignMode)
                this.SetCommand(x => x.AddCommand);

            Children = new ReactiveList<IHierarchicalLibraryItem>();
            IsExpanded = true;

            this.WhenAnyValue(x => x.SelectedItemsInternal)
                .Select(x => x == null ? null : x.CreateDerivedCollection(i => (IHierarchicalLibraryItem) i))
                .BindTo(this, x => x.SelectedItems);


            UiHelper.TryOnUiThread(() => {
                Children.EnableCollectionSynchronization(_childrenLock);
                _childrenView =
                    Children.CreateCollectionView(
                        new[] {
                            new SortDescription("SortOrder", ListSortDirection.Ascending),
                            new SortDescription("Model.IsFavorite", ListSortDirection.Descending),
                            new SortDescription("Model.Name", ListSortDirection.Ascending)
                        }, null,
                        null, null, true);
                _itemsView = _childrenView;
            });
        }
开发者ID:SIXNetworks,项目名称:withSIX.Desktop,代码行数:28,代码来源:LibraryGroupViewModel.cs


示例5: AccountsViewModel

        public AccountsViewModel(IAccountsService accountsService)
        {
            _accountsService = accountsService;
            Accounts = new ReactiveList<IAccount>(accountsService);
            LoginCommand = ReactiveCommand.Create();
            GoToAddAccountCommand = ReactiveCommand.Create();
            DeleteAccountCommand = ReactiveCommand.Create();

            DeleteAccountCommand.OfType<IAccount>().Subscribe(x =>
            {
                if (Equals(accountsService.ActiveAccount, x))
                    ActiveAccount = null;
                accountsService.Remove(x);
                Accounts.Remove(x);
            });

            LoginCommand.OfType<IAccount>().Subscribe(x =>
            {
                if (Equals(accountsService.ActiveAccount, x))
                    DismissCommand.ExecuteIfCan();
                else
                {
                    ActiveAccount = x;
                    MessageBus.Current.SendMessage(new LogoutMessage());
                    DismissCommand.ExecuteIfCan();
                }
            });

            GoToAddAccountCommand.Subscribe(_ => ShowViewModel(CreateViewModel<IAddAccountViewModel>()));

            this.WhenActivated(d => Accounts.Reset(accountsService));
        }
开发者ID:treejames,项目名称:CodeFramework,代码行数:32,代码来源:AccountsViewModel.cs


示例6: BlogViewModel

        public BlogViewModel(string title, Uri feedAddress, IFeedService feedService = null, IBlobCache cache = null)
        {
            Title = title;
            FeedAddress = feedAddress;
            FeedService = feedService ?? Locator.Current.GetService<IFeedService>();
            Cache = cache ?? Locator.Current.GetService<IBlobCache>();

            Articles = new ReactiveList<ArticleViewModel>();

            Refresh = ReactiveCommand.CreateAsyncObservable(x => GetAndFetchLatestArticles());
            Refresh.Subscribe(articles =>
            {
                // this could be done cleaner, send a PR.
                // Refresh.ToPropertyEx(this, x => x.Articles);

                Articles.Clear();
                Articles.AddRange(articles);
            });

            
            Refresh.ThrownExceptions.Subscribe(thrownException => { this.Log().Error(thrownException); });
            _isLoading = Refresh.IsExecuting.ToProperty(this, x => x.IsLoading);

            // post-condition checks
            Condition.Ensures(FeedAddress).IsNotNull();
            Condition.Ensures(FeedService).IsNotNull();
            Condition.Ensures(Cache).IsNotNull();
        }
开发者ID:moswald,项目名称:rxui-samples,代码行数:28,代码来源:BlogViewModel.cs


示例7: MainVM

        public MainVM()
        {
            var bobbyJoe = new Person("Bobby Joe", new[] { new Pet("Fluffy") });
            var bob = new Person("Bob", new[] { bobbyJoe });
            var littleJoe = new Person("Little Joe");
            var joe = new Person("Joe", new[] { littleJoe });
            Family = new ReactiveList<TreeItem> { bob, joe };

            _addPerson = ReactiveCommand.Create();
            _addPerson.Subscribe(_ =>
            {
                if (SelectedItem == null) return;
                var p = new Person(NewName);
                SelectedItem.AddChild(p);
                p.IsSelected = true;
                p.ExpandPath();
            });
            _addPet = ReactiveCommand.Create();
            _addPet.Subscribe(_ =>
            {
                if (SelectedItem == null) return;
                var p = new Pet(PetName);
                SelectedItem.AddChild(p);
                p.IsSelected = true;
                p.ExpandPath();
            });
            _collapse = ReactiveCommand.Create();
            _collapse.Subscribe(_ =>
            {
                SelectedItem?.CollapsePath();
            });
        }
开发者ID:reactiveui-forks,项目名称:ReactiveUI-TreeView,代码行数:32,代码来源:MainVM.cs


示例8: CacheViewModel

        public CacheViewModel(IScreen hostScreen, IAppState appState)
        {
            HostScreen = hostScreen;

            appState.WhenAny(x => x.CachePath, x => x.Value)
                .Where(x => !String.IsNullOrWhiteSpace(x))
                .Select(x => (new DirectoryInfo(x)).Name)
                .ToProperty(this, x => x.UrlPathSegment, out _UrlPathSegment);

            Keys = new ReactiveList<string>();
            appState.WhenAny(x => x.CurrentCache, x => x.Value)
                .SelectMany(x => Observable.Start(() => x.GetAllKeys(), RxApp.TaskpoolScheduler))
                .ObserveOn(RxApp.MainThreadScheduler)
                .Subscribe(newKeys => {
                    Keys.Clear();
                    newKeys.ForEach(x => Keys.Add(x));
                });

            FilteredKeys = Keys.CreateDerivedCollection(
                key => key,
                key => FilterText == null || key.IndexOf(FilterText, StringComparison.OrdinalIgnoreCase) > -1,
                signalReset: this.WhenAny(x => x.FilterText, x => x.Value));

            SelectedViewer = "Text";

            this.WhenAny(x => x.SelectedKey, x => x.SelectedViewer, (k, v) => k.Value)
                .Where(x => x != null && SelectedViewer != null)
                .SelectMany(x => appState.CurrentCache.GetAsync(x).Catch(Observable.Return(default(byte[]))))
                .Select(x => createValueViewModel(x, SelectedViewer))
                .LoggedCatch(this, Observable.Return<ICacheValueViewModel>(null))
                .ToProperty(this, x => x.SelectedValue, out _SelectedValue);
        }
开发者ID:scbond,项目名称:AkavacheExplorer,代码行数:32,代码来源:CacheViewModel.cs


示例9: IssueAssigneeViewModel

        public IssueAssigneeViewModel(
            Func<Task<IReadOnlyList<User>>> loadAssignees,
            Func<Task<User>> loadSelectedFunc,
            Func<User, Task> saveFunc)
        {
            var assignees = new ReactiveList<IssueAssigneeItemViewModel>();
            Assignees = assignees.CreateDerivedCollection(
                x => x,
                filter: x => x.Name.ContainsKeyword(SearchKeyword),
                signalReset: this.WhenAnyValue(x => x.SearchKeyword));

            this.WhenAnyValue(x => x.Selected)
                .Subscribe(x => {
                    foreach (var a in Assignees)
                        a.IsSelected = string.Equals(a.User.Login, x?.Login);
                });

            DismissCommand = ReactiveCommand.Create();

            SaveCommand = ReactiveCommand.CreateAsyncTask(_ => {
                DismissCommand.ExecuteIfCan();
                return Selected != _previouslySelected ? saveFunc(_selected) : Task.FromResult(0);
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {
                _previouslySelected = Selected = await loadSelectedFunc();
                assignees.Reset((await loadAssignees()).Select(CreateItemViewModel));
            });
        }
开发者ID:runt18,项目名称:CodeHub,代码行数:29,代码来源:IssueAssigneeViewModel.cs


示例10: IssueMilestonesViewModel

        public IssueMilestonesViewModel(IApplicationService applicationService)
        {
            Milestones = new ReactiveList<MilestoneModel>();

            SelectMilestoneCommand = ReactiveCommand.CreateAsyncTask(async t =>
            {
                var milestone = t as MilestoneModel;
                if (milestone != null)
                    SelectedMilestone = milestone;

                if (SaveOnSelect)
                {
                    try
                    {
                        int? milestoneNumber = null;
                        if (SelectedMilestone != null) milestoneNumber = SelectedMilestone.Number;
                        var updateReq = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Issues[IssueId].UpdateMilestone(milestoneNumber);
                        await applicationService.Client.ExecuteAsync(updateReq);
                    }
                    catch (Exception e)
                    {
                        throw new Exception("Unable to to save milestone! Please try again.", e);
                    }
                }

                DismissCommand.ExecuteIfCan();
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
                Milestones.SimpleCollectionLoad(
                    applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Milestones.GetAll(),
                    t as bool?));
        }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:33,代码来源:IssueMilestonesViewModel.cs


示例11: CreateCollectionView

 private MultiSelectCollectionView<ShortcutViewModel> CreateCollectionView(ReactiveList<ShortcutViewModel> shortcuts)
 {
     var view = new MultiSelectCollectionView<ShortcutViewModel>(shortcuts);
     view.Filter = ApplyFilter;
     view.SortDescriptions.Add(new SortDescription(nameof(ShortcutViewModel.Name), ListSortDirection.Ascending));
     return view;
 }
开发者ID:gatepoet,项目名称:Deicon.TilesDavis,代码行数:7,代码来源:DetailsViewModel.cs


示例12: IssueLabelsViewModel

        public IssueLabelsViewModel(Func<Task<IReadOnlyList<Label>>> loadLabels)
	    {
            var labels = new ReactiveList<Label>();
            Selected = new ReactiveList<Label>();
            Labels = labels.CreateDerivedCollection(x => 
            {
                var vm = new IssueLabelItemViewModel(x);
                vm.IsSelected = Selected.Any(y => string.Equals(y.Name, x.Name));
//                vm.GoToCommand
//                    .Select(_ => x)
//                    .Where(y => vm.IsSelected)
//                    .Where(y => Selected.All(l => l.Url != y.Url))
//                    .Subscribe(Selected.Add);
//                vm.GoToCommand
//                    .Select(_ => x)
//                    .Where(y => !vm.IsSelected)
//                    .Select(y => Selected.Where(l => l.Url == y.Url).ToArray())
//                    .Subscribe(Selected.RemoveAll);
                return vm;
            });

            SelectLabelsCommand = ReactiveCommand.CreateAsyncTask(t => {
                var selectedLabelsUrl = Selected.Select(x => x.Url).ToArray();
                var prevSelectedLabelsUrl = _previouslySelectedLabels.Select(x => x.Url).ToArray();
                var intersect = selectedLabelsUrl.Intersect(prevSelectedLabelsUrl).ToArray();
                var different = selectedLabelsUrl.Length != prevSelectedLabelsUrl.Length || intersect.Length != selectedLabelsUrl.Length;
                return Task.FromResult(0); //different ? updateIssue(new ReadOnlyCollection<Label>(Selected)) : Task.FromResult(0);
	        });

            LoadCommand = ReactiveCommand.CreateAsyncTask(async _ => {
                labels.Reset(await loadLabels());
            });
	    }
开发者ID:zdd910,项目名称:CodeHub,代码行数:33,代码来源:IssueLabelsViewModel.cs


示例13: ChangesetViewModel

        public ChangesetViewModel(IApplicationService applicationService)
        {
            _applicationService = applicationService;

            Comments = new ReactiveList<CommentModel>();

            GoToHtmlUrlCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.Commit).Select(x => x != null));
            GoToHtmlUrlCommand.Select(x => Commit).Subscribe(GoToUrlCommand.ExecuteIfCan);

            GoToRepositoryCommand = ReactiveCommand.Create();
            GoToRepositoryCommand.Subscribe(_ =>
            {
                var vm = CreateViewModel<RepositoryViewModel>();
                vm.RepositoryOwner = RepositoryOwner;
                vm.RepositoryName = RepositoryName;
                ShowViewModel(vm);
            });

            GoToFileCommand = ReactiveCommand.Create();
            GoToFileCommand.OfType<CommitModel.CommitFileModel>().Subscribe(x =>
            {
                if (x.Patch == null)
                {
                    var vm = CreateViewModel<SourceViewModel>();
                    vm.Branch = Commit.Sha;
                    vm.Username = RepositoryOwner;
                    vm.Repository = RepositoryName;
                    vm.Items = new [] 
                    { 
                        new SourceViewModel.SourceItemModel 
                        {
                            ForceBinary = true,
                            GitUrl = x.BlobUrl,
                            Name = x.Filename,
                            Path = x.Filename,
                            HtmlUrl = x.BlobUrl
                        }
                    };
                    vm.CurrentItemIndex = 0;
                    ShowViewModel(vm);
                }
                else
                {
                    var vm = CreateViewModel<ChangesetDiffViewModel>();
                    vm.Username = RepositoryOwner;
                    vm.Repository = RepositoryName;
                    vm.Branch = Commit.Sha;
                    vm.Filename = x.Filename;
                    ShowViewModel(vm);
                }
            });

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
            {
                var forceCacheInvalidation = t as bool?;
                var t1 = this.RequestModel(_applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Commits[Node].Get(), forceCacheInvalidation, response => Commit = response.Data);
                Comments.SimpleCollectionLoad(_applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].Commits[Node].Comments.GetAll(), forceCacheInvalidation).FireAndForget();
                return t1;
            });
        }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:60,代码来源:ChangesetViewModel.cs


示例14: AppState

 public AppState()
 {
     Articles = new ReactiveList<Article> ();
     ElectionArticles = new ReactiveList<ElectionArticle> ();
     Events = new ReactiveList<Event> ();
     OrganizationMenuItems = new ReactiveList<OrganizationMenuItem> ();
 }
开发者ID:dbeattie71,项目名称:HDP-Mobil,代码行数:7,代码来源:AppState.cs


示例15: ViewModel2

        public ViewModel2()
        {
            SearchResults = new ReactiveList<FlickrPhoto>();
            var canSearch = this.WhenAny(x => x.SearchTerm, x => !String.IsNullOrWhiteSpace(x.Value));

            Search = ReactiveCommand.CreateAsyncTask(canSearch, async _ =>  {  return await GetSearchResultFromBing(this.SearchTerm); });
            LoadMoreItems = ReactiveCommand.CreateAsyncTask(canSearch, async x => { return await LoadMore((int)x);  });

            Search.Subscribe(results =>
            {
                SearchResults.Clear();
                foreach (var item in results)
                {
                    SearchResults.Add(item);
                }
            });

            LoadMoreItems.Subscribe(results =>
            {
                foreach (var item in results)
                {
                    SearchResults.Add(item);
                }
            });

            Search.ThrownExceptions.Subscribe(ex => { UserError.Throw("Potential network connectivity Error", ex); });
            LoadMoreItems.ThrownExceptions.Subscribe(ex => { UserError.Throw("Problem when downloading additional items", ex); });

            this.WhenAnyValue(x => x.SearchTerm)
                .Throttle(TimeSpan.FromSeconds(1), RxApp.MainThreadScheduler)
                .InvokeCommand(this, x => x.Search);

            //SearchTerm = "british cat";
        }
开发者ID:afrog33k,项目名称:SharpPlayground,代码行数:34,代码来源:ViewModel2.cs


示例16: MainWindowModel

        public MainWindowModel()
        {
            _testDataSource = new TestDataSource();
            TestModels = new ReactiveList<TestModel>();

            TestViewModels = TestModels.CreateDerivedCollection(m =>
            {
                var vm = new TestViewModel
                {
                    Id = m.Id,
                    Name = m.Name,
                    OtherValue = "",
                    OriginalModel = m
                };
                vm.DoStuffWithThisCommand.Subscribe(x => DoStuff(x as TestViewModel));
                return vm;
            }, m => true, (m, vm) => 0);

            SetUpDataCommand = ReactiveCommand.CreateAsyncTask(_ => _testDataSource.GetTests());
            SetUpDataCommand.Subscribe(results =>
                {
                    using (SuppressChangeNotifications())
                    {
                        TestModels.Clear();
                        foreach (var model in results)
                            TestModels.Add(model);
                    }
                });
        }
开发者ID:reactiveui-forks,项目名称:ProgNET2014,代码行数:29,代码来源:MainWindowModel.cs


示例17: PullRequestsViewModel

        public PullRequestsViewModel(IApplicationService applicationService)
		{
            PullRequests = new ReactiveList<PullRequestModel>();

            GoToPullRequestCommand = ReactiveCommand.Create();
		    GoToPullRequestCommand.OfType<PullRequestModel>().Subscribe(pullRequest =>
		    {
		        var vm = CreateViewModel<PullRequestViewModel>();
		        vm.RepositoryOwner = RepositoryOwner;
		        vm.RepositoryName = RepositoryName;
		        vm.PullRequestId = pullRequest.Number;
		        vm.PullRequest = pullRequest;
		        vm.WhenAnyValue(x => x.PullRequest).Skip(1).Subscribe(x =>
		        {
                    var index = PullRequests.IndexOf(pullRequest);
                    if (index < 0) return;
                    PullRequests[index] = x;
                    PullRequests.Reset();
		        });
                ShowViewModel(vm);
		    });

		    this.WhenAnyValue(x => x.SelectedFilter).Skip(1).Subscribe(_ => LoadCommand.ExecuteIfCan());

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
            {
                var state = SelectedFilter == 0 ? "open" : "closed";
			    var request = applicationService.Client.Users[RepositoryOwner].Repositories[RepositoryName].PullRequests.GetAll(state: state);
                return PullRequests.SimpleCollectionLoad(request, t as bool?);
            });
		}
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:31,代码来源:PullRequestsViewModel.cs


示例18: BaseUsersViewModel

        protected BaseUsersViewModel()
        {
            var users = new ReactiveList<BasicUserModel>();
            Users = users.CreateDerivedCollection(x => {
                var isOrg = string.Equals(x.Type, "organization", StringComparison.OrdinalIgnoreCase);
                return new UserItemViewModel(x.Login, x.AvatarUrl, isOrg, () => {
                    if (isOrg)
                    {
                        var vm = this.CreateViewModel<OrganizationViewModel>();
                        vm.Init(x.Login);
                        NavigateTo(vm);
                    }
                    else
                    {
                        var vm = this.CreateViewModel<UserViewModel>();
                        vm.Init(x.Login);
                        NavigateTo(vm);
                    }
                });
            },
            x => x.Login.StartsWith(SearchKeyword ?? string.Empty, StringComparison.OrdinalIgnoreCase),
            signalReset: this.WhenAnyValue(x => x.SearchKeyword));

            LoadCommand = ReactiveCommand.CreateAsyncTask(t =>
                users.SimpleCollectionLoad(CreateRequest(), 
                x => LoadMoreCommand = x == null ? null : ReactiveCommand.CreateAsyncTask(_ => x())));
        }
开发者ID:zdd910,项目名称:CodeHub,代码行数:27,代码来源:BaseUsersViewModel.cs


示例19: AgentAnnotationViewModel

        public AgentAnnotationViewModel(ISharedDataService sharedDataService, MeetingViewModel meeting)
            : base(sharedDataService, meeting)
        {
            _annotations = new ReactiveList<AnnotationViewModel>();

            var annotationsChangedObs = _annotations
                .WhenAnyObservable(p => p.Changed)
                .Select(p => AreThereAnnotationInTheCurrentPage());

            var activeToolObs = Meeting.WhenAnyValue(vm => vm.ActiveTool).Where(t => t != null);
            var pageChangedObs = activeToolObs
                             .Select(t => t.WhenAnyValue(v => v.CurrentPageNumber, p => AreThereAnnotationInTheCurrentPage()))
                             .Switch(); // Only listen to the most recent sequence of property changes (active tool)
            var toolChangedObs = activeToolObs.Select(t => AreThereAnnotationInTheCurrentPage());

            _containsAnnotationsForCurrentPage = toolChangedObs.Merge(pageChangedObs).Merge(annotationsChangedObs)
                .ToProperty(this, p => p.ContainsAnnotationsForCurrentPage); 

            AnnotationTools = new AnnotationToolViewModel(this);

            // when the IsEditing flag changes to false, it means an edit has just completed and we can send
            // the updates annotations to the client
            _isEditingSub = this.WhenAnyValue(p => p.IsEditing)
                .Where(p => !p)
                .Subscribe(_ => UpdateAnnotationModelAnnotations());
        }
开发者ID:reactiveui-forks,项目名称:VirtualSales,代码行数:26,代码来源:AgentAnnotationViewModel.cs


示例20: FlickrSearchViewModel

        public FlickrSearchViewModel(IImageService imageService)
        {
            Images = new ReactiveList<SearchResultViewModel>();

            var canExecute = this.WhenAnyValue(x => x.SearchText)
                .Select(x => !String.IsNullOrWhiteSpace(x));

            Search = ReactiveCommand.CreateAsyncObservable(
                canExecute,
                _ =>
                {
                    Images.Clear();
                    ShowError = false;
                    return imageService.GetImages(SearchText);
                });

            Search.Subscribe(images => Images.Add(images));

            Search.ThrownExceptions.Subscribe(_ => ShowError = true);

            isLoading = Search.IsExecuting.ToProperty(this, vm => vm.IsLoading);

            canEnterSearchText = this.WhenAnyValue(x => x.IsLoading)
                .Select(x => !x)
                .ToProperty(this, vm => vm.CanEnterSearchText);
        }
开发者ID:reactiveui-forks,项目名称:ReactiveFlickr,代码行数:26,代码来源:FlickrSearchViewModel.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ReactiveProperty类代码示例发布时间:2022-05-24
下一篇:
C# ReactiveCommand类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap