예제 #1
0
        public TabsVM([NotNull] Tabs tabs)
        {
            try
            {
                SessionCount = tabs.SessionCount;
                Sessions     = tabs.Sessions.Select(s => new SessionVM(s)).ToList();
                Ok           = CreateCommand(OkExec);
                IsOn         = RestoreTabs.GetIsOn();
                this.WhenAnyValue(v => v.IsOn).Skip(1)
                .Delay(TimeSpan.FromMilliseconds(100))
                .Throttle(TimeSpan.FromMilliseconds(100))
                .ObserveOn(dispatcher)
                .Subscribe(RestoreTabs.SetIsOn);
                HasRestoreTabs = Sessions?.Count > 0;
                if (!HasRestoreTabs)
                {
                    HasHistory = true;
                }

                this.WhenAnyValue(v => v.HistorySearch).Skip(1).Subscribe(s => History.Reset());
                History = history.CreateDerivedCollection(t => t, HistoryFilter, HistoryOrder);
                LoadHistory();
            }
            catch (Exception ex)
            {
                AcadLib.Logger.Log.Error(ex, "RestoreTabs.TabsVM");
            }
        }
예제 #2
0
파일: TabsVM.cs 프로젝트: vildar82/AcadLib
        public TabsVM([NotNull] Tabs tabs)
        {
            try
            {
                SessionCount = tabs.SessionCount;
                Sessions     = tabs.Sessions.Select(s => new SessionVM(s)).ToList();
                Ok           = CreateCommand(OkExec);
                IsOn         = RestoreTabs.GetIsOn();
                this.WhenAnyValue(v => v.IsOn).Skip(1)
                .Delay(TimeSpan.FromMilliseconds(100))
                .Throttle(TimeSpan.FromMilliseconds(100))
                .ObserveOn(dispatcher)
                .Subscribe(RestoreTabs.SetIsOn);
                HasRestoreTabs = Sessions?.Count > 0;
                if (!HasRestoreTabs)
                {
                    HasHistory = true;
                }

                var searchObs = this.WhenAnyValue(v => v.HistorySearch).Skip(1);
                historySrc.Connect()
                .Sort(SortExpressionComparer <TabVM> .Ascending(s => s.Start))
                .AutoRefreshOnObservable(c => searchObs)
                .Filter(HistoryFilter)
                .ObserveOnDispatcher()
                .Bind(out var data)
                .Subscribe();
                History = data;

                LoadHistory();
            }
            catch (Exception ex)
            {
                AcadLib.Logger.Log.Error(ex, "RestoreTabs.TabsVM");
            }
        }