public override void Initialize() { for (int i=0; i<5; i++) { for (int j=0; j<5; j++) { PNode rect = PPath.CreateRectangle(i*60, j*60, 50, 50); rect.Brush = Brushes.Blue; Canvas.Layer.AddChild(rect); } } // Turn off default navigation event handlers Canvas.RemoveInputEventListener(Canvas.PanEventHandler); Canvas.RemoveInputEventListener(Canvas.ZoomEventHandler); // Create a selection event handler PSelectionEventHandler selectionEventHandler = new PSelectionEventHandler(Canvas.Layer, Canvas.Layer); Canvas.AddInputEventListener(selectionEventHandler); Canvas.Root.DefaultInputManager.KeyboardFocus = Canvas.Camera.ToPickPath(); PNotificationCenter.DefaultCenter.AddListener(this, "selectionChanged", PSelectionEventHandler.SELECTION_CHANGED_NOTIFICATION, selectionEventHandler); }
public override void Initialize() { Canvas.RemoveInputEventListener(Canvas.PanEventHandler); // Create a decorator group that is NOT volatile DecoratorGroup dg = new DecoratorGroup(); dg.Brush = Brushes.Magenta; // Put some nodes under the group for it to decorate PPath p1 = PPath.CreateEllipse(25,25,75,75); p1.Brush = Brushes.Red; PPath p2 = PPath.CreateRectangle(125,75,50,50); p2.Brush = Brushes.Blue; // Add everything to the Piccolo hierarchy dg.AddChild(p1); dg.AddChild(p2); Canvas.Layer.AddChild(dg); // Create a decorator group that IS volatile VolatileDecoratorGroup vdg = new VolatileDecoratorGroup(Canvas.Camera); vdg.Brush = Brushes.Cyan; // Put some nodes under the group for it to decorate PPath p3 = PPath.CreateEllipse(275,175,50,50); p3.Brush = Brushes.Blue; PPath p4 = PPath.CreateRectangle(175,175,75,75); p4.Brush = Brushes.Green; // Add everything to the Piccolo hierarchy vdg.AddChild(p3); vdg.AddChild(p4); Canvas.Layer.AddChild(vdg); // Create a selection handler so we can see that the decorator actually works PNodeList selectableParents = new PNodeList(); selectableParents.Add(dg); selectableParents.Add(vdg); PSelectionEventHandler ps = new PSelectionEventHandler(Canvas.Layer,selectableParents); Canvas.AddInputEventListener(ps); }
/// <summary> /// Constructs a new BoundsFilter with the given bounds and selectionHandler. /// </summary> /// <param name="bounds"> /// The bounds to use when deciding whether to accept a node. /// </param> /// <param name="selectionHandler"> /// The selection event handler to which this BoundsFilter will apply. /// </param> public BoundsFilter(RectangleF bounds, PSelectionEventHandler selectionHandler) { this.bounds = bounds; this.selectionHandler = selectionHandler; }