public static void OnCommand(object sender, EventArgs args) { if (MessageButtons.Yes == VsAppShell.Current.ShowMessage(Resources.Warning_SettingsReset, MessageButtons.YesNo)) { IVsUIShell shell = VsAppShell.Current.GetGlobalService <IVsUIShell>(typeof(SVsUIShell)); Guid group = VSConstants.CMDSETID.StandardCommandSet2K_guid; string asmDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetAssemblyPath()); string settingsFilePath1 = Path.Combine(asmDirectory, @"Profiles\", "R.vssettings"); string settingsFilePath2 = Path.Combine(asmDirectory, @"Profiles\", "RStudioKeyboard.vssettings"); if (!File.Exists(settingsFilePath1)) { string ideFolder = asmDirectory.Substring(0, asmDirectory.IndexOf(@"\Extensions", StringComparison.OrdinalIgnoreCase)); settingsFilePath1 = Path.Combine(ideFolder, @"Profiles\", "R.vssettings"); } object arguments = string.Format(CultureInfo.InvariantCulture, "-import:\"{0}\"", settingsFilePath1); shell.PostExecCommand(ref group, (uint)VSConstants.VSStd2KCmdID.ManageUserSettings, 0, ref arguments); if (MessageButtons.Yes == VsAppShell.Current.ShowMessage(Resources.Warning_RStudioKeyboardShortcuts, MessageButtons.YesNo)) { arguments = string.Format(CultureInfo.InvariantCulture, "-import:\"{0}\"", settingsFilePath2); shell.PostExecCommand(ref group, (uint)VSConstants.VSStd2KCmdID.ManageUserSettings, 0, ref arguments); } // Restore Ctrl+Enter if necessary IdleTimeAction.Create(() => { ReplShortcutSetting.Close(); ReplShortcutSetting.Initialize(); }, 100, typeof(ImportRSettingsCommand)); } }
protected override void Initialize() { Current = this; // Force app shell creation before everything else var shell = VsAppShell.Current; if (IsCommandLineMode()) { return; } CranMirrorList.Download(); VerifyWebToolsInstalled(); RtvsTelemetry.Initialize(); using (var p = Current.GetDialogPage(typeof(RToolsOptionsPage)) as RToolsOptionsPage) { p.LoadSettings(); } base.Initialize(); ReplShortcutSetting.Initialize(); ProjectIconProvider.LoadProjectImages(); LogCleanup.DeleteLogsAsync(DiagnosticLogs.DaysToRetain); _indexBuildingTask = FunctionIndex.BuildIndexAsync(); AdviseExportedWindowFrameEvents <ActiveWpfTextViewTracker>(); AdviseExportedWindowFrameEvents <VsActiveRInteractiveWindowTracker>(); AdviseExportedDebuggerEvents <VsDebuggerModeTracker>(); System.Threading.Tasks.Task.Run(() => RtvsTelemetry.Current.ReportConfiguration()); IdleTimeAction.Create(() => ExpansionsCache.Load(), 200, typeof(ExpansionsCache)); }