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);
        }
Esempio n. 2
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()
        {
            PNode blue = new PNode();

            blue.SetBounds(0, 0, 60, 80);
            blue.Brush = new SolidBrush(Color.Blue);
            Canvas.Layer.AddChild(blue);

            PNode 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 PPanEventHandler());

            base.Initialize();
        }
Esempio n. 4
0
        /// <summary>
        /// Set the form up first time it is run
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();

            //The point is to emulate an OS, so make the window full screen
            WindowState = FormWindowState.Maximized;

            //Shift keyboard focus to the background
            Canvas.Root.DefaultInputManager.KeyboardFocus = Canvas.Camera.ToPickPath();

            //Set up event listeners
            Canvas.ZoomEventHandler.AcceptsEvent = delegate(PInputEventArgs e) { return(e.PickedNode is PCamera && e.IsMouseEvent && AcceptsMouseButton(MouseButtons.Right, e.Button)); };
            Canvas.PanEventHandler.AcceptsEvent  = delegate(PInputEventArgs e) { return(e.PickedNode is PCamera && e.IsMouseEvent && AcceptsMouseButton(MouseButtons.Left, e.Button)); };

            CommandHandler = new ShowInterfaceHandler(Canvas.Camera, new CommandInterface(Canvas.Camera));
            Canvas.Camera.AddInputEventListener(CommandHandler);

            FindHandler = new ShowInterfaceHandler(Canvas.Camera, new FindInterface(this));
            Canvas.Camera.AddInputEventListener(FindHandler);

            DocHandler = new DocCreateHandler(Canvas);
            Canvas.AddInputEventListener(DocHandler);

            //Generate sample documents
            GenerateDocs();
        }
Esempio n. 5
0
        public override void Initialize()
        {
            PPath n1 = PPath.CreateRectangle(0, 0, 100, 80);
            PPath n2 = PPath.CreateEllipse(100, 100, 200, 34);
            PPath n3 = new PPath();

            n3.AddLine(0, 0, 20, 40);
            n3.AddLine(20, 40, 10, 200);
            n3.AddLine(10, 200, 155.444f, 33.232f);
            n3.CloseFigure();
            n3.Brush = Color.Yellow;

            n1.Pen = new System.Drawing.Pen(System.Drawing.Brushes.Red, 5);
            n2.Pen = new System.Drawing.Pen(System.Drawing.Brushes.Black, 0); //Fixed width stroke
            n3.Pen = new System.Drawing.Pen(System.Drawing.Brushes.Black, 0); //Fixed width stroke

            Canvas.Layer.AddChild(n1);
            Canvas.Layer.AddChild(n2);
            Canvas.Layer.AddChild(n3);

            // create a set of bounds handles for reshaping n3, and make them
            // sticky relative to the getCanvas().getCamera().
            PStickyHandleManager sm = new PStickyHandleManager(Canvas.Camera, n3);

            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
            Canvas.AddInputEventListener(new PDragEventHandler());
        }
        public override void Initialize()
        {
            NodeDemo();
            CreateNodeUsingExistingClasses();
            SubclassExistingClasses();
            ComposeOtherNodes();
            CreateCustomNode();

            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
            Canvas.AddInputEventListener(new PDragEventHandler());

            // This will create the actual BirdsEyeView and put it in a Form.
            BirdsEyeView bev = new BirdsEyeView();

            bev.Connect(Canvas, new PLayer[] { Canvas.Layer });
            Form bird = new Form();

            bird.Controls.Add(bev);
            bird.StartPosition = FormStartPosition.Manual;
            bird.Bounds        = new System.Drawing.Rectangle(this.Location.X + this.Width, this.Location.Y, 150, 150);
            bev.Size           = bird.ClientSize;
            bev.Anchor         = bev.Anchor | AnchorStyles.Right | AnchorStyles.Bottom;
            bird.Show();

            // Make sure the BirdsEyeView gets an initial update.
            Canvas.Camera.InvalidatePaint();
        }
Esempio n. 7
0
        public override void Initialize()
        {
            NodeDemo();
            CreateNodeUsingExistingClasses();
            SubclassExistingClasses();
            ComposeOtherNodes();
            CreateCustomNode();

            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
            Canvas.AddInputEventListener(new PDragEventHandler());
        }
        public override void Initialize()
        {
            // Create a new event handler that creates new rectangles on
            // mouse pressed, dragged, release.
            PBasicInputEventHandler rectEventHandler = new RectEventHandler(Canvas);

            // Remove the pan event handler that is installed by default so that it
            // does not conflict with our new rectangle creation event handler.
            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);

            // Register our new event handler.
            Canvas.AddInputEventListener(rectEventHandler);
        }
Esempio n. 9
0
        public override void Initialize()
        {
            PClip clip = new PClip();

            clip.AddEllipse(0, 0, 100, 100);
            clip.Brush = Brushes.Red;

            clip.AddChild(PPath.CreateRectangle(20, 20, 100, 50));
            Canvas.Layer.AddChild(clip);

            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
            Canvas.AddInputEventListener(new PDragEventHandler());
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        public override void Initialize()
        {
            Canvas.PanEventHandler = null;
            Canvas.AddInputEventListener(new PDragEventHandler());

            node1         = PPath.CreateEllipse(0, 0, 100, 100);
            node2         = PPath.CreateEllipse(0, 0, 100, 100);
            link          = PPath.CreateLine(50, 50, 50, 50);
            link.Pickable = false;
            Canvas.Layer.AddChild(node1);
            Canvas.Layer.AddChild(node2);
            Canvas.Layer.AddChild(link);

            node2.TranslateBy(200, 200);

            node1.FullBoundsChanged += new PPropertyEventHandler(node1_FullBoundsChanged);
            node2.FullBoundsChanged += new PPropertyEventHandler(node2_FullBoundsChanged);
        }
Esempio n. 12
0
        public override void Initialize()
        {
            PLayer layer = Canvas.Layer;

            Random r = new Random();

            for (int i = 0; i < 20; i++)
            {
                PPath each = PPath.CreateRectangle(0, 0, 100, 80);
                each.ScaleBy((float)r.NextDouble() * 2);
                each.OffsetBy((float)r.NextDouble() * 1000, (float)r.NextDouble() * 1000);
                each.Brush = new SolidBrush(Color.FromArgb((int)(255 * r.NextDouble()), (int)(255 * r.NextDouble()), (int)(255 * r.NextDouble())));
                each.Pen   = new Pen(Color.FromArgb((int)(255 * r.NextDouble()), (int)(255 * r.NextDouble()), (int)(255 * r.NextDouble())));
                layer.AddChild(each);
            }
            Canvas.AddInputEventListener(new PNavigationEventHandler());

            base.Initialize();
        }
        public override void Initialize()
        {
            //create bar layers
            PLayer rowBarLayer = new PLayer();
            PLayer colBarLayer = new PLayer();

            //create bar nodes
            for (int i = 0; i < 10; i++)
            {
                //create row bar with node row1, row2,...row10
                PText p = new PText("Row " + i);
                p.X     = 0;
                p.Y     = NODE_HEIGHT * i + NODE_HEIGHT;
                p.Brush = Color.White;
                colBarLayer.AddChild(p);

                //create col bar with node col1, col2,...col10
                p       = new PText("Col " + i);
                p.X     = NODE_WIDTH * i + NODE_WIDTH;
                p.Y     = 0;
                p.Brush = Color.White;
                rowBarLayer.AddChild(p);
            }

            //add bar layers to camera
            Canvas.Camera.AddChild(rowBarLayer);
            Canvas.Camera.AddChild(colBarLayer);

            //create matrix nodes
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    PPath path = PPath.CreateRectangle(NODE_WIDTH * j + NODE_WIDTH,
                                                       NODE_HEIGHT * i + NODE_HEIGHT, NODE_WIDTH - 1,
                                                       NODE_HEIGHT - 1);
                    Canvas.Layer.AddChild(path);
                }
            }

            //catch drag event and move bars corresponding
            Canvas.AddInputEventListener(new BarDragEventHandler(Canvas, rowBarLayer, colBarLayer));
        }
        public override void Initialize()
        {
            PLayer layer = Canvas.Layer;

            Random r = new Random();

            for (int i = 0; i < 1000; i++)
            {
                PPath each = PPath.CreateRectangle(0, 0, 100, 80);
                each.ScaleBy((float)r.NextDouble() * 2);
                each.OffsetBy((float)r.NextDouble() * 10000, (float)r.NextDouble() * 10000);
                each.Brush = Color.FromNonPremultiplied((int)(255 * r.NextDouble()), (int)(255 * r.NextDouble()), (int)(255 * r.NextDouble()), 255);
                each.Pen   = new System.Drawing.Pen(System.Drawing.Color.FromArgb((int)(255 * r.NextDouble()), (int)(255 * r.NextDouble()), (int)(255 * r.NextDouble())),
                                                    (float)(1 + (10 * (float)r.NextDouble())));
                layer.AddChild(each);
            }
            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
            Canvas.AddInputEventListener(new PNavigationEventHandler());
        }
Esempio n. 15
0
        public override void Initialize()
        {
            PComposite composite = new PComposite();

            PNode circle    = PPath.CreateEllipse(0, 0, 100, 100);
            PNode rectangle = PPath.CreateRectangle(50, 50, 100, 100);
            PNode text      = new PText("Hello world!");

            composite.AddChild(circle);
            composite.AddChild(rectangle);
            composite.AddChild(text);

            rectangle.RotateBy(45);
            rectangle.Brush = Color.Red;

            text.ScaleBy(2.0f);
            text.Brush = Color.Green;

            Canvas.Layer.AddChild(composite);
            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
            Canvas.AddInputEventListener(new PDragEventHandler());
        }
 public override void Initialize()
 {
     Canvas.RemoveInputEventListener(Canvas.ZoomEventHandler);
     Canvas.AddInputEventListener(new SquiggleHandler(Canvas.Layer));
     base.Initialize();
 }