/// <summary>
        /// Constructs a new PPaintContext.
        /// </summary>
        /// <param name="graphics">
        /// The graphics context to associate with this paint context.
        /// </param>
        /// <param name="canvas">The canvas that the paint context will render on.</param>
        public PPaintContext(Graphics2D graphics, PCanvas canvas)
        {
            this.graphics  = graphics;
            this.canvas    = canvas;
            clipStack      = new Stack();
            localClipStack = new Stack();
            cameraStack    = new Stack();
            transformStack = new Stack();
            RenderQuality  = RenderQuality.HighQuality;

            Region clip = graphics.Clip;

            if (clip.IsInfinite(graphics.Graphics))
            {
                clip = new Region(
                    new Rectangle(-int.MaxValue / 2,
                                  -int.MaxValue / 2,
                                  int.MinValue,
                                  int.MaxValue));
                graphics.Clip = clip;
            }

            localClipStack.Push(graphics.ClipBounds);
            CURRENT_PAINT_CONTEXT = this;
        }
Esempio n. 2
0
 public ZoomController(PCanvas graphEditor)
 {
     this.graphEditor = graphEditor;
     this.camera      = graphEditor.Camera;
     camera.Canvas.ZoomEventHandler = null;
     camera.MouseWheel   += OnMouseWheel;
     graphEditor.KeyDown += OnKeyDown;
 }
Esempio n. 3
0
        public PForm(PCanvas aCanvas)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            if (aCanvas == null)
            {
                canvas = new PCanvas();
            }
            else
            {
                canvas = aCanvas;
            }

            BeforeInitialize();

            //scrollableControl = new PScrollableControl(canvas);
            //AutoScrollCanvas = false;

            //Note: If the main application form, generated by visual studio, is set to
            //extend PForm, the InitializeComponent will set the bounds after this statement
            //Bounds = DefaultFormBounds;

            //this.SuspendLayout();
            canvas.Size = DefaultCanvasSize;
            //scrollableControl.Size = ClientSize;
            //this.Controls.Add(scrollableControl);

            //scrollableControl.Anchor =
            //	AnchorStyles.Bottom |
            //	AnchorStyles.Top |
            //	AnchorStyles.Left |
            //	AnchorStyles.Right;

            this.Controls.Add(canvas);
            //this.ResumeLayout(false);

            //FullScreenMode = fullScreenMode;

            //Force visible
            //this.Visible = true;
            //this.Refresh();

            //Necessary to invalidate the bounds because the state will be incorrect since
            //the message loop did not exist when the inpts were scheduled.
            //this.canvas.Root.InvalidateFullBounds();
            //this.canvas.Root.InvalidatePaint();

            //this.processDelegate = new ProcessDelegate(Initialize);
            //canvas.Invoke(processDelegate);

            canvas.Focus();
            Initialize();
        }
Esempio n. 4
0
 private void InitCanvas()
 {
     Canvas = new PCanvas();
     Canvas.AnimatingRenderQuality   = UMD.HCIL.Piccolo.Util.RenderQuality.HighQuality;
     Canvas.DefaultRenderQuality     = UMD.HCIL.Piccolo.Util.RenderQuality.HighQuality;
     Canvas.InteractingRenderQuality = UMD.HCIL.Piccolo.Util.RenderQuality.HighQuality;
     Canvas.GridFitText      = true;
     Canvas.PanEventHandler  = null;
     Canvas.ZoomEventHandler = null;
 }
Esempio n. 5
0
 public void Dispose()
 {
     //Remove event handlers for memory cleanup
     if (graphEditor != null)
     {
         graphEditor.KeyDown           -= OnKeyDown;
         graphEditor.Camera.MouseWheel -= OnMouseWheel;
     }
     graphEditor = null;
     camera      = null;
 }
Esempio n. 6
0
        /// <summary>
        /// Create a new DocCreateHandler
        /// </summary>
        /// <param Name="owner">The canvas that the documents are created on</param>
        public DocCreateHandler(PCanvas owner)
        {
            //Initialise such that if the user starts typing right away
            //The document will be created in the middle of their current view
            RectangleF curView = owner.Camera.Bounds;
            float      x       = curView.X + (curView.Width / 3);
            float      y       = curView.Y + (curView.Height / 3);

            LastPoint = new PointF(x, y);
            Owner     = owner;
        }
Esempio n. 7
0
		/// <summary>
		/// Constructs a new PPaintContext.
		/// </summary>
		/// <param name="graphics">
		/// The graphics context to associate with this paint context.
		/// </param>
		/// <param name="canvas">The canvas that the paint context will render on.</param>
		public PPaintContext(Graphics graphics, PCanvas canvas) {
			this.graphics = graphics;
			this.canvas = canvas;
			clipStack = new Stack();
			localClipStack = new Stack();
			cameraStack = new Stack();
			transformStack = new Stack();
			RenderQuality = RenderQuality.HighQuality;
			CURRENT_PAINT_CONTEXT = this;

			InitializeStacks();
		}
Esempio n. 8
0
		/// <summary>
		/// This method is called when the render quality is set to high.
		/// </summary>
		/// <param name="graphics">
		/// The graphics context associated with this paint context.
		/// </param>
		/// <param name="canvas">The canvas that this paint context will render on.</param>
		/// <remarks>
		/// Override this method to change how the high render quality is set.
		/// </remarks>
		protected virtual void OnHighRenderQuality(Graphics graphics, PCanvas canvas) {
			// Set default high quality flags.
			graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
			graphics.SmoothingMode = SmoothingMode.HighQuality;
			graphics.TextRenderingHint = GridFitText ? TextRenderingHint.AntiAliasGridFit :
				TextRenderingHint.AntiAlias;
			graphics.CompositingQuality = CompositingQuality.HighQuality;
			graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

			// Notify the canvas.
			if (canvas != null && canvas.HighRenderQuality != null) {
				canvas.HighRenderQuality(graphics);
			}
		}
Esempio n. 9
0
 void Update()
 {
     if (bpush)
     {
         AlNum = AlNum + ChangeSpeed;
     }
     else
     {
         AlNum = AlNum - ChangeSpeed;
     }
     AlNum = Mathf.Clamp(AlNum, .0f, 1.0f);
     ThisCanvas.SetAlpha((1.0f - AlNum));
     PCanvas.SetAlpha(AlNum);
 }
Esempio n. 10
0
		/// <summary>
		/// This method is called when the render quality is set to low.
		/// </summary>
		/// <param name="graphics">
		/// The graphics context associated with this paint context.
		/// </param>
		/// <param name="canvas">The canvas that this paint context will render on.</param>
		/// <remarks>
		/// Override this method to change how the low render quality is set.
		/// </remarks>
		protected virtual void OnLowRenderQuality(Graphics graphics, PCanvas canvas) {
			// Set default low quality flags.
			graphics.InterpolationMode = InterpolationMode.Low;
			graphics.SmoothingMode = SmoothingMode.HighSpeed;
			graphics.TextRenderingHint = GridFitText ? TextRenderingHint.SingleBitPerPixelGridFit
				: TextRenderingHint.SingleBitPerPixel;
			graphics.CompositingQuality = CompositingQuality.HighSpeed;
			graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;

			// Notify the canvas.
			if (canvas != null && canvas.LowRenderQuality != null) {
				canvas.LowRenderQuality(graphics);
			}
		}
Esempio n. 11
0
        public override void Initialize()
        {
            // Create a green and red node and add them to canvas layer.
            PCanvas canvas    = Canvas;
            PNode   nodeGreen = PPath.CreateRectangle(0, 0, 100, 100);
            PNode   nodeRed   = PPath.CreateRectangle(0, 0, 100, 100);

            nodeRed.TranslateBy(200, 0);
            nodeGreen.Brush = Color.Green;
            nodeRed.Brush   = Color.Red;
            canvas.Layer.AddChild(nodeGreen);
            canvas.Layer.AddChild(nodeRed);

            nodeGreen.AddInputEventListener(new GreenInputEventListener());
            nodeRed.AddInputEventListener(new RedInputEventListener());

            // Or, delegates could be used to add each eventhandler such as
            // nodeGreen.MouseDown += new PInputEventHandler(nodeGreen_MouseDown);
            // However, overriding the PBasicInputEventHandler is the preferred
            // approach
        }
Esempio n. 12
0
        /// <summary>
        /// Sets up the form, sizing and anchoring the canvas.
        /// </summary>
        /// <param name="fullScreenMode">
        /// Indicates whether or not to start up in full screen mode.
        /// </param>
        /// <param name="aCanvas">
        /// The canvas to add to this PForm; can be null.
        /// </param>
        public void InitializePiccolo(bool fullScreenMode, PCanvas aCanvas)
        {
            if (aCanvas == null)
            {
                canvas = new PCanvas();
            }
            else
            {
                canvas = aCanvas;
            }

            canvas.Focus();
            BeforeInitialize();

            scrollableControl = new PScrollableControl(canvas);
            AutoScrollCanvas  = false;

            //Note: If the main application form, generated by visual studio, is set to
            //extend PForm, the InitializeComponent will set the bounds after this statement
            Bounds = DefaultFormBounds;

            this.SuspendLayout();
            canvas.Size            = ClientSize;
            scrollableControl.Size = ClientSize;
            this.Controls.Add(scrollableControl);

            scrollableControl.Anchor =
                AnchorStyles.Bottom |
                AnchorStyles.Top |
                AnchorStyles.Left |
                AnchorStyles.Right;

            this.ResumeLayout(false);

            FullScreenMode = fullScreenMode;
        }
Esempio n. 13
0
 /// <summary>
 /// Constructs a new PControl,
 /// setting the current canvas to the given canvas.
 /// </summary>
 /// <param name="currentCanvas">
 /// The canvas to add the control to when <see cref="Editing"/> is turned on.
 /// </param>
 public PControl(PCanvas currentCanvas)
 {
     this.currentCanvas = currentCanvas;
 }
Esempio n. 14
0
 /// <summary>
 /// Constructs a new PControl, wrapping the given
 /// <see cref="System.Windows.Forms.Control">System.Windows.Forms.Control</see> and
 /// setting the current canvas to the given canvas.
 /// </summary>
 /// <param name="control">The control to wrap.</param>
 /// <param name="currentCanvas">
 /// The canvas to add the control to when <see cref="Editing"/> is turned on.
 /// </param>
 public PControl(Control control, PCanvas currentCanvas)
 {
     this.currentCanvas = currentCanvas;
     this.Control       = control;
 }
Esempio n. 15
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());
        }
Esempio n. 16
0
        /// <summary>
        /// Constructs a new PPaintContext.
        /// </summary>
        /// <param name="graphics">
        /// The graphics context to associate with this paint context.
        /// </param>
        /// <param name="canvas">The canvas that the paint context will render on.</param>
        public PPaintContext(Graphics2D graphics, PCanvas canvas)
        {
            this.graphics = graphics;
            this.canvas = canvas;
            clipStack = new Stack();
            localClipStack = new Stack();
            cameraStack = new Stack();
            transformStack = new Stack();
            RenderQuality = RenderQuality.HighQuality;

            Region clip = graphics.Clip;
            if (clip.IsInfinite(graphics.Graphics)) {
                clip = new Region(
                    new Rectangle(-int.MaxValue / 2,
                    -int.MaxValue / 2,
                    int.MinValue,
                    int.MaxValue));
                graphics.Clip = clip;
            }

            localClipStack.Push(graphics.ClipBounds);
            CURRENT_PAINT_CONTEXT = this;
        }
Esempio n. 17
0
		/// <summary>
		/// This method is called when the render quality is set to low.
		/// </summary>
		/// <param name="graphics">
		/// The graphics context associated with this paint context.
		/// </param>
		/// <param name="canvas">The canvas that this paint context will render on.</param>
		/// <remarks>
		/// Override this method to change how the low render quality is set.
		/// </remarks>
		protected virtual void OnLowRenderQuality(Graphics graphics, PCanvas canvas) {
			// Set default low quality flags.
			graphics.InterpolationMode = InterpolationMode.Low;
			graphics.SmoothingMode = SmoothingMode.HighSpeed;
			graphics.TextRenderingHint = GridFitText ? TextRenderingHint.SingleBitPerPixelGridFit
				: TextRenderingHint.SingleBitPerPixel;
			graphics.CompositingQuality = CompositingQuality.HighSpeed;
			graphics.PixelOffsetMode = PixelOffsetMode.HighSpeed;

			// Notify the canvas.
			if (canvas != null && canvas.LowRenderQuality != null) {
				canvas.LowRenderQuality(graphics);
			}
		}
Esempio n. 18
0
		/// <summary>
		/// Constructs a new PPaintContext.
		/// </summary>
		/// <param name="graphics">
		/// The graphics context to associate with this paint context.
		/// </param>
		/// <param name="canvas">The canvas that the paint context will render on.</param>
		public PPaintContext(Graphics graphics, PCanvas canvas) {
			this.graphics = graphics;
			this.canvas = canvas;
			clipStack = new Stack();
			localClipStack = new Stack();
			cameraStack = new Stack();
			transformStack = new Stack();
			RenderQuality = RenderQuality.HighQuality;
			CURRENT_PAINT_CONTEXT = this;

			InitializeStacks();
		}
Esempio n. 19
0
 /// <summary>
 /// Constructs a new PScrollableControl that scrolls the given canvas.
 /// </summary>
 /// <param name="view"></param>
 public PScrollableControl(PCanvas view)
 {
     Canvas = view;
 }
Esempio n. 20
0
		/// <summary>
		/// This method is called when the render quality is set to high.
		/// </summary>
		/// <param name="graphics">
		/// The graphics context associated with this paint context.
		/// </param>
		/// <param name="canvas">The canvas that this paint context will render on.</param>
		/// <remarks>
		/// Override this method to change how the high render quality is set.
		/// </remarks>
		protected virtual void OnHighRenderQuality(Graphics graphics, PCanvas canvas) {
			// Set default high quality flags.
			graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
			graphics.SmoothingMode = SmoothingMode.HighQuality;
			graphics.TextRenderingHint = GridFitText ? TextRenderingHint.AntiAliasGridFit :
				TextRenderingHint.AntiAlias;
			graphics.CompositingQuality = CompositingQuality.HighQuality;
			graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;

			// Notify the canvas.
			if (canvas != null && canvas.HighRenderQuality != null) {
				canvas.HighRenderQuality(graphics);
			}
		}
Esempio n. 21
0
 /// <summary>
 /// Constructs a new PForm, with the given canvas, in full screen mode if
 /// specified.
 /// </summary>
 /// <param name="fullScreenMode">
 /// Determines whether this PForm starts in full screen mode.
 /// </param>
 /// <param name="aCanvas">The canvas to add to this PForm.</param>
 /// <remarks>
 /// A <c>null</c> value can be passed in for <c>aCanvas</c>, in which a case
 /// a new canvas will be created.
 /// </remarks>
 public PForm(bool fullScreenMode, PCanvas aCanvas)
 {
     InitializeComponent();
     InitializePiccolo(fullScreenMode, aCanvas);
 }