Exemple #1
0
        public async Task ViewAsync(string expression, string title)
        {
            var evaluation = await EvaluateAsync(expression, _properties, RValueRepresentations.Str()) as IRValueInfo;

            if (evaluation != null)
            {
                await VsAppShell.Current.SwitchToMainThreadAsync();

                var id = Math.Abs(_toolWindowIdBase + expression.GetHashCode() % (Int32.MaxValue - _toolWindowIdBase));

                var existingPane = ToolWindowUtilities.FindWindowPane <VariableGridWindowPane>(id);
                var frame        = existingPane?.Frame as IVsWindowFrame;
                if (frame != null)
                {
                    frame.Show();
                }
                else
                {
                    VariableGridWindowPane pane = ToolWindowUtilities.ShowWindowPane <VariableGridWindowPane>(id, true);
                    frame = (IVsWindowFrame)pane.Frame;
                    frame.SetProperty((int)__VSFPROPID.VSFPROPID_IsWindowTabbed, true);
                    frame.SetFramePos(VSSETFRAMEPOS.SFP_fDock, typeof(VariableGridWindowPane).GUID, 0, 0, 0, 0);

                    title = !string.IsNullOrEmpty(title) ? title : evaluation.Expression;
                    pane.SetEvaluation(new VariableViewModel(evaluation, _aggregator), title);
                }
            }
        }
Exemple #2
0
        public async Task ViewAsync(string expression, string title, CancellationToken cancellationToken = default(CancellationToken))
        {
            var evaluation = await EvaluateAsync(expression, _properties, RValueRepresentations.Str(), cancellationToken);

            if (evaluation != null)
            {
                await VsAppShell.Current.SwitchToMainThreadAsync(cancellationToken);

                var id = Math.Abs(_toolWindowIdBase + expression.GetHashCode() % (Int32.MaxValue - _toolWindowIdBase));

                var pane = ToolWindowUtilities.FindWindowPane <VariableGridWindowPane>(id);
                if (pane == null)
                {
                    pane = ToolWindowUtilities.ShowWindowPane <VariableGridWindowPane>(id, true);
                }
                else
                {
                    var frame = pane.Frame as IVsWindowFrame;
                    Debug.Assert(frame != null);
                    frame?.Show();
                }

                title = !string.IsNullOrEmpty(title) ? title : evaluation.Expression;
                pane.SetEvaluation(new VariableViewModel(evaluation, _aggregator), title);
            }
        }
        protected override void SetStatus()
        {
            var variableWindowPane = ToolWindowUtilities.FindWindowPane <VariableWindowPane>(0);

            // 'Delete all variables' button should be enabled only when the Global environment
            // is selected in Variable Explorer.
            Enabled = (variableWindowPane?.IsGlobalREnvironment()) ?? false;
        }
Exemple #4
0
        public Task InvokeAsync(int index)
        {
            if (index < _windows.Length)
            {
                ToolWindowUtilities.ShowWindowPane <PlotDeviceWindowPane>(_windows[index].InstanceId, true);
            }

            return(Task.CompletedTask);
        }
Exemple #5
0
        public Task <CommandResult> InvokeAsync(int index)
        {
            if (index < _windows.Length)
            {
                ToolWindowUtilities.ShowWindowPane <PlotDeviceWindowPane>(_windows[index].InstanceId, true);
            }

            return(Task.FromResult(CommandResult.Executed));
        }
Exemple #6
0
        /// <summary>
        /// Displays R help URL in a browser on in the host app-provided window
        /// </summary>
        public async Task ShowHelp(string url)
        {
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            if (RToolsSettings.Current.HelpBrowser == HelpBrowserType.External)
            {
                Process.Start(url);
            }
            else
            {
                HelpWindowPane pane = ToolWindowUtilities.ShowWindowPane <HelpWindowPane>(0, focus: false);
                pane.Component.Navigate(url);
            }
        }
Exemple #7
0
        public async Task RefreshHistoryInfo()
        {
            var info = await PlotContentProvider.GetHistoryInfoAsync();

            ActivePlotIndex = info.ActivePlotIndex;
            PlotCount       = info.PlotCount;

            VsAppShell.Current.DispatchOnUIThread(() => {
                // We need to push creation of the tool window
                // so it appears on the first plot
                if (!VsAppShell.Current.IsUnitTestEnvironment)
                {
                    ToolWindowUtilities.ShowWindowPane <PlotWindowPane>(0, false);
                }
                HistoryChanged?.Invoke(this, EventArgs.Empty);
            });
        }
        protected T GetOrCreate(int instanceId, Func <T> factory)
        {
            _mainThread.Assert();
            if (_toolWindowPanes.TryGetValue(instanceId, out ToolWindowPaneHolder holder))
            {
                if (holder.ToolWindowPane != null)
                {
                    return(holder.ToolWindowPane);
                }
                RemoveHolder(instanceId);
            }

            var instance  = factory();
            var vsUiShell = Services.GetService <IVsUIShell>(typeof(SVsUIShell));

            ToolWindowUtilities.CreateToolWindow(vsUiShell, instance, instanceId);

            holder = new ToolWindowPaneHolder(instance, () => RemoveHolder(instanceId));
            _toolWindowPanes.Add(instanceId, holder);
            return(instance);
        }
        protected T GetOrCreate(int instanceId, Func <int, T> factory)
        {
            ToolWindowPaneHolder holder;

            if (_toolWindowPanes.TryGetValue(instanceId, out holder))
            {
                if (holder.ToolWindowPane != null)
                {
                    return(holder.ToolWindowPane);
                }
                RemoveHolder(instanceId);
            }

            var        instance  = factory(instanceId);
            IVsUIShell vsUiShell = VsAppShell.Current.GetGlobalService <IVsUIShell>(typeof(SVsUIShell));

            ToolWindowUtilities.CreateToolWindow(vsUiShell, instance, instanceId);

            holder = new ToolWindowPaneHolder(instance, () => RemoveHolder(instanceId));
            _toolWindowPanes.Add(instanceId, holder);
            return(instance);
        }
Exemple #10
0
 protected override void Handle()
 {
     ToolWindowUtilities.ShowWindowPane <T>(0, true);
 }
Exemple #11
0
        private void ShowVariableGridWindowPane(object parameter)
        {
            VariableGridWindowPane pane = ToolWindowUtilities.ShowWindowPane <VariableGridWindowPane>(0, true);

            pane.SetEvaluation(this);
        }
 protected override void Handle()
 {
     // TODO: find ad show all windows
     ToolWindowUtilities.ShowWindowPane <PlotWindowPane>(0, true);
 }
Exemple #13
0
 public void Show(bool focus, bool immediate) => ToolWindowUtilities.ShowToolWindow(this, Services.MainThread(), focus, immediate);
Exemple #14
0
 protected override void Handle()
 {
     ToolWindowUtilities.ShowWindowPane <PlotManagerWindowPane>(0, true);
 }