Пример #1
0
        public override void Initialize()
        {
            PRoot   root   = Canvas.Root;
            PCamera camera = Canvas.Camera;

            //PLayer gridLayer = new GridLayer();

            // replace standard layer with grid layer.
            root.RemoveChild(camera.GetLayer(0));
            camera.RemoveLayer(0);
            root.AddChild(gridLayer);
            camera.AddLayer(gridLayer);

            // add constraints so that grid layers bounds always match cameras view bounds. This makes
            // it look like an infinite grid.
            camera.BoundsChanged        += new PPropertyEventHandler(camera_BoundsChanged);
            camera.ViewTransformChanged += new PPropertyEventHandler(camera_ViewTransformChanged);

            gridLayer.Bounds = camera.ViewBounds;

            PNode n = new PNode();

            n.Brush = Color.Blue;
            n.SetBounds(0, 0, 100, 80);

            Canvas.Layer.AddChild(n);
            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);

            Canvas.AddInputEventListener(new GridDragHandler(Canvas));
        }
        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();
        }
        /// <summary>
        /// Installs the scroll director and adds the appropriate handlers.
        /// </summary>
        /// <param name="scrollableControl">
        /// The scrollable control on which this director directs.
        /// </param>
        /// <param name="view">The PCanvas that the scrollable control scrolls.</param>
        public virtual void Install(PScrollableControl scrollableControl, PCanvas view)
        {
            this.scrollableControl = scrollableControl;
            this.view = view;

            if (view != null)
            {
                this.camera = view.Camera;
                this.root   = view.Root;
            }

            if (camera != null)
            {
                camera.ViewTransformChanged += new PPropertyEventHandler(camera_ViewTransformChanged);
                camera.BoundsChanged        += new PPropertyEventHandler(camera_BoundsChanged);
                camera.FullBoundsChanged    += new PPropertyEventHandler(camera_FullBoundsChanged);
            }
            if (root != null)
            {
                root.BoundsChanged     += new PPropertyEventHandler(root_BoundsChanged);
                root.FullBoundsChanged += new PPropertyEventHandler(root_FullBoundsChanged);
            }

            if (scrollableControl != null)
            {
                scrollableControl.UpdateScrollbars();
            }
        }
Пример #4
0
        public override void Initialize()
        {
            PRoot  root  = Canvas.Root;
            PLayer layer = Canvas.Layer;

            PNode n      = PPath.CreateRectangle(0, 0, 100, 80);
            PNode sticky = PPath.CreateRectangle(0, 0, 50, 50);

            PBoundsHandle.AddBoundsHandlesTo(n);
            sticky.Brush = Color.Yellow;
            PBoundsHandle.AddBoundsHandlesTo(sticky);

            layer.AddChild(n);
            Canvas.Camera.AddChild(sticky);

            PCamera otherCamera = new PCamera();

            otherCamera.AddLayer(layer);
            root.AddChild(otherCamera);

            PCanvas other = new PCanvas();

            other.Camera = otherCamera;
            PForm result = new PForm(false, other);

            result.StartPosition = FormStartPosition.Manual;
            result.Location      = new System.Drawing.Point(this.Location.X + this.Width, this.Location.Y);
            result.Size          = this.Size;
            result.Show();
        }
Пример #5
0
        /// <summary>
        /// Creates a basic scene graph.
        /// </summary>
        /// <returns>The main camera node in the new scene graph.</returns>
        /// <remarks>
        /// The scene graph will consist of  root node with two children, a layer and a
        /// camera.  Additionally, The camera will be set to view the layer.  Typically,
        /// you will want to add new nodes to the layer.
        /// </remarks>
        public static PCamera CreateBasicScenegraph()
        {
            PRoot   r = new PRoot();
            PLayer  l = new PLayer();
            PCamera c = new PCamera();

            r.AddChild(c);
            r.AddChild(l);
            c.AddLayer(l);

            return(c);
        }
Пример #6
0
        /// <summary>
        /// Overridden.  Creats a scene graph with a <see cref="PCacheCamera">PCacheCamera</see>
        /// as the main camera.
        /// </summary>
        protected override PCamera CreateBasicScenegraph()
        {
            PRoot   r = new PRoot();
            PLayer  l = new PLayer();
            PCamera c = new PCacheCamera();

            r.AddChild(c);
            r.AddChild(l);
            c.AddLayer(l);

            return(c);
        }
        public override void Initialize()
        {
            PRoot   root          = Canvas.Root;
            PCamera camera        = Canvas.Camera;
            PLayer  mainLayer     = Canvas.Layer;               // viewed by the PCanvas camera, the lens is added to this layer.
            PLayer  sharedLayer   = new PLayer();               // viewed by both the lens camera and the PCanvas camera
            PLayer  lensOnlyLayer = new PLayer();               // viewed by only the lens camera

            root.AddChild(lensOnlyLayer);
            root.AddChild(sharedLayer);
            camera.AddLayer(0, sharedLayer);

            PLens lens = new PLens();

            lens.SetBounds(10, 10, 80, 110);
            lens.AddLayer(0, lensOnlyLayer);
            lens.AddLayer(1, sharedLayer);
            mainLayer.AddChild(lens);
            PBoundsHandle.AddBoundsHandlesTo(lens);

            // Create an event handler that draws squiggles on the first layer of the bottom
            // most camera.
            PDragSequenceEventHandler squiggleEventHandler = new SquiggleEventHandler();

            // add the squiggle event handler to both the lens and the
            // canvas camera.
            lens.Camera.AddInputEventListener(squiggleEventHandler);
            camera.AddInputEventListener(squiggleEventHandler);

            // remove default event handlers, not really nessessary since the squiggleEventHandler
            // consumes everything anyway, but still good to do.
            //Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
            Canvas.RemoveInputEventListener(Canvas.ZoomEventHandler);

            PNode sharedNode = new SharedNode(lens);

            sharedNode.Brush = new SolidBrush(Color.Green);             // Brushes.Green;
            sharedNode.SetBounds(0, 0, 100, 200);
            sharedNode.TranslateBy(100, 220);
            sharedLayer.AddChild(sharedNode);

            PText label = new PText("Move the lens \n (by dragging title bar) over the green rectangle, and it will appear red. press and drag the mouse on the canvas and it will draw squiggles. press and drag the mouse over the lens and drag squiggles that are only visible through the lens.");

            label.Font = new Font("Arial", 10, FontStyle.Regular);
            label.ConstrainWidthToTextWidth = false;
            label.SetBounds(100, 70, 130, 200);

            sharedLayer.AddChild(label);

            base.Initialize();
        }
Пример #8
0
        protected void ActivityStepped(PActivity activity)
        {
            PRoot root = Canvas.Root;

            if (root.PaintInvalid || root.ChildPaintInvalid)
            {
                PNodeList cameraChildren = Canvas.Camera.ChildrenReference;
                foreach (PNode each in cameraChildren)
                {
                    if (each is PHandle)
                    {
                        PHandle handle = (PHandle)each;
                        handle.RelocateHandle();
                    }
                }
            }
        }
Пример #9
0
        /// <summary>
        /// This copies the behavior of the standard
        /// <see cref="PCamera.AnimateViewToMatrix">AnimateViewToMatrix</see> but clears the cache
        /// when it is done.
        /// </summary>
        /// <param name="destination">The final matrix value.</param>
        /// <param name="duration">The amount of time that the animation should take.</param>
        /// <returns>
        /// The newly scheduled activity, if the duration is greater than 0; else null.
        /// </returns>
        protected PTransformActivity AnimateStaticViewToTransformFast(Matrix destination, long duration)
        {
            if (duration == 0)
            {
                this.ViewMatrix = destination;
                return(null);
            }

            PTransformActivity ta = new FastTransformActivity(this, duration, PUtil.DEFAULT_ACTIVITY_STEP_RATE, new PCamera.PCameraTransformTarget(this), destination);

            PRoot r = Root;

            if (r != null)
            {
                r.ActivityScheduler.AddActivity(ta);
            }

            return(ta);
        }
        /// <summary>
        /// Uninstalls the scroll director from the scrollable control.
        /// </summary>
        public virtual void UnInstall()
        {
            scrollableControl = null;
            view = null;

            if (camera != null)
            {
                camera.ViewTransformChanged -= new PPropertyEventHandler(camera_ViewTransformChanged);
                camera.BoundsChanged        -= new PPropertyEventHandler(camera_BoundsChanged);
                camera.FullBoundsChanged    -= new PPropertyEventHandler(camera_FullBoundsChanged);
            }
            if (root != null)
            {
                root.BoundsChanged     -= new PPropertyEventHandler(root_BoundsChanged);
                root.FullBoundsChanged -= new PPropertyEventHandler(root_FullBoundsChanged);
            }

            camera = null;
            root   = null;
        }
Пример #11
0
        public override void Initialize()
        {
            Canvas.RegionManagement = true;
            PLayer layer = Canvas.Layer;
            PRoot  root  = Canvas.Root;
            Random r     = new Random();

            for (int i = 0; i < 400; i++)
            {
                PNode n = PPath.CreateRectangle(0, 0, 100, 80);
                n.TranslateBy(10000 * (float)r.NextDouble(), 10000 * (float)r.NextDouble());
                n.Brush = Color.FromNonPremultiplied((int)(255 * r.NextDouble()), (int)(255 * r.NextDouble()), (int)(255 * r.NextDouble()), 255);
                layer.AddChild(n);
            }
            Canvas.Camera.AnimateViewToCenterBounds(layer.GlobalFullBounds, true, 0);
            PActivity a = new PActivity(-1, 20);

            a.ActivityStepped = new ActivitySteppedDelegate(ActivityStepped);
            root.AddActivity(a);
        }
Пример #12
0
        public override void Initialize()
        {
            PRoot              root      = Canvas.Root;
            PLayer             layer     = Canvas.Layer;
            PActivityScheduler scheduler = root.ActivityScheduler;

            PNode singlePulse        = PPath.CreateRectangle(0, 0, 100, 80);;
            PPath repeatPulse        = PPath.CreateRectangle(100, 80, 100, 80);;
            PNode repeatReversePulse = PPath.CreateRectangle(200, 160, 100, 80);;

            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);
        }
Пример #13
0
 /// <summary>
 /// Constructs a new PActivityScheduler.
 /// </summary>
 /// <param name="rootNode">The root node to associate with this activity scheduler.</param>
 public PActivityScheduler(PRoot rootNode)
 {
     root                 = rootNode;
     activities           = new PActivityList();
     processingActivities = new PActivityList();
 }