public ExtensionLogger(Func<IVsActivityLog> logProvider, IVsStatusbar statusBar) { Ensure.That(() => logProvider).IsNotNull(); Ensure.That(() => statusBar).IsNotNull(); _logProvider = logProvider; _statusBar = statusBar; }
protected override void OnCreate() { base.OnCreate(); _site = (IServiceProvider)this; _pyService = _site.GetPythonToolsService(); #if DEV14_OR_LATER // TODO: Get PYEnvironment added to image list BitmapImageMoniker = KnownMonikers.DockPanel; #else BitmapResourceID = PythonConstants.ResourceIdForReplImages; BitmapIndex = 0; #endif Caption = SR.GetString(SR.Environments); _service = _site.GetComponentModel().GetService<IInterpreterOptionsService>(); _outputWindow = OutputWindowRedirector.GetGeneral(_site); Debug.Assert(_outputWindow != null); _statusBar = _site.GetService(typeof(SVsStatusbar)) as IVsStatusbar; var list = new ToolWindow(); list.ViewCreated += List_ViewCreated; list.CommandBindings.Add(new CommandBinding( EnvironmentView.OpenInteractiveWindow, OpenInteractiveWindow_Executed, OpenInteractiveWindow_CanExecute )); list.CommandBindings.Add(new CommandBinding( EnvironmentView.OpenInteractiveOptions, OpenInteractiveOptions_Executed, OpenInteractiveOptions_CanExecute )); list.CommandBindings.Add(new CommandBinding( EnvironmentPathsExtension.StartInterpreter, StartInterpreter_Executed, StartInterpreter_CanExecute )); list.CommandBindings.Add(new CommandBinding( EnvironmentPathsExtension.StartWindowsInterpreter, StartInterpreter_Executed, StartInterpreter_CanExecute )); list.CommandBindings.Add(new CommandBinding( ApplicationCommands.Help, OnlineHelp_Executed, OnlineHelp_CanExecute )); list.CommandBindings.Add(new CommandBinding( ToolWindow.UnhandledException, UnhandledException_Executed, UnhandledException_CanExecute )); list.Service = _service; Content = list; }
private async void CreateProjectAndHandleErrors( IVsStatusbar statusBar, Microsoft.PythonTools.Project.ImportWizard.ImportWizard dlg ) { try { var path = await dlg.ImportSettings.CreateRequestedProjectAsync(); if (File.Exists(path)) { object outRef = null, pathRef = ProcessOutput.QuoteSingleArgument(path); _serviceProvider.GetDTE().Commands.Raise( VSConstants.GUID_VSStandardCommandSet97.ToString("B"), (int)VSConstants.VSStd97CmdID.OpenProject, ref pathRef, ref outRef ); statusBar.SetText(""); return; } } catch (UnauthorizedAccessException) { MessageBox.Show(Strings.ErrorImportWizardUnauthorizedAccess, Strings.ProductTitle); } catch (Exception ex) { ActivityLog.LogError(Strings.ProductTitle, ex.ToString()); MessageBox.Show(Strings.ErrorImportWizardException.FormatUI(ex.GetType().Name), Strings.ProductTitle); } statusBar.SetText(Strings.StatusImportWizardError); }
private async Task<bool> SendToRemoteWorkerAsync(IEnumerable<string> files, string projectDir, string projectName, string remotePath, IVsStatusbar statusBar, CancellationToken cancellationToken) { await TaskUtilities.SwitchToBackgroundThread(); string currentStatusText; statusBar.GetText(out currentStatusText); var workflow = _interactiveWorkflowProvider.GetOrCreate(); var outputWindow = workflow.ActiveWindow.InteractiveWindow; uint cookie = 0; try { var session = workflow.RSession; statusBar.SetText(Resources.Info_CompressingFiles); statusBar.Progress(ref cookie, 1, "", 0, 0); int count = 0; uint total = (uint)files.Count() * 2; // for compressing and sending string compressedFilePath = string.Empty; await Task.Run(() => { compressedFilePath = _fs.CompressFiles(files, projectDir, new Progress<string>((p) => { Interlocked.Increment(ref count); statusBar.Progress(ref cookie, 1, string.Format(Resources.Info_CompressingFile, Path.GetFileName(p)), (uint)count, total); string dest = p.MakeRelativePath(projectDir).ProjectRelativePathToRemoteProjectPath(remotePath, projectName); _appShell.DispatchOnUIThread(() => { outputWindow.WriteLine(string.Format(Resources.Info_LocalFilePath, p)); outputWindow.WriteLine(string.Format(Resources.Info_RemoteFilePath, dest)); }); }), CancellationToken.None); statusBar.Progress(ref cookie, 0, "", 0, 0); }); using (var fts = new DataTransferSession(session, _fs)) { cookie = 0; statusBar.SetText(Resources.Info_TransferringFiles); total = (uint)_fs.FileSize(compressedFilePath); var remoteFile = await fts.SendFileAsync(compressedFilePath, true, new Progress<long>((b) => { statusBar.Progress(ref cookie, 1, Resources.Info_TransferringFiles, (uint)b, total); }), cancellationToken); statusBar.SetText(Resources.Info_ExtractingFilesInRHost); await session.EvaluateAsync<string>($"rtvs:::save_to_project_folder({remoteFile.Id}, {projectName.ToRStringLiteral()}, '{remotePath.ToRPath()}')", REvaluationKind.Normal, cancellationToken); _appShell.DispatchOnUIThread(() => { outputWindow.WriteLine(Resources.Info_TransferringFilesDone); }); } } catch(Exception ex) when (ex is UnauthorizedAccessException || ex is IOException) { _appShell.ShowErrorMessage(Resources.Error_CannotTransferFile.FormatInvariant(ex.Message)); } catch (RHostDisconnectedException rhdex) { _appShell.DispatchOnUIThread(() => { outputWindow.WriteErrorLine(Resources.Error_CannotTransferNoRSession.FormatInvariant(rhdex.Message)); }); } finally { statusBar.Progress(ref cookie, 0, "", 0, 0); statusBar.SetText(currentStatusText); } return true; }
public EventQueue(IVsStatusbar statusBar) { this._statusBar = statusBar; _queue = new BlockingQueue<Action>(); _queueTask = Task.Run(() => ProcessQueue()); }
public PublishProject(CommonProjectNode node, PublishProjectOptions options) { _statusBar = (IVsStatusbar)CommonPackage.GetGlobalService(typeof(SVsStatusbar)); _statusBar.SetText("Starting publish..."); _node = node; _options = options; }
public VSStatusBar(IServiceProvider serviceProvider) { Guard.ArgumentNotNull(serviceProvider, "serviceProvider"); this.statusBar = serviceProvider.GetService(typeof(SVsStatusbar)) as IVsStatusbar; this.serviceProvider = serviceProvider; Guard.ArgumentNotNull(this.statusBar, "SVsStatusbar service"); }
public AddLicenseHeaderToAllProjectsCommand(LicenseHeaderReplacer licenseReplacer, IVsStatusbar statusBar, IDefaultLicenseHeaderPage licenseHeaderPage) { this.statusBar = statusBar; this.licenseReplacer = licenseReplacer; this.licenseHeaderPage = licenseHeaderPage; addLicenseHeaderToAllFilesCommand = new AddLicenseHeaderToAllFilesCommand(licenseReplacer); }
public static void Instantiate(IVsOutputWindowPane outputLog, IVsStatusbar statusBar) { lock (_locker) { if (_instance != null) throw new InvalidOperationException(string.Format("{0} of Resurrect is already instantiated.", _instance.GetType().Name)); _instance = new Log(outputLog, statusBar); } }
/// <summary> /// Initializes a new instance of the <see cref="VisualStudioJSLintProvider" /> class. /// </summary> /// <param name="serviceProvider">The service provider.</param> /// <param name="errorListProvider">The error list provider.</param> /// <param name="jsLintFactory">The JSLint factory.</param> /// <param name="fileSystemWrapper">The file system wrapper.</param> /// <param name="settingsRepository">The settings repository.</param> /// <param name="cacheProvider">The cache provider.</param> public VisualStudioJSLintProvider(IServiceProvider serviceProvider, IJSLintErrorListProvider errorListProvider, IJSLintFactory jsLintFactory, IFileSystemWrapper fileSystemWrapper, ISettingsRepository settingsRepository, ICacheProvider cacheProvider) { this.serviceProvider = serviceProvider; this.errorListProvider = errorListProvider; this.jsLintFactory = jsLintFactory; this.fileSystemWrapper = fileSystemWrapper; this.settingsRepository = settingsRepository; this.cacheProvider = cacheProvider; this.statusBar = this.serviceProvider.GetService<SVsStatusbar, IVsStatusbar>(); this.solutionService = this.serviceProvider.GetService<SVsSolution, IVsSolution>(); }
public MarginFactory([Import]SVsServiceProvider serviceProvider) { _serviceProvider = serviceProvider; ToolTipService.ShowDurationProperty.OverrideMetadata(typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue)); _dte = (DTE)serviceProvider.GetService(typeof(DTE)); _solutionEvents = _dte.Events.SolutionEvents; _solutionEvents.Opened += SolutionEvents_Opened; _solutionEvents.AfterClosing += SolutionEvents_AfterClosing; _statusBar = serviceProvider.GetService(typeof(SVsStatusbar)) as IVsStatusbar; LogFactory.CurrentLogger = new VisualStudioLogger(serviceProvider); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; }
protected override void OnCreate() { _outputWindow = OutputWindowRedirector.GetGeneral(this); Debug.Assert(_outputWindow != null); _statusBar = GetService(typeof(SVsStatusbar)) as IVsStatusbar; _uiShell = GetService(typeof(SVsUIShell)) as IVsUIShell; _dte = GetService(typeof(EnvDTE.DTE)) as EnvDTE.DTE; _infoBarFactory = GetService(typeof(SVsInfoBarUIFactory)) as IVsInfoBarUIFactory; object control = null; if (!CookiecutterClientProvider.IsCompatiblePythonAvailable()) { ReportPrereqsEvent(false); control = new MissingDependencies(); } else { ReportPrereqsEvent(true); string feedUrl = CookiecutterPackage.Instance.RecommendedFeed; if (string.IsNullOrEmpty(feedUrl)) { feedUrl = UrlConstants.DefaultRecommendedFeed; } _cookiecutterControl = new CookiecutterControl(_outputWindow, CookiecutterTelemetry.Current, new Uri(feedUrl), OpenGeneratedFolder, UpdateCommandUI); _cookiecutterControl.ContextMenuRequested += OnContextMenuRequested; control = _cookiecutterControl; _cookiecutterControl.InitializeAsync(CookiecutterPackage.Instance.CheckForTemplateUpdate).HandleAllExceptions(this, GetType()).DoNotWait(); } Content = control; RegisterCommands(new Command[] { new HomeCommand(this), new RunCommand(this), new UpdateCommand(this), new CheckForUpdatesCommand(this), new GitHubCommand(this, PackageIds.cmdidLinkGitHubHome), new GitHubCommand(this, PackageIds.cmdidLinkGitHubIssues), new GitHubCommand(this, PackageIds.cmdidLinkGitHubWiki), }, PackageGuids.guidCookiecutterCmdSet); RegisterCommands(new Command[] { new DeleteInstalledTemplateCommand(this), }, VSConstants.GUID_VSStandardCommandSet97); base.OnCreate(); OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (CookiecutterPackage.Instance.ShowHelp) { AddInfoBar(); } }
public VisualStudioWriter(DTE dte, System.IServiceProvider serviceProvider) { if (dte == null) { Debug.Write("Visual Studio Writer was passed a null DTE"); if(System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Break(); return; } _outputWindowPane = LoadOutputWindowPane(dte); _errorListProvider = LoadErrorListPane(serviceProvider); _statusbar = serviceProvider.GetService(typeof (SVsStatusbar)) as IVsStatusbar; }
internal StatusBarAdapter(IVim vim, IVimProtectedOperations vimProtectedOperations, ICommandMarginUtil commandMarginUtil, IVimApplicationSettings vimApplicationSettings, SVsServiceProvider vsServiceProvider) { _vim = vim; _vimProtectedOperations = vimProtectedOperations; _commandMarginUtil = commandMarginUtil; _vimApplicationSettings = vimApplicationSettings; _vsStatusbar = vsServiceProvider.GetService<SVsStatusbar, IVsStatusbar>(); _timer = new DispatcherTimer( TimeSpan.FromSeconds(.1), DispatcherPriority.Normal, OnTimer, Dispatcher.CurrentDispatcher); _timer.IsEnabled = !_vimApplicationSettings.UseEditorCommandMargin; _vimApplicationSettings.SettingsChanged += OnSettingsChanged; }
protected override void Initialize() { base.Initialize(); _statusBar = GetService(typeof (SVsStatusbar)) as IVsStatusbar; _oleMenuCommandService = GetService(typeof (IMenuCommandService)) as OleMenuCommandService; _outputWindow = GetService(typeof (SVsOutputWindow)) as IVsOutputWindow; _sortIcon = (short) Constants.SBAI_General; if (_oleMenuCommandService != null) { var menuCommandId = new CommandID(GuidList.guidErsx_Net_VsixCmdSet, (int) PkgCmdIDList.sortResx); var menuItem = new OleMenuCommand(MenuItemClick, StatusChanged, BeforeContextMenuOpens, menuCommandId); _oleMenuCommandService.AddCommand(menuItem); } }
public static async Task EndAnimationAsync(StatusAnimation animation) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); try { IVsStatusbar statusBar = await GetServiceAsync(); statusBar.FreezeOutput(0); statusBar.Animation(0, animation); statusBar.FreezeOutput(1); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } }
public Message(IVsStatusbar statusBar, string message) { _statusBar = statusBar; Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread(); // Make sure the status bar is not frozen _statusBar.IsFrozen(out var frozen); if (frozen != 0) { _statusBar.FreezeOutput(0); } // Set the status bar text and make its display static. _statusBar.SetText(message); }
public static async Task SetTextAsync(string text) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); try { IVsStatusbar statusBar = await GetServiceAsync(); statusBar.FreezeOutput(0); statusBar.SetText(text); statusBar.FreezeOutput(1); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex); } }
public CodeWindowManager(IVsCodeWindow codeWindow, IWpfTextView textView, IVsStatusbar statusBar) { _window = codeWindow; _textView = textView; var model = CommonPackage.ComponentModel; var adaptersFactory = model.GetService <IVsEditorAdaptersFactoryService>(); var factory = model.GetService <IEditorOperationsFactoryService>(); EditFilter editFilter = _filter = new EditFilter(textView, factory.GetEditorOperations(textView), statusBar); var textViewAdapter = adaptersFactory.GetViewAdapter(textView); editFilter.AttachKeyboardFilter(textViewAdapter); var viewFilter = new TextViewFilter(); viewFilter.AttachFilter(textViewAdapter); }
void ShowInfo(string text) { Dispatcher.CurrentDispatcher.VerifyAccess(); if (_statusBar == null) { try { _statusBar = owner.GetServiceAsync(typeof(SVsStatusbar)).Result as IVsStatusbar; } catch { MessageBox.Show(text); return; } } _statusBar.SetText(text); }
private PostHasteCommand(Package package, TextSelector textSelector) { if (package == null) throw new ArgumentNullException(nameof(package)); this.url = Properties.Settings.Default.HasteBinUrl; this.package = package; this.textSelector = textSelector; OleMenuCommandService commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; if (commandService != null) { var menuCommandId = new CommandID(CommandSet, CommandId); var menuItem = new MenuCommand(MenuItemCallback, menuCommandId); commandService.AddCommand(menuItem); } statusBar = ServiceProvider.GetService(typeof(SVsStatusbar)) as IVsStatusbar; }
private void StopProgress() { if (_statusBar == null) return; // Clear the animation if (_animationIcon != null) { _statusBar.Animation(0, ref _animationIcon); _statusBar.SetText(""); _animationIcon = null; } // Clear the progress bar. if (_cookie != 0) { _statusBar.Progress(ref _cookie, 0, "", 0, 0); _cookie = 0; } _statusBar = null; }
public void ReportProgress(string displayText, int completed, int total) { if (completed >= total) { Logger.LogInfo("Stopping progress at {0:n0} completed operations.", completed); StopProgress(); return; } if (_statusBar == null) { Logger.LogInfo("Starting progress of {0:n0} total operations.", total); _statusBar = _serviceProvider.GetService(typeof(SVsStatusbar)) as IVsStatusbar; if (_statusBar == null) return; } if (total == int.MaxValue) { ShowIndterminateProgress(displayText); } else { ShowProgress(displayText, completed, total); } }
//<Snippet1> void ProgressBarExample() { IVsStatusbar statusBar = (IVsStatusbar)GetService(typeof(SVsStatusbar)); uint cookie = 0; string label = "Progress bar label..."; // Initialize the progress bar. statusBar.Progress(ref cookie, 1, "", 0, 0); for (uint i = 0, total = 100; i <= total; i++) { // Display incremental progress. statusBar.Progress(ref cookie, 1, label, i, total); System.Threading.Thread.Sleep(1); } // Clear the progress bar. statusBar.Progress(ref cookie, 0, "", 0, 0); }
public TestDotsCoverageVsPlugin(VsSolutionTestCoverage vsSolutionTestCoverage, ITaskCoverageManager taskCoverageManager, IWpfTextView textView, IVsStatusbar statusBar, Solution solution) { _vsSolutionTestCoverage = vsSolutionTestCoverage; _taskCoverageManager = taskCoverageManager; _canvas = new Canvas(); _textView = textView; _statusBar = statusBar; _solution = solution; _textView.ViewportHeightChanged += (s, e) => Redraw(); _textView.LayoutChanged += LayoutChanged; this.Width = 20; this.ClipToBounds = true; this.Background = new SolidColorBrush(Colors.White); Children.Add(_canvas); textView.TextBuffer.Changed += TextBuffer_Changed; _taskCoverageManager.CoverageTaskEvent += TaskCoverageManagerCoverageTaskEvent; }
public Tool( IPackageContext packageContext, BuildInfo buildContext, IBuildDistributor buildDistributor, ControlViewModel viewModel) { _dte = packageContext.GetDTE(); if (_dte == null) throw new InvalidOperationException("Unable to get DTE instance."); _dteStatusBar = packageContext.GetStatusBar(); if (_dteStatusBar == null) TraceManager.TraceError("Unable to get IVsStatusbar instance."); _toolWindowManager = new ToolWindowManager(packageContext); _buildContext = buildContext; _buildDistributor = buildDistributor; _viewModel = viewModel; _solutionEvents = _dte.Events.SolutionEvents; Initialize(); }
/// <summary> /// Get all library archives accessible to the linker of the specified project. /// </summary> /// <param name="project">The project to get the LibArchives for</param> /// <param name="statusBar">the VS status bar</param> /// <returns>Parsed libraries which are accessible by the linker of the given project.</returns> public List<LibArchive> GetLibraryArchives(Project project, IVsStatusbar statusBar) { int frozen; uint cookie = 0; statusBar.IsFrozen(out frozen); if (!_projectArchiveMap.ContainsKey(project)) { var archives = new List<LibArchive>(); var libraries = GetLibraries(project); if (frozen == 0) statusBar.Progress(ref cookie, 1, "", 0, (uint)libraries.Count); int i = 0; foreach(var lib in libraries) { if (frozen == 0) { statusBar.Progress(ref cookie, 1, "", (uint) i++, (uint)libraries.Count); statusBar.SetText("Scanning " + Path.GetFileName(lib)); } archives.Add(GetArchive(lib)); } _projectArchiveMap.Add(project, archives); } if (frozen == 0) { statusBar.Progress(ref cookie, 0, "", 0, 0); statusBar.Clear(); } return _projectArchiveMap[project]; }
internal static void SetStatusMessage(string message) { if (StatusBar == null) { StatusBar = Package.GetGlobalService(typeof(IVsStatusbar)) as IVsStatusbar; } StatusBar.SetText(message); }
/// <summary> /// Constructor. /// </summary> /// <param name="sp"></param> /// <param name="extensionDirectory"></param> public SandoGlobalService(IServiceProvider sp) { //Trace.WriteLine("Constructing a new instance of SandoGlobalService"); serviceProvider = sp; statusBar = (IVsStatusbar)Package.GetGlobalService(typeof(SVsStatusbar)); }
private void GetStatusbar() { this.statusBar = GetService(typeof(SVsStatusbar)) as IVsStatusbar; if (this.statusBar == null) ErrorHandler.ThrowOnFailure(1); }
private static void TrySetTypingsLoadedStatusBar(IVsStatusbar statusBar, object icon, bool statusSetSuccess) { if (statusBar != null && (statusSetSuccess || !IsStatusBarFrozen(statusBar))) { if (!ErrorHandler.Succeeded(statusBar.FreezeOutput(0))) { Debug.Fail("Failed to unfreeze typings status bar"); return; } statusBar.Animation(0, ref icon); statusBar.SetText(Resources.StatusTypingsLoaded); } }
public StatusBar() { this.statusBar = (IVsStatusbar)Package.GetGlobalService(typeof(SVsStatusbar)); }
private static bool TrySetTypingsLoadingStatusBar(IVsStatusbar statusBar, object icon) { if (statusBar != null && !IsStatusBarFrozen(statusBar)) { statusBar.SetText(Resources.StatusTypingsLoading); statusBar.Animation(1, ref icon); if (ErrorHandler.Succeeded(statusBar.FreezeOutput(1))) { return true; } Debug.Fail("Failed to freeze typings status bar"); } return false; }
public TacticReplacerProxy(ITextDocumentFactoryService tdf, IServiceProvider isp, IPeekBroker pb) { _status = (IVsStatusbar) isp.GetService(typeof(SVsStatusbar)); RefactoringUtil.Tdf = tdf; _pb = pb; _activePeekSession = new Dictionary<string, ActivePeekSessionData>(); }
private static bool IsStatusBarFrozen(IVsStatusbar statusBar) { int frozen; statusBar.IsFrozen(out frozen); return frozen == 1; }
internal static void Initialize(IVsStatusbar vsStatusBar) { _statusBar = vsStatusBar; }