public SaleViewModel() { Items = new BindableCollection <ItemViewModel>(); IsToolVisible = false; PaymentForms = new BindableCollection <AmountItemViewModel>(); var pco = Observable.FromEventPattern <PropertyChangedEventArgs>(this, "PropertyChanged") .Select(x => x.EventArgs) .Where(x => x.PropertyName == "ViewState") .Select(x => this.ViewState); var normal = pco.Where(x => x == "Normal").Select(x => Unit.Default); var other = pco.Where(x => x != "Normal").Select(x => Unit.Default); Scanner.ObservableKeys .Where(x => !char.IsWhiteSpace(x)) .SkipUntil(normal) .Publish(o => o.Buffer(() => o.Throttle(TimeSpan.FromMilliseconds(500)))) .Select(x => string.Join("", x)) .TakeUntil(other) .Repeat() .Subscribe(x => { AddItem["kodi"] = x; AddItem.Execute(null); }); }
public FeedHandlerConfigWindowViewModel(LogViewer logViewer) { AddItem = ReactiveCommand.Create(() => Feeds.Add( new FeedHandlerConfig { CheckEveryMinutes = 15, Regex = ".*" })); DelItem = ReactiveCommand.Create <string>(url => Feeds.Remove(Feeds.First(f => f.Url == url))); SaveItems = ReactiveCommand.Create(async() => { await Helpers.SaveConfigFile <FeedHandler>(Feeds.ToList()); CloseWindow.OnNext(true); }); Cancel = ReactiveCommand.Create(() => CloseWindow.OnNext(false)); ViewLogs = ReactiveCommand.Create(async() => { if (Application.Current.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) { var window = new Window { Height = 400, Width = 1200, Content = logViewer }; await window.ShowDialog(desktop.MainWindow); } }); var config = Helpers.GetConfig <FeedHandler, List <FeedHandlerConfig> >(); if (config.Count == 0) { AddItem.Execute().Subscribe(); } else { config.ForEach(c => Feeds.Add(c)); } }