public IObservable <IEnumerable <Histogram> > AnalyzeAsync(SignalNotifier isCreating) { return(Observable.Start(() => { isCreating.Increment(); var ret = Analyzer.CreateHistogram(); var ymax = ret.Max(x => x.Tally); if (ymax > 10) { YAxisInterval = (int)(ymax / 10); } else { // 小数点表示したくないので、Intervalの最小値は1 YAxisInterval = 1; } // グラフ表示に少し余裕を持たせたいので20%分余白をつくる。 YAxisMaximum = ymax * 1.2; return ret; }) .Finally(() => isCreating.Decrement()) .Catch((Exception ex) => Messenger.Raise(new InformationMessage("データ解析に失敗しました。", "エラー", "ShowError")))); }
public AnalysisViewModel(NamingServiceManager maanger) { _manager = _manager; var isCreating = new SignalNotifier(); // nullではないAnalyzerがセットされたら更新実行が可能 UpdateCommand = Observable .FromEventPattern<PropertyChangedEventArgs>(this, "PropertyChanged") .Where(e => e.EventArgs.PropertyName == "Analyzer") .Select(_ => _Analyzer != null) .Merge(isCreating.Select(x => x == SignalChangedStatus.Empty)) .ToReactiveCommand(false); Items = UpdateCommand .SelectMany(_ => AnalyzeAsync(isCreating)) .Do(_ => Items.ClearOnScheduler()) .SelectMany(_ => _) .ToReactiveCollection(); }
public AnalysisViewModel(NamingServiceManager maanger) { _manager = _manager; var isCreating = new SignalNotifier(); // nullではないAnalyzerがセットされたら更新実行が可能 UpdateCommand = Observable .FromEventPattern <PropertyChangedEventArgs>(this, "PropertyChanged") .Where(e => e.EventArgs.PropertyName == "Analyzer") .Select(_ => _Analyzer != null) .Merge(isCreating.Select(x => x == SignalChangedStatus.Empty)) .ToReactiveCommand(false); Items = UpdateCommand .SelectMany(_ => AnalyzeAsync(isCreating)) .Do(_ => Items.ClearOnScheduler()) .SelectMany(_ => _) .ToReactiveCollection(); }
public SearchRecordWindowViewModel(Action<RecordDescription> notifier, string dataType=null, string componentType=null, string portName=null) { _recordDescriptionRepository = RepositoryFactory.CreateRepository(); _notifier = notifier; // 検索中は検索ボタンが押せないようにする var isSearching = new SignalNotifier(); SearchCommand = isSearching.Select(x=>x == SignalChangedStatus.Empty).ToReactiveCommand(); // 検索ボタンが押されたら検索処理を非同期で実行し、その結果をSearchResultsに入れる SearchResults = SearchCommand.SelectMany(_ => SearchAsync(isSearching)) .Do(_ => SearchResults.ClearOnScheduler()) .SelectMany(_ => _) .Select(r => new SearchResultViewModel(r, NotifyAdopt)) .ToReactiveCollection(); Initialize(dataType, componentType, portName); SearchCommand.Execute(null); }
public SearchRecordWindowViewModel(Action <RecordDescription> notifier, string dataType = null, string componentType = null, string portName = null) { _recordDescriptionRepository = RepositoryFactory.CreateRepository(); _notifier = notifier; // 検索中は検索ボタンが押せないようにする var isSearching = new SignalNotifier(); SearchCommand = isSearching.Select(x => x == SignalChangedStatus.Empty).ToReactiveCommand(); // 検索ボタンが押されたら検索処理を非同期で実行し、その結果をSearchResultsに入れる SearchResults = SearchCommand.SelectMany(_ => SearchAsync(isSearching)) .Do(_ => SearchResults.ClearOnScheduler()) .SelectMany(_ => _) .Select(r => new SearchResultViewModel(r, NotifyAdopt)) .ToReactiveCollection(); Initialize(dataType, componentType, portName); SearchCommand.Execute(null); }
/// <summary> /// 非同期でデータベースの検索を行う /// </summary> private IObservable <IEnumerable <RecordDescription> > SearchAsync(SignalNotifier isSearching) { isSearching.Increment(); // 検索中 var condition = new SearchCondition() { DataType = DataType, ComponentType = ComponentType, PortName = PortName, StartDateTime = StartDate, EndDateTime = EndDate }; return(Observable.Start(() => { //SearchResults.Clear(); var ret = _recordDescriptionRepository.GetRecordDescriptions(condition); //isSearching.Decrement(); //検索完了 return ret; }) .Finally(() => isSearching.Decrement()) .Catch((Exception ex) => Messenger.Raise(new InformationMessage("データベースアクセスに失敗しました。", "エラー", "ShowError")))); }
public IObservable<IEnumerable<Histogram>> AnalyzeAsync(SignalNotifier isCreating) { return Observable.Start(() => { isCreating.Increment(); var ret = Analyzer.CreateHistogram(); var ymax = ret.Max(x => x.Tally); if (ymax > 10) { YAxisInterval = (int)(ymax/10); } else { // 小数点表示したくないので、Intervalの最小値は1 YAxisInterval = 1; } // グラフ表示に少し余裕を持たせたいので20%分余白をつくる。 YAxisMaximum = ymax * 1.2; return ret; }) .Finally(() => isCreating.Decrement()) .Catch((Exception ex) => Messenger.Raise(new InformationMessage("データ解析に失敗しました。", "エラー", "ShowError"))); }
/// <summary> /// 非同期でデータベースの検索を行う /// </summary> private IObservable<IEnumerable<RecordDescription>> SearchAsync(SignalNotifier isSearching) { isSearching.Increment(); // 検索中 var condition = new SearchCondition() { DataType = DataType, ComponentType = ComponentType, PortName = PortName, StartDateTime = StartDate, EndDateTime = EndDate }; return Observable.Start(() => { //SearchResults.Clear(); var ret = _recordDescriptionRepository.GetRecordDescriptions(condition); //isSearching.Decrement(); //検索完了 return ret; }) .Finally(() => isSearching.Decrement()) .Catch((Exception ex) => Messenger.Raise(new InformationMessage("データベースアクセスに失敗しました。", "エラー", "ShowError"))); }