UMD.HCIL.Piccolo.PNode.SetBounds C# (CSharp) Method

SetBounds() public method

Set the bounds of this node to the given values.
These bounds are stored in the local coordinate system of this node.
public SetBounds ( float x, float y, float width, float height ) : bool
x float The new x coordinate of the bounds.
y float The new y coordinate of the bounds.
width float The new width of the bounds.
height float The new height of the bounds.
return bool
		public virtual bool SetBounds(float x, float y, float width, float height) {
			if (bounds.X != x || bounds.Y != y || bounds.Width != width || bounds.Height != height) {
				bounds.X = x;
				bounds.Y = y;
				bounds.Width = width;
				bounds.Height = height;

				InternalUpdateBounds(x, y, width, height);
				InvalidatePaint();
				SignalBoundsChanged();

				// Don't put any invalidating code here or else nodes with volatile bounds will
				// create a soft infinite loop (calling Control.BeginInvoke()) when they validate
				// their bounds.
				return true;
			}
			return false;		
		}

Usage Example

Example #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 = Brushes.Blue;
			n.SetBounds(0, 0, 100, 80);
		
			Canvas.Layer.AddChild(n);
			Canvas.RemoveInputEventListener(Canvas.PanEventHandler);

			Canvas.AddInputEventListener(new GridDragHandler(Canvas));
		}
All Usage Examples Of UMD.HCIL.Piccolo.PNode::SetBounds