예제 #1
0
        public override void Initialize()
        {
            PRoot root = Canvas.Root;
            PLayer layer = Canvas.Layer;
            PActivityScheduler scheduler = root.ActivityScheduler;

            PNode singlePulse = new PNode();
            singlePulse.Brush = new SolidBrush(Color.White);
            singlePulse.SetBounds(0, 0, 60, 60);
            PNode repeatPulse = new PNode();
            repeatPulse.Brush = new SolidBrush(Color.White);
            repeatPulse.SetBounds(60, 60, 60, 60);;
            PNode repeatReversePulse = new PNode();
            repeatReversePulse.Brush = new SolidBrush(Color.White);
            repeatReversePulse.SetBounds(120, 120, 60, 60);

            layer.AddChild(singlePulse);
            layer.AddChild(repeatPulse);
            layer.AddChild(repeatReversePulse);

            PColorActivity singlePulseActivity = new PColorActivity(1000, 0, 1, ActivityMode.SourceToDestination, new PulseTarget(singlePulse), Color.Orange);
            PColorActivity repeatPulseActivity = new PColorActivity(1000, 0, 5, ActivityMode.SourceToDestination, new PulseTarget(repeatPulse), Color.Blue);
            PColorActivity repeatReversePulseActivity = new PColorActivity(500, 0, 10, ActivityMode.SourceToDestination, new PulseTarget(repeatReversePulse), Color.Green);

            scheduler.AddActivity(singlePulseActivity);
            scheduler.AddActivity(repeatPulseActivity);
            scheduler.AddActivity(repeatReversePulseActivity);

            base.Initialize ();
        }
예제 #2
0
 /// <summary>
 /// Adds bounds handles to the given node.
 /// </summary>
 /// <param name="aNode">The node to add bounds handles to.</param>
 public static void AddBoundsHandlesTo(PNode aNode)
 {
     //aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateEastLocator(aNode)));
     //aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateWestLocator(aNode)));
     //aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthLocator(aNode)));
     //aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthLocator(aNode)));
     aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthEastLocator(aNode)));
     aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthWestLocator(aNode)));
     aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthEastLocator(aNode)));
     aNode.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthWestLocator(aNode)));
 }
예제 #3
0
        public override void Initialize()
        {
            long currentTime = PUtil.CurrentTimeMillis;

            // Create a new node that we will apply different activities to, and
            // place that node at location 200, 200.
            aNode = new PNode();  //PPath.CreateRectangle(0, 0, 100, 80);
            aNode.SetBounds(0, 0, 100, 80);
            aNode.Brush = new SolidBrush(Color.Blue);
            PLayer layer = Canvas.Layer;
            layer.AddChild(aNode);
            aNode.SetOffset(200, 200);

            // Create a new custom "flash" activity. This activity will start running in
            // five seconds, and while it runs it will flash aNode's brush color between
            // red and green every half second.  The same effect could be achieved by
            // extending PActivity and override OnActivityStep.
            PActivity flash = new PActivity(-1, 500, currentTime + 5000);
            flash.ActivityStepped = new ActivitySteppedDelegate(ActivityStepped);

            Canvas.Root.AddActivity(flash);

            // Use the PNode animate methods to create three activities that animate
            // the node's position. Since our node already descends from the root node the
            // animate methods will automatically schedule these activities for us.
            PActivity a1 = aNode.AnimateToPositionScale(0f, 0f, 0.5f, 5000);
            PActivity a2 = aNode.AnimateToPositionScale(100f, 0f, 1.5f, 5000);
            //PActivity a3 = aNode.AnimateToPositionScale(200f, 100f, 1f, 5000);
            PActivity a3 = aNode.AnimateToPositionScale(20f, 200f, 1f, 5000);

            // the animate activities will start immediately (in the next call to PRoot.processInputs)
            // by default. Here we set their start times (in PRoot global time) so that they start
            // when the previous one has finished.
            a1.StartTime = currentTime;

            a2.StartAfter(a1);
            a3.StartAfter(a2);

            // or the previous three lines could be replaced with these lines for the same effect.
            //a2.setStartTime(currentTime + 5000);
            //a3.setStartTime(currentTime + 10000);

            base.Initialize ();
        }
예제 #4
0
        public override void Initialize()
        {
            PNode blue = new PNode();
            blue.SetBounds(0, 0, 60, 80);
            blue.Brush = new SolidBrush(Color.Blue);
            Canvas.Layer.AddChild(blue);

            PEllipse red = new PEllipse();
            red.SetBounds(50, 30, 60, 45);
            red.Brush = new SolidBrush(Color.Red);
            Canvas.Layer.AddChild(red);

            Bitmap bm = new Bitmap(GetType().Module.Assembly.GetManifestResourceStream("PocketPiccoloFeatures.hcil.bmp"));
            PImage image = new PImage(bm);
            image.SetBounds(80, 100, image.Width, image.Height);
            Canvas.Layer.AddChild(image);

            Canvas.ZoomEventHandler = null;
            Canvas.AddInputEventListener(new PDragEventHandler());

            base.Initialize ();
        }
예제 #5
0
 /// <summary>
 /// Pass the given repaint request up the tree, so that any cameras
 ///	can invalidate that region on their associated canvas.
 /// </summary>
 /// <param name="bounds">
 /// The bounds to repaint, specified in the local coordinate system.
 /// </param>
 /// <param name="childOrThis">
 /// If childOrThis does not equal this then this node's matrix will
 /// be applied to the bounds paramater.
 /// </param>
 public virtual void RepaintFrom(RectangleF bounds, PNode childOrThis)
 {
     if (parent != null) {
         if (childOrThis != this) {
             bounds = LocalToParent(bounds);
         } else if (!Visible) {
             return;
         }
         parent.RepaintFrom(bounds, this);
     }
 }
예제 #6
0
 /// <summary>
 /// Change the order of this node in its parent's children list so that
 /// it will draw after the given sibling node.
 /// </summary>
 /// <param name="sibling">The sibling to move in front of.</param>
 public void MoveInFrontOf(PNode sibling)
 {
     PNode p = parent;
     if (p != null && p == sibling.Parent) {
         p.RemoveChild(this);
         int index = p.IndexOfChild(sibling);
         p.AddChild(index + 1, this);
     }
 }
예제 #7
0
 /// <summary>
 /// Remove the given child from this node's children list.
 /// </summary>
 /// <param name="child">The child to remove.</param>
 /// <remarks>
 /// Any subsequent children are shifted to the left (one is subtracted 
 /// from their indices). The removed child’s parent is set to null.
 /// </remarks>
 public virtual void RemoveChild(PNode child)
 {
     RemoveChild(IndexOfChild(child));
 }
 /// <summary>
 /// Ends a standard selection sequence.
 /// </summary>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 /// <remarks>
 /// <b>Notes to Inheritors:</b>  Subclasses can override this method to be notified
 /// at the end of a standard selection sequence.
 /// <para>
 /// Overriding methods must still call <c>base.EndStandardSelection()</c> for correct
 /// behavior.
 /// </para>
 /// </remarks>
 protected virtual void EndStandardSelection(PInputEventArgs e)
 {
     pressNode = null;
 }
        /// <summary>
        /// Unselects the given node, if it is currently selected.
        /// </summary>
        /// <param name="node">The node to unselect.</param>
        /// <returns>True if the node was unselected; otherwise, false.</returns>
        /// <remarks>
        /// The handles will be removed from the node if it is unselected.
        /// </remarks>
        protected virtual bool InternalUnselect(PNode node)
        {
            if (!IsSelected(node)) {
                return false;
            }

            UndecorateSelectedNode(node);
            selection.Remove(node);
            return true;
        }
예제 #10
0
 /// <summary>
 /// Constructs a new PNodeBoundsActivity
 /// </summary>
 /// <param name="target">The target node.</param>
 /// <param name="dst">The destination bounds.</param>
 /// <param name="duration">The duration of the activity.</param>
 public PNodeBoundsActivity(PNode target, RectangleF dst, long duration)
     : base(duration, PUtil.DEFAULT_ACTIVITY_STEP_RATE)
 {
     this.target = target;
     this.dst = dst;
 }
예제 #11
0
 /// <summary>
 /// Constructs a new PNodeTransformTarget.
 /// </summary>
 /// <param name="target">The target node.</param>
 public PNodeTransformTarget(PNode target)
 {
     this.target = target;
 }
 /// <summary>
 /// Sets the initial press point and press node for the selection.
 /// </summary>
 /// <param name="e">A PInputEventArgs that contains the event data.</param>
 protected virtual void InitializeSelection(PInputEventArgs e)
 {
     canvasPressPt = e.CanvasPosition;
     presspt = e.Position;
     pressNode = e.Path.PickedNode;
     if (pressNode is PCamera) {
         pressNode = null;
     }
 }
예제 #13
0
 //****************************************************************
 // Structure - Methods for manipulating and traversing the
 // parent child relationship
 //
 // Most of these methods won't need to be overridden by subclasses
 // but you will use them frequently to build up your node structures.
 //****************************************************************
 /// <summary>Add a node to be a new child of this node.</summary>
 /// <param name="child">The new child to add to this node.</param>
 /// <remarks>
 /// The new node is added to the end of the list of this node's children.
 /// If child was previously a child of another node, it is removed from that
 /// node first.
 /// </remarks>
 public virtual void AddChild(PNode child)
 {
     int insertIndex = ChildrenCount;
     if (child.Parent == this) {
         insertIndex--;
     }
     AddChild(insertIndex, child);
 }
예제 #14
0
 /// <summary>
 /// Adds sticky bounds handles (with respect to the given camera) to the specified node.
 /// </summary>
 /// <param name="aNode">The node to add sticky bounds handles to.</param>
 /// <param name="camera">The camera to stick the bounds handles to.</param>
 /// <remarks>
 /// Sticky bounds handles are not affected by the view transform of the camera.  That
 /// is, they will remain a constant size as the view is zoomed in and out.
 /// </remarks>
 public static void AddStickyBoundsHandlesTo(PNode aNode, PCamera camera)
 {
     camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateEastLocator(aNode)));
     camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateWestLocator(aNode)));
     camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthLocator(aNode)));
     camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthLocator(aNode)));
     camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthEastLocator(aNode)));
     camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthWestLocator(aNode)));
     camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthEastLocator(aNode)));
     camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthWestLocator(aNode)));
 }
예제 #15
0
 /// <summary>
 /// Removes bounds handles from the given node.
 /// </summary>
 /// <param name="aNode">The node to remove the bounds handles from.</param>
 public static void RemoveBoundsHandlesFrom(PNode aNode)
 {
     PNodeList handles = new PNodeList();
     PNodeList children = aNode.ChildrenReference;
     foreach (PNode each in children) {
         if (each is PBoundsHandle) {
             handles.Add(each);
         }
     }
     aNode.RemoveChildren(handles);
 }
예제 #16
0
 /// <summary>
 /// Constructs a new PNodeLocator that locates points on the given node.
 /// </summary>
 /// <param name="node">The node on which the points are located.</param>
 public PNodeLocator(PNode node)
 {
     Node = node;
 }
예제 #17
0
        //****************************************************************
        // Camera Repaint Notifications - Layer nodes must forward their
        // repaints to each camera that is viewing them so that the camera
        // views will also get repainted.
        //****************************************************************
        /// <summary>
        /// Overridden.  Forward repaints to the cameras that are viewing this layer.
        /// </summary>
        /// <param name="bounds">
        /// The bounds to repaint, specified in the local coordinate system.
        /// </param>
        /// <param name="childOrThis">
        /// If childOrThis does not equal this then this layer's matrix will be
        /// applied to the bounds paramater.
        /// </param>
        public override void RepaintFrom(RectangleF bounds, PNode childOrThis)
        {
            if (childOrThis != this) {
                bounds = LocalToParent(bounds);
            }

            NotifyCameras(bounds);

            if (Parent != null) {
                Parent.RepaintFrom(bounds, childOrThis);
            }
        }
        /// <summary>
        /// Determines if the specified node is selectable (i.e., if it is a child
        /// of a node in the list of selectable parents).
        /// </summary>
        /// <param name="node">The node to test.</param>
        /// <returns>True if the node is selectable; otherwise, false.</returns>
        protected virtual bool IsSelectable(PNode node)
        {
            bool selectable = false;

            foreach (PNode parent in selectableParents) {
                if (parent.ChildrenReference.Contains(node)) {
                    selectable = true;
                    break;
                }
                else if (parent is PCamera) {
                    PCamera cameraParent = (PCamera)parent;
                    for(int i=0; i<cameraParent.LayerCount; i++) {
                        PLayer layer = cameraParent.GetLayer(i);
                        if (layer.ChildrenReference.Contains(node)) {
                            selectable = true;
                            break;
                        }
                    }
                }
            }

            return selectable;
        }
예제 #19
0
        /// <summary>
        /// Set the parent of this node, and transform the node in such a way that it
        /// doesn't move in global coordinates.
        /// </summary>
        /// <param name="newParent">The new parent of this node.</param>
        public virtual void Reparent(PNode newParent)
        {
            PMatrix originalTransform = GlobalToLocalMatrix;
            PMatrix newTransform = newParent.GlobalToLocalMatrix;
            newTransform.Multiply(originalTransform);

            RemoveFromParent();
            Matrix = newTransform;
            newParent.AddChild(this);
            fullBoundsCache = ComputeFullBounds();
        }
예제 #20
0
        /// <summary>
        /// Add a node to be a new child of this node at the specified index.
        /// </summary>
        /// <param name="index">The index at which to add the new child.</param>
        /// <param name="child">The new child to add to this node.</param>
        /// <remarks>
        /// If child was previously a child of another node, it is removed 
        /// from that node first.
        /// </remarks>
        public virtual void AddChild(int index, PNode child)
        {
            PNode oldParent = child.Parent;

            if (oldParent != null) {
                oldParent.RemoveChild(child);
            }

            child.Parent = this;
            ChildrenReference.Insert(index, child);
            child.InvalidatePaint();
            InvalidateFullBounds();
        }
예제 #21
0
 /// <summary>
 /// Swaps this node out of the scene graph tree, and replaces it with the specified
 /// replacement node.
 /// </summary>
 /// <param name="replacementNode">
 /// The new node that replaces the current node in the scene graph tree.
 /// </param>
 /// <remarks>
 /// This node is left dangling, and it is up to the caller to manage it.  The
 /// replacement node will be added to this node's parent in the same position as this node
 /// was located.  That is, if this was the 3rd child of its parent, then after calling
 /// <c>ReplaceWith</c>, the replacement node will also be the 3rd child of its parent.
 ///	If this node has no parent when <c>ReplaceWith</c> is called, then nothing will be
 ///	done at all.
 /// </remarks>
 public virtual void ReplaceWith(PNode replacementNode)
 {
     if (parent != null) {
         PNode myParent = this.parent;
         int index = myParent.ChildrenReference.IndexOf(this);
         myParent.RemoveChild(this);
         myParent.AddChild(index, replacementNode);
     }
 }
예제 #22
0
        //****************************************************************
        // Paint Damage Management - Methods used to invalidate the areas
        // of the screen that that need to be repainted.
        //****************************************************************
        /// <summary>
        /// Overridden.  Repaint this camera, and forward the repaint request to the camera's
        /// canvas if it is not null.
        /// </summary>
        /// <param name="bounds">The bounds to repaint, in local coordinates.</param>
        /// <param name="childOrThis">
        /// If childOrThis does not equal this then this camera's matrix will be applied to the
        /// bounds paramater.
        /// </param>
        public override void RepaintFrom(RectangleF bounds, PNode childOrThis)
        {
            if (Parent != null) {
                if (childOrThis != this) {
                    bounds = LocalToParent(bounds);
                }

                if (Canvas != null) {
                    Canvas.InvalidateBounds(bounds);
                }

                Parent.RepaintFrom(bounds, this);
            }
        }
예제 #23
0
 /// <summary>
 /// Constructs a new PNodeColorTarget
 /// </summary>
 /// <param name="target">The target node.</param>
 public PNodeColorTarget(PNode target)
 {
     this.target = target;
 }
 /// <summary>
 /// Unselects the given node, if it is currently selected, and posts a
 /// SELECTION_CHANGED_NOTIFICATION if the current selection has changed.
 /// </summary>
 /// <param name="node">The node to unselect.</param>
 /// <remarks>
 /// The handles will be removed from the node if it is unselected.
 /// </remarks>
 public virtual void Unselect(PNode node)
 {
     if (InternalUnselect(node)) {
         PostSelectionChanged();
     }
 }
예제 #25
0
 public PulseTarget(PNode node)
 {
     this.node = node;
 }
예제 #26
0
 /// <summary>
 /// Return true if this node is a descendent of the parameter node.
 /// </summary>
 /// <param name="node">A possible descendent node.</param>
 /// <returns>True if this node is a descendent of the given node; else false.</returns>
 public virtual bool IsDescendentOf(PNode node)
 {
     PNode p = parent;
     while (p != null) {
         if (p == node) {
             return true;
         }
         p = p.Parent;
     }
     return false;
 }
예제 #27
0
 /// <summary>
 /// Return the index where the given child is stored.
 /// </summary>
 /// <param name="child">The child whose index is desired.</param>
 /// <returns>The index of the given child.</returns>
 public virtual int IndexOfChild(PNode child)
 {
     if (children == null) return -1;
     return children.IndexOf(child);
 }
        /// <summary>
        /// Selects the given node, if it is not already selected.
        /// </summary>
        /// <param name="node">The node to select.</param>
        /// <returns>True if the node was selected; otherwise, false.</returns>
        /// <remarks>
        /// The node will be decorated with handles if it is selected.
        /// </remarks>
        protected virtual bool InternalSelect(PNode node)
        {
            if (IsSelected(node)) {
                return false;
            }

            selection.Add(node, true);
            DecorateSelectedNode(node);
            return true;
        }
예제 #29
0
        /// <summary>
        /// Repaint from one of the camera's layers.
        /// </summary>
        /// <param name="bounds">The bounds to repaint, in view coordinates.</param>
        /// <param name="repaintedLayer">The layer that was repainted.</param>
        /// <remarks>
        /// The repaint region needs to be transformed from view to local coordinates in
        /// this case.  Unlike most repaint methods in piccolo this one must not modify
        /// the bounds parameter.
        /// </remarks>
        public virtual void RepaintFromLayer(RectangleF bounds, PNode repaintedLayer)
        {
            bounds = ViewToLocal(bounds);

            //if (Bounds.IntersectsWith(bounds)) {
            if (PUtil.RectanglesIntersect(Bounds, bounds)) {
                RectangleF tempRect = PUtil.IntersectionOfRectangles(bounds, Bounds);
                    //RectangleF.Intersect(bounds, Bounds);
                RepaintFrom(tempRect, repaintedLayer);
            }
        }
예제 #30
0
 /// <summary>
 /// Return true if this node is an ancestor of the parameter node.
 /// </summary>
 /// <param name="node">A possible descendent node.</param>
 /// <returns>True if this node is an ancestor of the given node; else false.</returns>
 public virtual bool IsAncestorOf(PNode node)
 {
     PNode p = node.Parent;
     while (p != null) {
         if (p == this)  {
             return true;
         }
         p = p.Parent;
     }
     return false;
 }