Exemple #1
0
        public Solution([NotNull] ITracer tracer, [NotNull] IVsServiceProvider serviceProvider, [NotNull] PerformanceTracer performanceTracer)
        {
            Contract.Requires(tracer != null);
            Contract.Requires(serviceProvider != null);
            Contract.Requires(performanceTracer != null);

            _deferredUpdateThrottle = new DispatcherThrottle(DispatcherPriority.ApplicationIdle, Update);

            _tracer            = tracer;
            _serviceProvider   = serviceProvider;
            _performanceTracer = performanceTracer;

            _specificProjectConfigurations = _projects.ObservableSelectMany(prj => prj.SpecificProjectConfigurations);
            _projectConfigurations         = _projects.ObservableSelectMany(prj => prj.ProjectConfigurations);

            _solutionEvents = Dte?.Events?.SolutionEvents;
            if (_solutionEvents != null)
            {
                _solutionEvents.Opened         += () => Solution_Changed("Solution opened");
                _solutionEvents.AfterClosing   += () => Solution_Changed("Solution after closing");
                _solutionEvents.ProjectAdded   += _ => Solution_Changed("Project added");
                _solutionEvents.ProjectRemoved += _ => Solution_Changed("Project removed");
                _solutionEvents.ProjectRenamed += (_, __) => Solution_Changed("Project renamed");
            }

            Update();
        }
Exemple #2
0
        public Solution(ITracer tracer, IVsServiceProvider serviceProvider)
        {
            Contract.Requires(tracer != null);
            Contract.Requires(serviceProvider != null);

            _deferredUpdateThrottle = new DispatcherThrottle(DispatcherPriority.ContextIdle, Update);

            _tracer          = tracer;
            _serviceProvider = serviceProvider;

            _specificProjectConfigurations = Projects.ObservableSelectMany(prj => prj.SpecificProjectConfigurations);
            _solutionContexts             = SolutionConfigurations.ObservableSelectMany(cfg => cfg.Contexts);
            _defaultProjectConfigurations = Projects.ObservableSelect(prj => prj.DefaultProjectConfiguration);
            _projectConfigurations        = new ObservableCompositeCollection <ProjectConfiguration>(_defaultProjectConfigurations, _specificProjectConfigurations);

            _solutionEvents = Dte?.Events?.SolutionEvents;
            if (_solutionEvents != null)
            {
                _solutionEvents.Opened         += Solution_Changed;
                _solutionEvents.AfterClosing   += Solution_Changed;
                _solutionEvents.ProjectAdded   += _ => Solution_Changed();
                _solutionEvents.ProjectRemoved += _ => Solution_Changed();
                _solutionEvents.ProjectRenamed += (_, __) => Solution_Changed();
            }

            Update();
        }
Exemple #3
0
        protected Configuration(ITracer tracer)
            : base(tracer)
        {
            Contract.Requires(tracer != null);

            _codeReferencesChangeThrottle = new DispatcherThrottle(DispatcherPriority.ContextIdle, PersistCodeReferences);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ResourceTableEntry" /> class.
        /// </summary>
        /// <param name="container">The owner.</param>
        /// <param name="key">The resource key.</param>
        /// <param name="index">The original index of the resource in the file.</param>
        /// <param name="languages">The localized values.</param>
        internal ResourceTableEntry([NotNull] ResourceEntity container, [NotNull] string key, double index, [NotNull] IDictionary <CultureKey, ResourceLanguage> languages)
        {
            Contract.Requires(container != null);
            Contract.Requires(!string.IsNullOrEmpty(key));
            Contract.Requires(languages != null);
            Contract.Requires(languages.Any());

            _container = container;
            _key       = key;
            _index     = index;
            _languages = languages;

            _deferredValuesChangedThrottle  = new DispatcherThrottle(() => OnPropertyChanged(nameof(Values)));
            _deferredCommentChangedThrottle = new DispatcherThrottle(() => OnPropertyChanged(nameof(Comment)));

            _values = new ResourceTableValues <string>(_languages, lang => lang.GetValue(_key), (lang, value) => lang.SetValue(_key, value));
            _values.ValueChanged += Values_ValueChanged;

            _comments = new ResourceTableValues <string>(_languages, lang => lang.GetComment(_key), (lang, value) => lang.SetComment(_key, value));
            _comments.ValueChanged += Comments_ValueChanged;

            _fileExists = new ResourceTableValues <bool>(_languages, lang => true, (lang, value) => false);

            _snapshotValues   = new ResourceTableValues <string>(_languages, lang => _snapshot?.GetValueOrDefault(lang.CultureKey)?.Text, (lang, value) => false);
            _snapshotComments = new ResourceTableValues <string>(_languages, lang => _snapshot?.GetValueOrDefault(lang.CultureKey)?.Comment, (lang, value) => false);

            _valueAnnotations   = new ResourceTableValues <ICollection <string> >(_languages, GetValueAnnotations, (lang, value) => false);
            _commentAnnotations = new ResourceTableValues <ICollection <string> >(_languages, GetCommentAnnotations, (lang, value) => false);

            Contract.Assume(languages.Any());
            _neutralLanguage = languages.First().Value;
            Contract.Assume(_neutralLanguage != null);
        }
Exemple #5
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;
        }
Exemple #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Map" /> class.
        /// </summary>
        public Map()
        {
            Focusable       = false;
            ClipToBounds    = true;
            _updateThrottle = new DispatcherThrottle(DispatcherPriority.Background, Update);

            Loaded += (_, __) => ViewportSize = (Vector)this.GetPhysicalPixelSize() * 512.0;
        }
Exemple #7
0
        public ShellViewModel(ResourceManager resourceManager)
        {
            Contract.Requires(resourceManager != null);

            _updateThrottle = new DispatcherThrottle(DispatcherPriority.Background, () => IsLoading = false);

            resourceManager.SelectedEntities.CollectionChanged += SelectedEntities_CollectionChanged;
        }
Exemple #8
0
        protected Configuration([NotNull] ITracer tracer)
            : base(tracer)
        {
            Contract.Requires(tracer != null);

            _codeReferencesChangeThrottle             = new DispatcherThrottle(DispatcherPriority.ContextIdle, PersistCodeReferences);
            _sourceFileExclusionFiltersChangeThrottle = new DispatcherThrottle(DispatcherPriority.ContextIdle, PersistSourceFileExclusionFilters);
        }
Exemple #9
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();
        }
        public DteConfiguration([NotNull] DteSolution solution, [NotNull] ITracer tracer)
            : base(tracer)
        {
            Contract.Requires(solution != null);
            Contract.Requires(tracer != null);

            _solution = solution;
            _moveToResourcesChangeThrottle = new DispatcherThrottle(DispatcherPriority.ContextIdle, PersistMoveToResources);
        }
        public ShellViewModel([NotNull] ResourceViewModel resourceViewModel, [NotNull] PerformanceTracer performanceTracer)
        {
            Contract.Requires(resourceViewModel != null);
            Contract.Requires(performanceTracer != null);

            _performanceTracer = performanceTracer;
            _updateThrottle    = new DispatcherThrottle(DispatcherPriority.Background, () => IsLoading = false);

            resourceViewModel.SelectedEntities.CollectionChanged += SelectedEntities_CollectionChanged;
        }
        public ProjectFile([NotNull] Solution solution, [NotNull] Project project)
        {
            Contract.Requires(solution != null);
            Contract.Requires(project != null);

            _deferredSaveThrottle = new DispatcherThrottle(SaveProjectFile);
            _solution             = solution;
            _project = project;

            FileTime = File.GetLastWriteTime(project.FullName);

            _projectGuid = GetProjectGuid(solution, project.ProjectHierarchy);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ListBoxSelectAllBehavior"/> class.
 /// </summary>
 public ListBoxSelectAllBehavior()
 {
     _collectionChangedThrottle = new DispatcherThrottle(ListBox_CollectionChanged);
 }
Exemple #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DataGridExtensions.Behaviors.ExtendedStarSizeBehavior" /> class.
 /// </summary>
 public ExtendedStarSizeBehavior()
 {
     _updateColumnGripperToolTipVisibilityThrottle = new DispatcherThrottle(DispatcherPriority.Background, UpdateColumnGripperToolTipVisibility);
 }
Exemple #15
0
 public CustomToolRunner()
 {
     _throttle = new DispatcherThrottle(RunCustomTool);
 }
 public void Test1()
 {
     _throttle = new DispatcherThrottle(Test1);
     Assert.True(_throttle.GetType().Assembly == typeof(UnitTest1).Assembly);
 }
 public PropertiesColumnsManagerBehavior()
 {
     _columnsCreatedThrottle      = new DispatcherThrottle(DispatcherPriority.Background, ColumnsCreated);
     _displayIndexChangedThrottle = new DispatcherThrottle(DispatcherPriority.Background, ColumnsDisplayIndexChanged);
 }
Exemple #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VisualCompositionBehavior{T}"/> class.
 /// </summary>
 protected VisualCompositionBehavior()
 {
     _deferredUpdateThrottle = new DispatcherThrottle(DispatcherPriority.Background, Update);
 }