コード例 #1
0
        public VsixShellViewModel(ResourceManager resourceManager)
        {
            Contract.Requires(resourceManager != null);

            _selectedCodeGeneratorsChangedThrottle = new DispatcherThrottle(() => OnPropertyChanged(nameof(SelectedCodeGenerators)));
            _resourceManager = resourceManager;
            _resourceManager.SelectedEntities.CollectionChanged += (_, __) => _selectedCodeGeneratorsChangedThrottle.Tick();
            _resourceManager.Loaded += (_, __) => _selectedCodeGeneratorsChangedThrottle.Tick();
        }
コード例 #2
0
        private CodeReferenceConfiguration CreateCodeReferenceConfiguration()
        {
            _codeReferences = GetValue(default(CodeReferenceConfiguration)) ?? CodeReferenceConfiguration.Default;
            _codeReferences.ItemPropertyChanged += (_, __) => _codeReferencesChangeThrottle.Tick();

            return(_codeReferences);
        }
コード例 #3
0
        public ResourceViewModel([NotNull] ResourceManager resourceManager, [NotNull] Configuration configuration, [NotNull] ISourceFilesProvider sourceFilesProvider, [NotNull] CodeReferenceTracker codeReferenceTracker, [NotNull] ITracer tracer, [NotNull] PerformanceTracer performanceTracer)
        {
            Contract.Requires(resourceManager != null);
            Contract.Requires(configuration != null);
            Contract.Requires(sourceFilesProvider != null);
            Contract.Requires(codeReferenceTracker != null);
            Contract.Requires(tracer != null);
            Contract.Requires(performanceTracer != null);

            _resourceManager      = resourceManager;
            _configuration        = configuration;
            _sourceFilesProvider  = sourceFilesProvider;
            _codeReferenceTracker = codeReferenceTracker;
            _tracer            = tracer;
            _performanceTracer = performanceTracer;

            _resourceTableEntiyCountUpdateThrottle = new DispatcherThrottle(() => OnPropertyChanged(nameof(ResourceTableEntryCount)));

            _resourceTableEntries = _selectedEntities.ObservableSelectMany(entity => entity.Entries);
            _resourceTableEntries.CollectionChanged += (_, __) => _resourceTableEntiyCountUpdateThrottle.Tick();

            _restartFindCodeReferencesThrottle = new DispatcherThrottle(DispatcherPriority.ContextIdle, () => BeginFindCodeReferences(sourceFilesProvider.SourceFiles));

            resourceManager.TableEntries.CollectionChanged += (_, __) => _restartFindCodeReferencesThrottle.Tick();

            resourceManager.LanguageChanged += ResourceManager_LanguageChanged;
        }
コード例 #4
0
        private MoveToResourceConfiguration CreateMoveToResourceConfiguration(MoveToResourceConfiguration current)
        {
            _moveToResources = current ?? MoveToResourceConfiguration.Default;
            _moveToResources.ItemPropertyChanged += (_, __) => _moveToResourcesChangeThrottle.Tick();

            return(_moveToResources);
        }
        private DataGridColumn CreateColumn([NotNull] ProjectPropertyName projectPropertyName)
        {
            Contract.Requires(projectPropertyName != null);

            var column = new DataGridTextColumn
            {
                Header = new TextBlock {
                    Text = projectPropertyName.DisplayName
                },
                Width   = new DataGridLength(1, DataGridLengthUnitType.Star),
                Binding = new Binding(@"PropertyValue[" + projectPropertyName.Name + @"]")
                {
                    Mode = BindingMode.TwoWay
                },
            };

            column.EnableMultilineEditing();

            column.SetValue(DataGridFilterColumn.TemplateProperty, AssociatedObject?.FindResource(ResourceKeys.MultipleChoiceFilterTemplate));
            column.SetValue(ProjectPropertyNameProperty, projectPropertyName);
            column.SetValue(PropertyNameProperty, projectPropertyName.Name);

            _columnsCreatedThrottle.Tick();

            return(column);
        }
コード例 #6
0
        private void SelectedEntities_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            _updateThrottle.Tick();

            IsLoading = true;

            Dispatcher.ProcessMessages(DispatcherPriority.Render);
        }
コード例 #7
0
        private void SetCodeProvider(CodeGenerator codeGenerator)
        {
            _resourceManager.SelectedEntities
            .Select(x => x.NeutralProjectFile)
            .OfType <DteProjectFile>()
            .ForEach(pf => pf.CodeGenerator = codeGenerator);

            _selectedCodeGeneratorsChangedThrottle.Tick();
        }
コード例 #8
0
        private MoveToResourceConfiguration LoadMoveToResourceConfiguration(MoveToResourceConfiguration current)
        {
            Contract.Ensures(Contract.Result <MoveToResourceConfiguration>() != null);

            _moveToResources = current ?? MoveToResourceConfiguration.Default;
            _moveToResources.ItemPropertyChanged += (_, __) => _moveToResourcesChangeThrottle.Tick();

            return(_moveToResources);
        }
コード例 #9
0
        private CodeReferenceConfiguration LoadCodeReferenceConfiguration()
        {
            Contract.Ensures(Contract.Result <CodeReferenceConfiguration>() != null);

            // ReSharper disable once ExplicitCallerInfoArgument
            _codeReferences = GetValue(default(CodeReferenceConfiguration), nameof(CodeReferences)) ?? CodeReferenceConfiguration.Default;
            _codeReferences.ItemPropertyChanged += (_, __) => _codeReferencesChangeThrottle.Tick();

            return(_codeReferences);
        }
コード例 #10
0
        private SourceFileExclusionFilterConfiguration LoadSourceFileExclusionFilterConfiguration()
        {
            Contract.Ensures(Contract.Result <SourceFileExclusionFilterConfiguration>() != null);

            // ReSharper disable once ExplicitCallerInfoArgument
            _sourceFileExclusionFilters = GetValue(default(SourceFileExclusionFilterConfiguration), nameof(SourceFileExclusionFilters)) ?? SourceFileExclusionFilterConfiguration.Default;
            _sourceFileExclusionFilters.ItemPropertyChanged += (_, __) => _sourceFileExclusionFiltersChangeThrottle.Tick();

            return(_sourceFileExclusionFilters);
        }
コード例 #11
0
        public void Enqueue(IEnumerable <EnvDTE.ProjectItem> projectItems)
        {
            if (projectItems == null)
            {
                return;
            }

            _projectItems.AddRange(projectItems);

            _throttle.Tick();
        }
コード例 #12
0
        private void SelectedEntities_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            _updateThrottle.Tick();

            IsLoading = true;

            // using (_performanceTracer.Start("Dispatcher.ProcessMessages"))
            {
                Dispatcher.ProcessMessages(DispatcherPriority.Render);
            }
        }
コード例 #13
0
        private void DisplaySettings_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == nameof(DisplaySettings.StyleWindowTitleBar))
            {
                if (!DisplaySettingsPanel.CurrentDisplaySettings.StyleWindowTitleBar)
                {
                    restartNotificationThrottle.Tick();
                    return;
                }

                UpdateWindowStyle();
            }
        }
        private void Initialize()
        {
            if (_projectPropertyNames == null)
            {
                return;
            }

            var dataGrid = AssociatedObject;

            if (dataGrid == null)
            {
                return;
            }

            dataGrid.Columns.AddRange(_projectPropertyNames.OfType <ProjectPropertyName>().Select(CreateColumn));
            dataGrid.ColumnDisplayIndexChanged += (_, __) => _displayIndexChangedThrottle.Tick();
        }
コード例 #15
0
        public void Reload(bool forceFindCodeReferences)
        {
            try
            {
                using (_performanceTracer.Start("ResourceManager.Load"))
                {
                    var sourceFiles = _sourceFilesProvider.SourceFiles;

                    _codeReferenceTracker.StopFind();

                    if (_resourceManager.Reload(sourceFiles, _configuration.DuplicateKeyHandling) || forceFindCodeReferences)
                    {
                        _restartFindCodeReferencesThrottle.Tick();
                    }

                    _configuration.Reload();
                }
            }
            catch (Exception ex)
            {
                _tracer.TraceError(ex.ToString());
            }
        }
コード例 #16
0
 private void Solution_Changed(string action)
 {
     _tracer.WriteLine(action);
     _deferredUpdateThrottle.Tick();
 }
コード例 #17
0
 private void Comments_ValueChanged(object sender, EventArgs e)
 {
     _deferredCommentChangedThrottle.Tick();
 }
コード例 #18
0
 private void SaveChanges()
 {
     _deferredSaveThrottle.Tick();
 }
コード例 #19
0
        protected override void OnAttached()
        {
            base.OnAttached();

            var listBox = AssociatedObject;

            if (listBox == null)
            {
                return;
            }

            listBox.SelectAll();

            listBox.SelectionChanged += ListBox_SelectionChanged;
            ((INotifyCollectionChanged)listBox.Items).CollectionChanged += (_, __) => _collectionChangedThrottle.Tick();

            _performanceTracer = listBox.GetExportProvider().GetExportedValue <PerformanceTracer>();
        }
コード例 #20
0
 private void DataGrid_ColumnDisplayIndexChanged(object sender, DataGridColumnEventArgs e)
 {
     _updateColumnGripperToolTipVisibilityThrottle.Tick();
 }
コード例 #21
0
        protected override void OnAttached()
        {
            base.OnAttached();

            var listBox = AssociatedObject;

            if (listBox == null)
            {
                return;
            }

            listBox.SelectAll();

            listBox.SelectionChanged += ListBox_SelectionChanged;
            ((INotifyCollectionChanged)listBox.Items).CollectionChanged += (_, __) => _collectionChangedThrottle.Tick();
        }
コード例 #22
0
 private void Solution_Changed()
 {
     _deferredUpdateThrottle.Tick();
 }