本文整理汇总了C#中ObservableAsPropertyHelper.BooleanAnd方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableAsPropertyHelper.BooleanAnd方法的具体用法?C# ObservableAsPropertyHelper.BooleanAnd怎么用?C# ObservableAsPropertyHelper.BooleanAnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableAsPropertyHelper
的用法示例。
在下文中一共展示了ObservableAsPropertyHelper.BooleanAnd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ViewMapVM
//.........这里部分代码省略.........
_CurrentMap = this.ObservableToProperty(Messenger.Listen<IElementVM<Map>>(MessageContracts.VIEW), x => x.CurrentMap);
_CurrentMap
.Where(vm => vm != null)
.Select(vm => Observable.Start(() => MapStorage.loadMap(vm.Model)))
.Switch()
.ObserveOnDispatcher()
.Select(stream => {
var img = new BitmapImage();
img.SetSource(stream);
stream.Close();
return img;
})
.Subscribe(x => MapImage = x);
var current_series = Messenger.Listen<ILocationOwner>(MessageContracts.VIEW);
var current_localizable = Messenger.Listen<ILocalizable>(MessageContracts.VIEW);
var current_series_if_not_localizable = current_series.Merge(current_localizable.Select(_ => null as ILocationOwner));
var current_localizable_if_not_series = current_localizable.Merge(current_series.Select(_ => null as ILocalizable));
var series_and_map =
current_series_if_not_localizable
.CombineLatest(_CurrentMap.Where(x => x != null), (es, map) =>
new { Map = map.Model, Series = es })
.Publish();
var add_locs =
series_and_map
.Select(pair => {
if (pair.Series != null) {
var stream = Storage.getGeoPointsForSeries(pair.Series.EntityID).ToObservable(ThreadPoolScheduler.Instance) //Fetch geopoints asynchronously on Threadpool thread
.Merge(Messenger.Listen<GeoPointForSeries>(MessageContracts.SAVE).Where(gp => gp.SeriesID == pair.Series.EntityID)) //Listen to new Geopoints that are added to the current tour
.Select(gp => pair.Map.PercentilePositionOnMap(gp))
.TakeUntil(series_and_map)
.Replay();
stream.Connect();
return stream as IObservable<Point?>;
}
else
return Observable.Empty<Point?>();
}).Replay(1);
_AdditionalLocalizations = add_locs;
add_locs.Connect();
series_and_map.Connect();
Observable.CombineLatest(
current_localizable_if_not_series,
_CurrentMap,
(loc, map) => {
if (map == null)
return null;
return map.Model.PercentilePositionOnMap(loc);
})
.Subscribe(c => PrimaryLocalization = c);
ToggleEditable = new ReactiveCommand(current_localizable_if_not_series.Select(l => l != null));
_IsEditable = this.ObservableToProperty(
current_localizable_if_not_series.Select(_ => false)
.Merge(ToggleEditable.Select(_ => true)),
x => x.IsEditable);
SetLocation = new ReactiveCommand(_IsEditable);
SetLocation
.Select(loc => loc as Point?)
.Where(loc => loc != null)
.Subscribe(loc => PrimaryLocalization = loc);
var valid_localization = this.ObservableForProperty(x => x.PrimaryLocalization).Value()
.Select(loc => loc.HasValue);
Save = new ReactiveCommand(_IsEditable.BooleanAnd(valid_localization));
current_localizable_if_not_series
.Where(loc => loc != null)
.Select(loc =>
Save
.Select(_ => loc)
)
.Switch()
.Do(c => c.SetCoordinates(CurrentMap.Model.GPSFromPercentilePosition(PrimaryLocalization.Value)))
.Do(_ => Messenger.SendMessage(Page.Previous))
.ToMessage(Messenger, MessageContracts.SAVE);
this.OnActivation()
.Where(_ => CurrentMap != null)
.SelectMany(_ => Location.Location().StartWith(null as Coordinate).TakeUntil(this.OnDeactivation()))
.Select(c => CurrentMap.Model.PercentilePositionOnMap(c))
.Subscribe(c => CurrentLocation = c);
}