Ejemplo n.º 1
0
 public static EditTimeVisualizer Create(IWpfTextView editor, EditTimeVisualizerModel model)
 {
     return(editor.VisualElement.Dispatcher.Invoke(() => new EditTimeVisualizer()
     {
         DataContext = model
     }));
 }
Ejemplo n.º 2
0
        public static EditTimeVisualizer Create(IWpfTextView editor, SyntaxNode node)
        {
            var model = EditTimeVisualizerModel.Create(node);

            if (model.IsValid)
            {
                return(Create(editor, model));
            }
            return(null);
        }
Ejemplo n.º 3
0
        public static EditTimeVisualizerModel Create(GazeTarget target)
        {
            var model = new EditTimeVisualizerModel();

            //model.ID = target.Start + "_" + target.Length;

            model.Name  = ((ISymbol)target.DataModel).Name;
            model.Value = AttemptGetDebuggerValue(model.Name);

            return(model);
        }
Ejemplo n.º 4
0
        public static EditTimeVisualizerModel Create(SyntaxNode node)
        {
            var model = new EditTimeVisualizerModel();

            //model.ID = node.Span.Start + "_" + node.Span.Length;

            Debug.WriteLine($"SyntaxNode is {node.GetType()}");

            if (node is ParameterSyntax)
            {
                model.Name  = ((ParameterSyntax)node).Identifier.Text;
                model.Value = AttemptGetDebuggerValue(model.Name);
            }
            else if (node is IdentifierNameSyntax && ((IdentifierNameSyntax)node).IsVar)
            {
                model.Name  = ((IdentifierNameSyntax)node).Identifier.Text;
                model.Value = AttemptGetDebuggerValue(model.Name);
            }
            else if (node is QualifiedNameSyntax)
            {
                // todo - dotted syntax
            }
            return(model);
        }
Ejemplo n.º 5
0
        public GazeAdornment(Microsoft.VisualStudio.Text.Editor.IWpfTextView view)
        {
            var componentModel = (Microsoft.VisualStudio.ComponentModelHost.IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(Microsoft.VisualStudio.ComponentModelHost.SComponentModel));

            Workspace = componentModel.GetService <Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace>();
            View      = view;

            LayerManager = GazeLayerManager.Get(view);
            LayerManager.SingletonLayers = new System.Collections.Generic.List <GazeResponseLayer>()
            {
                new EllipseInformationalGazeLayerElement(View, Brushes.Red, 5, 5),      // show a 5x5 core target that is the discrete X,Y coordinates
                new EllipseInformationalGazeLayerElement(View, Brushes.Cyan, 100, 100), // show a 100x100 extended target that is the scan area for the gaze targeting system
            };

            EyeTracking.PointAvailable             += (sender, e) => Stabilization.AddPoint(e);
            Stabilization.StabilizedPointAvailable += (sender, e) =>
            {
                if (_inFlight)
                {
                    return;
                }

                _inFlight = true;

                // workflow goes here, point should be stabilized coming from point provider
                try
                {
                    if (View.VisualElement.Dispatcher.Invoke(() => (View.VisualElement.ActualHeight == 0 || !View.VisualElement.IsInitialized || !View.VisualElement.IsLoaded)))
                    {
                        _inFlight = false;
                        return; // gaze point available before WPF draw is finished
                    }

                    // localize point to our editor view
                    var localPt = View.VisualElement.Dispatcher.Invoke(() => View.VisualElement.PointFromScreen(e));
                    localPt.X += View.ViewportLeft;
                    localPt.Y += View.ViewportTop;

                    // infer/guess gaze targets
                    var gazedElements = GazeTargeting.GetTargetCandidateTokens(View, Workspace, localPt.X, localPt.Y);

                    // draw singleton layers (coordinate-based)
                    LayerManager.DrawSingletonLayers(localPt.X, localPt.Y);

                    // draw highlights around gazed elements
                    LayerManager.ScrubLayers();
                    foreach (GazeTarget element in gazedElements.OrderByDescending(el => el.Weight))
                    {
                        var span = new SnapshotSpan(View.TextSnapshot, element.DefinitionLocation.Start, element.DefinitionLocation.Length);
                        if (!LayerManager.IsTracking(span))
                        {
                            // gradate opacity of the debug layer based on target weights (on green)
                            LayerManager.Layers.Add(new TextHighlightInformationalGazeLayerElement(View, span, element.Weight));
                        }

                        var model = EditTimeVisualizerModel.Create(element);
                        if (model != null && model.IsValid)
                        {
                            LayerManager.Layers.Add(new EditTimeVisualizationLayer(View, span, model));
                        }
                    }
                    LayerManager.Draw();
                }
                catch (Exception ex)
                {
                }

                _inFlight = false;
            };
        }