本文整理汇总了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;
});
}
示例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);
}
示例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);
});
}