예제 #1
0
        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));
            }
        }
예제 #2
0
파일: RPackage.cs 프로젝트: fpcMotif/RTVS
        protected override void Dispose(bool disposing)
        {
            if (_indexBuildingTask != null && !_indexBuildingTask.IsFaulted)
            {
                _indexBuildingTask.Wait(2000);
                _indexBuildingTask = null;
            }

            LogCleanup.Cancel();
            ReplShortcutSetting.Close();
            ProjectIconProvider.Close();

            RtvsTelemetry.Current.Dispose();

            using (var p = RPackage.Current.GetDialogPage(typeof(RToolsOptionsPage)) as RToolsOptionsPage) {
                p.SaveSettings();
            }

            base.Dispose(disposing);
        }