Example #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));
            }
        }
Example #2
0
        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);
        }
Example #3
0
        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));
        }