public void HandleButton(object sender, EventArgs e)
        {
            var solutionUpdateViewModel       = new SolutionUpdateViewModel();
            var addHeaderToAllProjectsCommand = new AddLicenseHeaderToAllFilesInSolutionCommand(_licenseReplacer, solutionUpdateViewModel);
            var buttonThreadWorker            = new SolutionLevelButtonThreadWorker(addHeaderToAllProjectsCommand);
            var dialog = new SolutionUpdateDialog(solutionUpdateViewModel);


            dialog.Closing     += DialogOnClosing;
            _resharperSuspended = CommandUtility.ExecuteCommandIfExists("ReSharper_Suspend", _dte2);
            Dispatcher uiDispatcher = Dispatcher.CurrentDispatcher;

            buttonThreadWorker.ThreadDone += (o, args) =>
            {
                uiDispatcher.BeginInvoke(new Action(() => { dialog.Close(); }));
                ResumeResharper();
            };

            _solutionUpdateThread = new System.Threading.Thread(buttonThreadWorker.Run)
            {
                IsBackground = true
            };
            _solutionUpdateThread.Start(_dte2.Solution);

            dialog.ShowModal();
        }
示例#2
0
        public void HandleButton(object sender, EventArgs e)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            var solutionUpdateViewModel = new SolutionUpdateViewModel();

            _dialog = new SolutionUpdateDialog(solutionUpdateViewModel)
            {
                WindowStartupLocation = WindowStartupLocation.CenterOwner
            };
            _dialog.Closing += DialogOnClosing;
            ThreadHelper.ThrowIfNotOnUIThread();
            _reSharperSuspended = CommandUtility.TryExecuteCommand("ReSharper_Suspend", _dte2);

            Task.Run(() => HandleButtonInternalAsync(_dte2.Solution, _handler, solutionUpdateViewModel)).FireAndForget();
            Mouse.OverrideCursor = null;
            _dialog.ShowModal();
        }
 public SolutionUpdateDialog(SolutionUpdateViewModel solutionUpdateViewModel)
 {
     InitializeComponent();
     DataContext = solutionUpdateViewModel;
     ((SolutionUpdateViewModel)DataContext).PropertyChanged += OnViewModelUpdated;
 }
 public AddLicenseHeaderToAllProjectsCommand(LicenseHeaderReplacer licenseReplacer, IDefaultLicenseHeaderPage licenseHeaderPage, SolutionUpdateViewModel solutionUpdateViewModel)
 {
     _licenseHeaderPage       = licenseHeaderPage;
     _licenseReplacer         = licenseReplacer;
     _solutionUpdateViewModel = solutionUpdateViewModel;
 }
 public SolutionUpdateDialog(SolutionUpdateViewModel solutionUpdateViewModel)
 {
     InitializeComponent();
     this.DataContext = solutionUpdateViewModel;
 }
示例#6
0
        private async Task AddLicenseHeaderToProjectsAsync(CancellationToken cancellationToken, ICollection <Project> projectsInSolution, SolutionUpdateViewModel viewModel)
        {
            viewModel.ProcessedProjectCount = 0;
            viewModel.ProjectCount          = projectsInSolution.Count;
            var addAllLicenseHeadersCommand = new AddLicenseHeaderToAllFilesInProjectHelper(cancellationToken, _licenseHeaderExtension, viewModel);

            foreach (var project in projectsInSolution)
            {
                await addAllLicenseHeadersCommand.RemoveOrReplaceHeadersAsync(project);
                await IncrementProjectCountAsync(viewModel).ConfigureAwait(true);
            }
        }
 public AddLicenseHeaderToAllFilesInSolutionCommand(LicenseHeaderReplacer licenseReplacer, SolutionUpdateViewModel solutionUpdateViewModel)
 {
     _licenseReplacer         = licenseReplacer;
     _solutionUpdateViewModel = solutionUpdateViewModel;
 }