private void SaveSettingsAndClose() { _model.Settings.Save(_appShell.SettingsStorage); // Make sure all files are saved and up to date on disk. var dte = _appShell.GetGlobalService <DTE>(typeof(DTE)); dte.ExecuteCommand("File.SaveAll"); var uiShell = _appShell.GetGlobalService <IVsUIShell>(typeof(SVsUIShell)); var guid = RGuidList.RCmdSetGuid; var o = new object(); uiShell.PostExecCommand(ref guid, RPackageCommandId.icmdPublishSProc, 0, ref o); Close(); }
private async Task RMarkdownRenderAsync(IRSession session, IFileSystem fs, string inputFilePath, string outputFilePath, string format, int codePage, IApplicationShell appShell) { using (var fts = new DataTransferSession(session, fs)) { string currentStatusText = string.Empty; uint cookie = 0; IVsStatusbar statusBar = null; appShell.DispatchOnUIThread(() => { statusBar = appShell.GetGlobalService<IVsStatusbar>(typeof(SVsStatusbar)); statusBar.GetText(out currentStatusText); statusBar.Progress(ref cookie, 1, "", 0, 0); }); try { // TODO: progress and cancellation handling appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownSendingInputFile.FormatInvariant(Path.GetFileName(inputFilePath)), 0, 3); }); var rmd = await fts.SendFileAsync(inputFilePath, true, null, CancellationToken.None); appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownPublishingFile.FormatInvariant(Path.GetFileName(inputFilePath)), 1, 3); }); var publishResult = await session.EvaluateAsync<ulong>($"rtvs:::rmarkdown_publish(blob_id = {rmd.Id}, output_format = {format.ToRStringLiteral()}, encoding = 'cp{codePage}')", REvaluationKind.Normal); appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownGetOutputFile.FormatInvariant(Path.GetFileName(outputFilePath)), 2, 3); }); await fts.FetchFileAsync(new RBlobInfo(publishResult), outputFilePath, true, null, CancellationToken.None); appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownPublishComplete.FormatInvariant(Path.GetFileName(outputFilePath)), 3, 3); }); } finally { appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 0, "", 0, 0); statusBar?.SetText(currentStatusText); }); } } }
private async Task RMarkdownRenderAsync(IRSession session, IFileSystem fs, string inputFilePath, string outputFilePath, string format, int codePage, IApplicationShell appShell) { using (var fts = new DataTransferSession(session, fs)) { string currentStatusText = string.Empty; uint cookie = 0; IVsStatusbar statusBar = null; appShell.DispatchOnUIThread(() => { statusBar = appShell.GetGlobalService <IVsStatusbar>(typeof(SVsStatusbar)); statusBar.GetText(out currentStatusText); statusBar.Progress(ref cookie, 1, "", 0, 0); }); try { appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownSendingInputFile.FormatInvariant(Path.GetFileName(inputFilePath)), 0, 3); }); var rmd = await fts.SendFileAsync(inputFilePath); appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownPublishingFile.FormatInvariant(Path.GetFileName(inputFilePath)), 1, 3); }); var publishResult = await session.EvaluateAsync <ulong>($"rtvs:::rmarkdown_publish(blob_id = {rmd.Id}, output_format = {format.ToRStringLiteral()}, encoding = 'cp{codePage}')", REvaluationKind.Normal); appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownGetOutputFile.FormatInvariant(Path.GetFileName(outputFilePath)), 2, 3); }); await fts.FetchFileAsync(new RBlobInfo(publishResult), outputFilePath); appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 1, Resources.Info_MarkdownPublishComplete.FormatInvariant(Path.GetFileName(outputFilePath)), 3, 3); }); } finally { appShell.DispatchOnUIThread(() => { statusBar?.Progress(ref cookie, 0, "", 0, 0); statusBar?.SetText(currentStatusText); }); } } }
private void Handle() { var project = _pss.GetSelectedProject <IVsHierarchy>()?.GetDTEProject(); if (project != null) { var sprocFiles = project.GetSProcFiles(_pss); if (sprocFiles.Any()) { try { // Make sure all files are saved and up to date on disk. var dte = _appShell.GetGlobalService <DTE>(typeof(DTE)); dte.ExecuteCommand("File.SaveAll"); var publisher = new SProcPublisher(_appShell, _pss, _fs, _dacServicesProvider.GetDacPackageServices()); var settings = new SqlSProcPublishSettings(_settings); publisher.Publish(settings, sprocFiles); } catch (Exception ex) { _appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.SqlPublish_PublishError, ex.Message)); } } else { _appShell.ShowErrorMessage(Resources.SqlPublishDialog_NoSProcFiles); } } }
public static IntPtr GetDialogOwnerWindow(this IApplicationShell appShell) { IntPtr vsWindow; var uiShell = appShell.GetGlobalService<IVsUIShell>(typeof(SVsUIShell)); uiShell.GetDialogOwnerHwnd(out vsWindow); return vsWindow; }
public static void PostCommand(this IApplicationShell appShell, Guid guid, int id) { var uiShell = appShell.GetGlobalService <IVsUIShell>(typeof(SVsUIShell)); var o = new object(); uiShell.PostExecCommand(ref guid, (uint)id, 0, ref o); }
private Visual GetRootVisual() { var dte = _shell.GetGlobalService <EnvDTE.DTE>(); EnvDTE.Window window; try { window = dte.MainWindow; } catch (NullReferenceException) { // Window isn't loaded yet return(null); } var hwnd = window.HWnd; var hwndSource = HwndSource.FromHwnd(new IntPtr(hwnd)); return(hwndSource?.RootVisual); }
private static void OverrideImageSources(IApplicationShell shell) { IVsImageService2 imageService = shell.GetGlobalService <IVsImageService2>(typeof(SVsImageService)); ImageSources.Add = GetImage(imageService, KnownMonikers.Add); ImageSources.Edit = GetImage(imageService, KnownMonikers.Edit); ImageSources.Property = GetImage(imageService, KnownMonikers.Property); }
private void SaveSettingsAndClose() { _model.Settings.Save(_settings); // Make sure all files are saved and up to date on disk. var dte = _appShell.GetGlobalService <DTE>(typeof(DTE)); dte.ExecuteCommand("File.SaveAll"); _appShell.PostCommand(RGuidList.RCmdSetGuid, RPackageCommandId.icmdPublishSProc); Close(); }
public static Font GetUiFont(this IApplicationShell appShell) { var fontSvc = appShell.GetGlobalService<IUIHostLocale2>(typeof(SUIHostLocale)); if (fontSvc != null) { var logFont = new UIDLGLOGFONT[1]; int hr = fontSvc.GetDialogFont(logFont); if (hr == VSConstants.S_OK && logFont[0].lfFaceName != null) { return IdeUtilities.FontFromUiDialogFont(logFont[0]); } } return null; }
private Visual GetRootVisual() { var shell = _shell.GetGlobalService <IVsUIShell>(typeof(SVsUIShell)); IntPtr window; shell.GetDialogOwnerHwnd(out window); if (window == IntPtr.Zero) { return(null); } var hwndSource = HwndSource.FromHwnd(window); return(hwndSource?.RootVisual); }
public static async Task OpenDataCsvApp(IREvaluationResultInfo result, IApplicationShell appShell, IFileSystem fileSystem, IProcessServices processServices) { await appShell.SwitchToMainThreadAsync(); if (Interlocked.Exchange(ref _busy, 1) > 0) { return; } var workflow = appShell.ExportProvider.GetExportedValue <IRInteractiveWorkflowProvider>().GetOrCreate(); var session = workflow.RSession; var folder = GetTempCsvFilesFolder(); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } var pss = appShell.ExportProvider.GetExportedValue <IProjectSystemServices>(); var variableName = result.Name ?? _variableNameReplacement; var csvFileName = MakeCsvFileName(appShell, pss, variableName); var file = pss.GetUniqueFileName(folder, csvFileName, "csv", appendUnderscore: true); string currentStatusText; var statusBar = appShell.GetGlobalService <IVsStatusbar>(typeof(SVsStatusbar)); statusBar.GetText(out currentStatusText); try { statusBar.SetText(Resources.Status_WritingCSV); appShell.ProgressDialog.Show(async(p, ct) => await CreateCsvAndStartProcess(result, session, file, fileSystem, p), Resources.Status_WritingCSV, 100, 500); if (fileSystem.FileExists(file)) { processServices.Start(file); } } catch (Win32Exception ex) { appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message)); } catch (IOException ex) { appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message)); } finally { statusBar.SetText(currentStatusText); } Interlocked.Exchange(ref _busy, 0); }
private void RegisterFocusPreservingWindow(ToolWindowPane toolWindow) { var frame = toolWindow.Frame as IVsWindowFrame; if (frame != null) { Guid persistenceSlot; if (frame.GetGuidProperty((int)__VSFPROPID.VSFPROPID_GuidPersistenceSlot, out persistenceSlot) >= 0) { var debugger = _shell.GetGlobalService <SVsShellDebugger>() as IVsDebugger6; if (debugger != null) { debugger.RegisterFocusPreservingWindow(persistenceSlot); } } } }
public static async Task OpenDataCsvApp(IREvaluationResultInfo result, IApplicationShell appShell, IFileSystem fileSystem, IProcessServices processServices) { await appShell.SwitchToMainThreadAsync(); if (Interlocked.Exchange(ref _busy, 1) > 0) { return; } var workflow = appShell.ExportProvider.GetExportedValue<IRInteractiveWorkflowProvider>().GetOrCreate(); var session = workflow.RSession; var folder = GetTempCsvFilesFolder(); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } var pss = appShell.ExportProvider.GetExportedValue<IProjectSystemServices>(); var variableName = result.Name ?? _variableNameReplacement; var csvFileName = MakeCsvFileName(appShell, pss, variableName); var file = pss.GetUniqueFileName(folder, csvFileName, "csv", appendUnderscore: true); string currentStatusText; var statusBar = appShell.GetGlobalService<IVsStatusbar>(typeof(SVsStatusbar)); statusBar.GetText(out currentStatusText); try { statusBar.SetText(Resources.Status_WritingCSV); appShell.ProgressDialog.Show(async (p, ct) => await CreateCsvAndStartProcess(result, session, file, fileSystem, p, ct), Resources.Status_WritingCSV, 100, 500); if (fileSystem.FileExists(file)) { processServices.Start(file); } } catch (Exception ex) when (ex is Win32Exception || ex is IOException || ex is UnauthorizedAccessException) { appShell.ShowErrorMessage(string.Format(CultureInfo.InvariantCulture, Resources.Error_CannotOpenCsv, ex.Message)); } finally { statusBar.SetText(currentStatusText); } Interlocked.Exchange(ref _busy, 0); }
public ShowPlotWindowCommand(IApplicationShell appShell, IRInteractiveWorkflow workflow) { _plotManager = workflow.Plots; _shell = appShell.GetGlobalService <IVsUIShell4>(typeof(SVsUIShell)); }
public ShowPlotWindowCommand(IApplicationShell appShell, IRInteractiveWorkflow workflow) { _plotManager = workflow.Plots; _shell = appShell.GetGlobalService<IVsUIShell4>(typeof(SVsUIShell)); }
public HideAllPlotWindowsCommand(IApplicationShell appShell) : base(RGuidList.RCmdSetGuid, RPackageCommandId.icmdPlotWindowsHideAll) { _appShell = appShell; _shell = appShell.GetGlobalService<IVsUIShell4>(typeof(SVsUIShell)); }
protected async Task <bool> SendToRemoteAsync(IEnumerable <string> files, string projectDir, string projectName, string remotePath) { IVsStatusbar statusBar = _appShell.GetGlobalService <IVsStatusbar>(typeof(SVsStatusbar)); return(await SendToRemoteWorkerAsync(files, projectDir, projectName, remotePath, statusBar)); }
public HideAllPlotWindowsCommand(IApplicationShell appShell) : base(RGuidList.RCmdSetGuid, RPackageCommandId.icmdPlotWindowsHideAll) { _appShell = appShell; _shell = appShell.GetGlobalService <IVsUIShell4>(typeof(SVsUIShell)); }