/// <summary>
 /// Initializes an instance of <seealso cref="LogsViewerViewModel"/> class.
 /// </summary>
 public LogsViewerViewModel()
 {
     _dataSource       = new Lazy <LoggingDataSource>(CreateDataSource);
     RefreshCommand    = new ProtectedCommand(OnRefreshCommand);
     LogItemCollection = new ListCollectionView(_logs);
     LogItemCollection.GroupDescriptions.Add(new PropertyGroupDescription(nameof(LogItem.Date)));
     CancelRequestCommand    = new ProtectedCommand(CancelRequest);
     SimpleTextSearchCommand = new ProtectedCommand(() =>
     {
         EventsReporterWrapper.ReportEvent(LogsViewerSimpleTextSearchEvent.Create());
         ErrorHandlerUtils.HandleAsyncExceptions(ReloadAsync);
     });
     FilterSwitchCommand         = new ProtectedCommand(SwapFilter);
     SubmitAdvancedFilterCommand = new ProtectedCommand(() =>
     {
         EventsReporterWrapper.ReportEvent(LogsViewerAdvancedFilterEvent.Create());
         ErrorHandlerUtils.HandleAsyncExceptions(ReloadAsync);
     });
     AdvancedFilterHelpCommand = new ProtectedCommand(ShowAdvancedFilterHelp);
     DateTimePickerModel       = new DateTimePickerViewModel(
         TimeZoneInfo.Local, DateTime.UtcNow, isDescendingOrder: true);
     DateTimePickerModel.DateTimeFilterChange += (sender, e) => ErrorHandlerUtils.HandleAsyncExceptions(ReloadAsync);
     PropertyChanged     += OnPropertyChanged;
     ResourceTypeSelector = new ResourceTypeMenuViewModel(_dataSource);
     ResourceTypeSelector.PropertyChanged += OnPropertyChanged;
     OnDetailTreeNodeFilterCommand         = new ProtectedCommand <ObjectNodeTree>(FilterOnTreeNodeValue);
     OnAutoReloadCommand = new ProtectedCommand(AutoReload);
 }
예제 #2
0
        /// <summary>
        /// Initializes an instance of <seealso cref="LogsViewerViewModel"/> class.
        /// </summary>
        /// <param name="toolWindowIdNumber"></param>
        public LogsViewerViewModel(int toolWindowIdNumber)
        {
            IsVisibleUnbound    = true;
            _package            = GoogleCloudExtensionPackage.Instance;
            _toolWindowIdNumber = toolWindowIdNumber;
            RefreshCommand      = new ProtectedCommand(OnRefreshCommand);
            LogItemCollection   = new ListCollectionView(_logs);
            LogItemCollection.GroupDescriptions.Add(new PropertyGroupDescription(nameof(LogItem.Date)));
            CancelRequestCommand    = new ProtectedCommand(CancelRequest);
            SimpleTextSearchCommand = new ProtectedCommand(() =>
            {
                EventsReporterWrapper.ReportEvent(LogsViewerSimpleTextSearchEvent.Create());
                AsyncAction = new AsyncProperty(ReloadAsync());
            });
            FilterSwitchCommand         = new ProtectedCommand(SwapFilter);
            SubmitAdvancedFilterCommand = new ProtectedCommand(() =>
            {
                EventsReporterWrapper.ReportEvent(LogsViewerAdvancedFilterEvent.Create());
                AsyncAction = new AsyncProperty(ReloadAsync());
            });
            AdvancedFilterHelpCommand = new ProtectedCommand(ShowAdvancedFilterHelp);
            DateTimePickerModel       = new DateTimePickerViewModel(
                TimeZoneInfo.Local, DateTime.UtcNow, isDescendingOrder: true);
            DateTimePickerModel.DateTimeFilterChange += (sender, e) => AsyncAction = new AsyncProperty(ReloadAsync());
            ResourceTypeSelector = new ResourceTypeMenuViewModel(() => DataSource);
            ResourceTypeSelector.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == null ||
                    args.PropertyName == nameof(ResourceTypeMenuViewModel.SelectedMenuItem))
                {
                    LogIdList   = null;
                    AsyncAction = new AsyncProperty(ReloadAsync());
                }
            };

            OnDetailTreeNodeFilterCommand = new ProtectedAsyncCommand <ObjectNodeTree>(FilterOnTreeNodeValueAsync);
            OnAutoReloadCommand           = new ProtectedCommand(AutoReload);
        }