Esempio n. 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));
        }
Esempio n. 2
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();
        }
Esempio n. 3
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);
        }
        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();
        }
Esempio n. 5
0
        public override void Initialize()
        {
            PLayer l = new PLayer();
            PPath  n = PPath.CreateEllipse(0, 0, 100, 80);

            n.Brush = Brushes.Red;
            n.Pen   = null;
            PBoundsHandle.AddBoundsHandlesTo(n);
            l.AddChild(n);
            n.TranslateBy(200, 200);

            PCamera c = new PCamera();

            c.SetBounds(0, 0, 100, 80);
            c.ScaleViewBy(0.1f);
            c.AddLayer(l);
            PBoundsHandle.AddBoundsHandlesTo(c);
            c.Brush = Brushes.Yellow;

            Canvas.Layer.AddChild(l);
            Canvas.Layer.AddChild(c);
        }
Esempio n. 6
0
        public override void Initialize()
        {
            PLayer   l = new PLayer();
            PEllipse n = new PEllipse();

            n.SetBounds(0, 0, 100, 80);
            n.Brush = new SolidBrush(Color.Red);
            PBoundsHandle.AddBoundsHandlesTo(n);
            l.AddChild(n);
            n.TranslateBy(100, 100);

            PCamera c = new PCamera();

            c.SetBounds(0, 0, 100, 80);
            c.ScaleViewBy(0.1f);
            c.AddLayer(l);
            PBoundsHandle.AddBoundsHandlesTo(c);
            c.Brush = new SolidBrush(Color.Yellow);

            Canvas.Layer.AddChild(l);
            Canvas.Layer.AddChild(c);

            base.Initialize();
        }
Esempio n. 7
0
 /// <summary>
 /// Add the layer at the given index in the list of layers managed by the camera child
 /// of this lens.
 /// </summary>
 /// <param name="index">The index at which to add the layer.</param>
 /// <param name="layer">The layer to add to the camera child of this lens.</param>
 public virtual void AddLayer(int index, PLayer layer)
 {
     camera.AddLayer(index, layer);
 }
Esempio n. 8
0
        public override void Initialize()
        {
            // Add a standard pnode to the scene graph.
            PNode aNode = new PNode();

            aNode.SetBounds(0, 70, 15, 15);
            aNode.Brush = Brushes.Blue;
            Canvas.Layer.AddChild(aNode);

            // Create a button.
            Button button = new Button();

            button.Text      = "Hello";
            button.Bounds    = new Rectangle(10, 10, 10, 10);
            button.BackColor = SystemColors.Control;

            // Wrap the button in a PControl and
            // add it to the scene graph.
            PControl cn = new PControl(button);

            Canvas.Layer.AddChild(cn);
            cn.SetBounds(20, 20, 70, 70);

            // Create another button.
            Button otherButton = new Button();

            otherButton.Text      = "123";
            otherButton.Bounds    = new Rectangle(0, 0, 15, 45);
            otherButton.BackColor = SystemColors.Control;

            // Wrap the second button in another PControl and
            // add it to the scene graph.
            PControl cn2 = new PControl(otherButton, PCanvas.CURRENT_PCANVAS);

            cn2.ScaleBy(1.1f);
            Canvas.Layer.AddChild(cn2);

            // Create a tabcontrol
            TabControl tabControl = new TabControl();

            tabControl.Size = new Size(60, 60);
            tabControl.TabPages.Add(new TabPage("P1"));
            tabControl.TabPages.Add(new TabPage("P2"));

            // Wrap the tabcontrol in a PControl and
            // add it the scene graph.
            PControl cn3 = new PControl(tabControl);

            cn3.ScaleBy(1.2f);
            cn3.TranslateBy(0, 100);
            Canvas.Layer.AddChild(cn3);

            // Create an internal camera that looks at the main layer.
            PCamera internalCamera = new PCamera();

            internalCamera.TranslateViewBy(145, 145);
            internalCamera.ScaleViewBy(.5f);
            internalCamera.SetBounds(130, 130, 200, 200);
            internalCamera.Brush = Brushes.Yellow;
            internalCamera.AddLayer(Canvas.Layer);
            Canvas.Camera.AddChild(internalCamera);

            Canvas.Layer.ScaleBy(1.3f);

            // Create another canvas.
            PCamera otherCamera = new PCamera();

            otherCamera.AddLayer(Canvas.Layer);
            Canvas.Root.AddChild(otherCamera);

            PCanvas other = new PCanvas();

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

            result.StartPosition = FormStartPosition.Manual;
            result.Location      = new Point(this.Location.X + this.Width, this.Location.Y);
            result.Size          = this.Size;
            result.Show();

            // Add the control event handler to both canvas' cameras.
            Canvas.Camera.AddInputEventListener(new PControlEventHandler());
            other.Camera.AddInputEventListener(new PControlEventHandler());
        }