コード例 #1
0
        public AsyncDataGridColumn(
            AsyncDataGridColumnsViewModel columns,
            DataColumnView columnModel,
            AsyncDataViewModel adv,
            bool isDisconnected)
        {
            Columns          = columns;
            this.columnModel = columnModel;
            this.adv         = adv;
            IsDisconnected   = isDisconnected;

            isInitializing = true;
            if (isDisconnected)
            {
                ModelColumnIndex        = -1;
                ModelVisibleColumnIndex = -1;
                IsVisible     = true;
                Width         = 45.0;
                TextAlignment = TextAlignment.Right;
            }

            ColumnName    = columnModel.Name;
            TextAlignment = TextAlignment.Left;

            CoerceValue(WidthProperty);
            RefreshViewModelFromModel();
            isInitializing = false;
        }
コード例 #2
0
        public ColumnChooser(
            ReadOnlyObservableCollection <AsyncDataGridColumn> columns,
            AsyncDataViewModel viewModel)
        {
            if (columns == null)
            {
                throw new ArgumentNullException(nameof(columns));
            }

            this.columns = columns;

            ViewModel     = viewModel;
            sortedColumns = new AsyncDataGridColumn[columns.Count];
            this.columns.CopyTo(sortedColumns, 0);
            Array.Sort(sortedColumns, CompareColumnNames);

            for (int i = 0; i < sortedColumns.Length; ++i)
            {
                Items.Insert(i, CreateContainer(sortedColumns[i]));
            }

            ((INotifyCollectionChanged)this.columns).CollectionChanged += ColumnsCollectionChangedHandler;

            CommandBindings.Add(
                new CommandBinding(ApplicationCommands.Close, CloseCommandExecuted));
        }
コード例 #3
0
 public void Foo()
 {
     var dataTable        = new DataTable("Foo");
     var dataView         = new DataView(dataTable, new DefaultFormatProviderSource());
     var templatePreset   = new AsyncDataViewModelPreset();
     var presetCollection = new AdvmPresetCollection();
     var adv       = new AsyncDataViewModel(dataView, templatePreset, templatePreset, presetCollection);
     var viewModel = new PresetManagerViewModel(adv);
 }
コード例 #4
0
        public AsyncDataGridColumnsViewModel(AsyncDataViewModel model)
        {
            Model = model;

            Columns             = CollectionUtils.InitializeReadOnly(out columns);
            ConfigurableColumns = CollectionUtils.InitializeReadOnly(out configurableColumns);
            VisibleColumns      = CollectionUtils.InitializeReadOnly(out visibleColumns);

            ExpanderHeaderColumn              = new ExpanderHeaderColumn(this, model);
            LeftFreezableAreaSeparatorColumn  = new FreezableAreaSeparatorColumn(this, model);
            RightFreezableAreaSeparatorColumn = new FreezableAreaSeparatorColumn(this, model);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: maxgolov/event-trace-kit
        public void Setup()
        {
            var dataTable = new DataTable("Stub");

            var templatePreset = new AsyncDataViewModelPreset();

            for (int i = 0; i < 8; ++i)
            {
                int columnId = i + 1;

                var preset = new ColumnViewModelPreset {
                    Id        = new Guid($"{columnId:X8}-0000-0000-0000-000000000000"),
                    Name      = $"Column{columnId}",
                    IsVisible = true,
                    Width     = 200
                }.EnsureFrozen();

                var column = DataColumn.Create(x => (x << 16 | columnId));
                column.Id        = preset.Id;
                column.Name      = preset.Name;
                column.IsVisible = preset.IsVisible;
                column.Width     = preset.Width;

                dataTable.Columns.Add(column);

                templatePreset.ConfigurableColumns.Add(preset);
            }

            dataView = new DataView(dataTable, new DefaultFormatProviderSource());

            var defaultPreset    = templatePreset.Clone();
            var presetCollection = new AdvmPresetCollection();

            advModel = new AsyncDataViewModel(
                dataView, templatePreset, defaultPreset, presetCollection);

            presenterViewModel = new AsyncDataGridCellsPresenterViewModel(advModel);

            presenter                = new AsyncDataGridCellsPresenter();
            presenter.ViewModel      = presenterViewModel;
            presenter.VisibleColumns = advModel.GridViewModel.ColumnsModel.VisibleColumns;
            presenter.HorizontalGridLinesThickness = 0;
            presenter.VerticalGridLinesThickness   = 0;
            presenter.AutoScroll = true;
            presenter.Arrange(new Rect(0, 0, 1200, 200));

            while (!advModel.IsReady)
            {
                Dispatcher.CurrentDispatcher.DoEvents();
            }
        }
コード例 #6
0
        public TraceLogToolViewModel(
            ISettingsService settings, ITraceController traceController,
            Func <ISettingsStore, TraceSettingsViewModel> traceSettingsViewModelFactory,
            IVsUIShell uiShell = null)
        {
            this.settings        = settings ?? throw new ArgumentNullException(nameof(settings));
            this.traceController = traceController ?? throw new ArgumentNullException(nameof(traceController));
            this.traceSettingsViewModelFactory = traceSettingsViewModelFactory ??
                                                 throw new ArgumentNullException(nameof(traceSettingsViewModelFactory));
            this.uiShell = uiShell;

            settings.SettingsLayerChanged += OnSettingsLayerChanged;

            traceController.SessionStarting += OnSessionStarting;
            traceController.SessionStarted  += OnSessionStarted;
            traceController.SessionStopped  += OnSessionStopped;

            var tableTuple     = new GenericEventsViewModelSource().CreateTable(this);
            var dataTable      = tableTuple.Item1;
            var templatePreset = tableTuple.Item2;

            var defaultPreset = GenericEventsViewModelSource.CreateDefaultPreset();
            var viewPresets   = settings.GetGlobalStore().GetViewPresets(SettingsSerializer.Mapper);

            viewPresets.BuiltInPresets.Add(defaultPreset);

            var preset = viewPresets.TryGetPersistedPresetByName(defaultPreset.Name);

            if (preset == null)
            {
                preset = defaultPreset;
            }

            EventsDataView = new TraceEventsDataView(dataTable, this);
            AdvModel       = new AsyncDataViewModel(
                EventsDataView, templatePreset, preset, viewPresets);

            GridModel = AdvModel.GridViewModel;
            AdvModel.PresetChanged += OnViewPresetChanged;
            BindingOperations.SetBinding(GridModel, AsyncDataGridViewModel.AutoScrollProperty, new Binding(nameof(AutoScroll))
            {
                Source = this
            });

            updateStatsTimer          = new DispatcherTimer(DispatcherPriority.Background);
            updateStatsTimer.Interval = TimeSpan.FromSeconds(1);
            updateStatsTimer.Tick    += (s, e) => UpdateStats();

            LoadGlobalSettings();
            LoadAmbientSettings();
        }
コード例 #7
0
        public AsyncDataGridTestViewModel()
        {
            StartCommand          = new AsyncDelegateCommand(Start, CanStart);
            StopCommand           = new AsyncDelegateCommand(Stop, CanStop);
            ClearCommand          = new AsyncDelegateCommand(Clear);
            OpenViewEditorCommand = new AsyncDelegateCommand(OpenViewEditor);

            SelectableBrushes = new ObservableCollection <BrushEntry>();
            foreach (var property in typeof(Brushes).GetProperties(BindingFlags.Static | BindingFlags.Public).OrderBy(x => x.Name))
            {
                var brush = (Brush)property.GetValue(null);

                BrushEntry.KnownBrushes[brush] = property.Name;
                SelectableBrushes.Add(new BrushEntry(property.Name, brush));
            }

            PropertyEditors = new ObservableCollection <PropertyEditor> {
                new SliderPropertyEditor(nameof(RowFontSize), x => RowFontSize = x),
                new BrushPropertyEditor(nameof(Background), SelectableBrushes, x => Background       = x),
                new BrushPropertyEditor(nameof(RowForeground), SelectableBrushes, x => RowForeground = x),
                new BrushPropertyEditor(nameof(RowBackground), SelectableBrushes, x => RowBackground = x),
                new BrushPropertyEditor(nameof(RowBackground) + "Alt", SelectableBrushes, x => AlternatingRowBackground = x),
                new BrushPropertyEditor(nameof(RowSelectionForeground), SelectableBrushes, x => RowSelectionForeground  = x),
                new BrushPropertyEditor(nameof(RowSelectionBackground), SelectableBrushes, x => RowSelectionBackground  = x),
                new BrushPropertyEditor(nameof(RowInactiveSelectionForeground), SelectableBrushes, x => RowInactiveSelectionForeground = x),
                new BrushPropertyEditor(nameof(RowInactiveSelectionBackground), SelectableBrushes, x => RowInactiveSelectionBackground = x),
                new BrushPropertyEditor(nameof(RowFocusBorderBrush), SelectableBrushes, x => RowFocusBorderBrush = x)
            };

            RowFontFamily                  = new FontFamily("Consolas");
            RowFontSize                    = (double)new FontSizeConverter().ConvertFromInvariantString("9pt");
            RowForeground                  = Brushes.Black;
            Background                     = Brushes.White;
            RowBackground                  = Brushes.WhiteSmoke;
            AlternatingRowBackground       = Brushes.AliceBlue;
            RowSelectionForeground         = Brushes.White;
            RowSelectionBackground         = Brushes.DarkBlue;
            RowInactiveSelectionForeground = Brushes.DimGray;
            RowInactiveSelectionBackground = Brushes.LightGray;
            RowFocusBorderBrush            = Brushes.GreenYellow;

            adv       = CreateModel(out dataView);
            GridModel = adv.GridViewModel;

            RowCount = 10;
        }
コード例 #8
0
        public PresetManagerViewModel(AsyncDataViewModel advModel)
        {
            TemplateColumns = CollectionUtils.InitializeReadOnly(out templateColumns);
            PresetColumns   = CollectionUtils.InitializeReadOnly(out presetColumns);

            leftFreezableAreaSeparatorColumn = new PresetManagerColumnViewModel(
                this, PresetManagerColumnType.LeftFreezableAreaSeparator);
            rightFreezableAreaSeparatorColumn = new PresetManagerColumnViewModel(
                this, PresetManagerColumnType.RightFreezableAreaSeparator);

            PresetDropDownMenu = new HeaderDropDownMenu();
            BindingOperations.SetBinding(PresetDropDownMenu, HeaderDropDownMenu.HeaderProperty, new Binding {
                Source = this,
                Path   = new PropertyPath(MangledPresetNameProperty),
                Mode   = BindingMode.OneWay
            });

            AdvViewModel       = advModel;
            IsDialogStateDirty = false;
            isApplyingChanges  = false;
        }
コード例 #9
0
        public AsyncDataGridCellsPresenterViewModel(AsyncDataViewModel advModel)
        {
            this.advModel = advModel;

            RowSelection = new AsyncDataGridRowSelection(this);
        }
コード例 #10
0
 public FreezableAreaSeparatorColumn(
     AsyncDataGridColumnsViewModel columns, AsyncDataViewModel adv)
     : base(columns, CreateColumnView(), adv, true)
 {
 }
コード例 #11
0
 public AsyncDataGridViewModel(AsyncDataViewModel advModel)
 {
     this.advModel  = advModel;
     ColumnsModel   = new AsyncDataGridColumnsViewModel(advModel);
     CellsPresenter = new AsyncDataGridCellsPresenterViewModel(advModel);
 }
コード例 #12
0
 public ExpanderHeaderColumn(
     AsyncDataGridColumnsViewModel columns, AsyncDataViewModel adv)
     : base(columns, CreateColumnView(), adv, true)
 {
 }