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


C# ReactiveList.First方法代码示例

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


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

示例1: PrintSettingsViewModel

        public PrintSettingsViewModel()
        {
            var lps = new LocalPrintServer();
            var queue = lps.GetPrintQueue("Microsoft XPS Document Writer");
            var pc = Capabilities.Load(queue.GetPrintCapabilitiesAsXml());
            printTicket = Ticket.Load(queue.DefaultPrintTicket.GetXmlStream());

            var mediaSizeFeature = pc.Get(Psk.PageMediaSize);
            MediaSizeDisplayName = mediaSizeFeature.Get(Psk.DisplayName)?.AsString();
            MediaSizeCapabilities = new ReactiveList<MediaSizeViewModel>(
                from option in mediaSizeFeature.Options()
                select new MediaSizeViewModel(option));

            MediaSize = MediaSizeCapabilities.First(ms =>
            {
                return ms.Option.Name == printTicket.Get(Psk.PageMediaSize)?.First()?.Name;
            });

            this.WhenAnyValue(x => x.MediaSize)
                .Skip(1)
                .Subscribe(ms =>
                {
                    printTicket = printTicket.Set(Psk.PageMediaSize, ms.Option);
                });

            var copies = pc.Get(Psk.JobCopiesAllDocuments);
            CopiesDisplayName = copies.Get(Psk.DisplayName)?.AsString();
            CopiesMax = (copies.Get(Psf.MaxValue)?.AsInt()).GetValueOrDefault(1);
            CopiesMin = (copies.Get(Psf.MinValue)?.AsInt()).GetValueOrDefault(1);
            CopiesMultiple = (copies.Get(Psf.Multiple)?.AsInt()).GetValueOrDefault(1);
            Copies = (copies.Get(Psf.DefaultValue)?.AsInt()).GetValueOrDefault(1);

            this.WhenAnyValue(x => x.Copies)
                .Skip(1)
                .Subscribe(cp =>
                {
                    printTicket = printTicket.Set(Psk.JobCopiesAllDocuments, cp);
                });

            IncreaseCopies = ReactiveCommand.Create(
                this.WhenAny(_ => _.Copies, x => x.Value < CopiesMax));
            IncreaseCopies.Subscribe(_ =>
            {
                Copies += CopiesMultiple;
            });

            DecreaseCopies = ReactiveCommand.Create(
                this.WhenAny(_ => _.Copies, x => x.Value > CopiesMin));
            DecreaseCopies.Subscribe(_AppDomain =>
            {
                Copies -= CopiesMultiple;
            });
        }
开发者ID:kei10in,项目名称:KipSharp,代码行数:53,代码来源:PrintSettingsViewModel.cs

示例2: MonthViewModel

		public MonthViewModel(IEnumerable<Transfer> transfers)
		{
			Transfers = new ReactiveList<Transfer>(transfers);

			MonthName = Transfers.First().Raw.Date.ToString("MMMM");

			this.WhenAnyObservable(x => x.Transfers.Changed)
				.Select(_ => Transfers.Where(x => x.Raw.Amount > 0).Sum(x => x.Raw.Amount))
				.StartWith(Transfers.Where(x => x.Raw.Amount > 0).Sum(x => x.Raw.Amount))
				.ToProperty(this, vm => vm.Incomes, out income);

			this.WhenAnyObservable(x => x.Transfers.Changed)
				.Select(_ => Transfers.Where(x => x.Raw.Amount < 0).Sum(x => x.Raw.Amount))
				.StartWith(Transfers.Where(x => x.Raw.Amount < 0).Sum(x => x.Raw.Amount))
				.ToProperty(this, vm => vm.Expanses, out expenditure);

			this.WhenAnyValue(x => x.Incomes, x => x.Expanses)
				.Select(t => t.Item1 + t.Item2)
				.ToProperty(this, vm => vm.Balance, out balance);

		}
开发者ID:dachowiec,项目名称:ShowMeTheMoney,代码行数:21,代码来源:MonthViewModel.cs

示例3: RequestViewModel

        public RequestViewModel(IRequestHistory requests, IObservable<HttpRequest> selectedRequested )
        {
            this.requests = requests;
            HttpMethods = new ReactiveList<HttpMethods>(Enum.GetValues(typeof(HttpMethods)).Cast<HttpMethods>());
            SelectedHttpMethod = HttpMethods.First();

            var canSendRequest = this.WhenAny(x => x.Url, url => UrlHelper.IsValidUrl(url.Value));
            SendRequest = ReactiveCommand.CreateAsyncTask(canSendRequest, SendRequestImpl);

            this.ObservableForProperty(vm => vm.Url).Subscribe(_ =>
            {
                Reset();
            });

            selectedRequested.Subscribe(request =>
            {
                Reset();
                SelectedHttpMethod = request.Method;
                Url = request.Url;
                SendRequest.Execute(null);
            });
        }
开发者ID:georgebearden,项目名称:Peticion,代码行数:22,代码来源:RequestViewModel.cs


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