Exemplo n.º 1
0
        private void ShowContextMenu(bool mousePosition)
        {
            // Already on main thread, but unwind callstack before showing the text menu
            ThreadHelper.JoinableTaskFactory.RunAsync(async delegate
            {
                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(alwaysYield: true);

                BindingPackage package = BindingPackage.Get(this.services);
                package.Telemetry.TrackEvent(Constants.EventShowContextMenu);

                FrameworkElement table = this.control.Control;
                Point point            = mousePosition
                    ? table.PointToScreen(Mouse.GetPosition(table))
                    : table.PointToScreen(new Point(table.RenderSize.Width / 2, table.RenderSize.Height / 2)); // should really get the focused entry position
                POINTS[] locationPoints = new[] { new POINTS()
                                                  {
                                                      x = (short)point.X, y = (short)point.Y
                                                  } };

                IVsUIShell shell = this.services.GetService <SVsUIShell, IVsUIShell>();
                IOleCommandTarget commandTarget = table.Tag as IOleCommandTarget;
                Guid commandSet = Constants.GuidBindingPaneCommandSet;

                shell.ShowContextMenu(0, ref commandSet, Constants.BindingPaneContextMenuId, locationPoints, commandTarget);
            }).FileAndForget(Constants.VsBindingPaneFeaturePrefix + nameof(ITableControlEventProcessor.PostprocessMouseRightButtonUp));
        }
Exemplo n.º 2
0
        public BindingPane(BindingPackage package)
            : base(null)
        {
            this.package                 = package;
            this.outputParsers           = new List <IOutputParser>();
            this.viewModel               = new BindingPaneViewModel(package.Telemetry, this.outputParsers);
            this.control                 = new BindingPaneControl(this.package, this.viewModel);
            this.controller              = new BindingPaneController(package, this.viewModel, this.control.TableControl);
            this.cancellationTokenSource = new CancellationTokenSource();

            this.Caption = Resource.ToolWindow_Title;
            this.Content = this.control;
            this.ToolBarCommandTarget = this.controller;
            this.ToolBarLocation      = (int)VSTWT_LOCATION.VSTWT_TOP;
            this.ToolBar = new CommandID(Constants.GuidBindingPaneCommandSet, Constants.BindingPaneToolbarId);
        }