Пример #1
0
        /// <summary>
        /// Create and show a new error
        /// </summary>
        /// <param Name="error">The text to display to the user</param>
        /// <param Name="camera">The camera to display the error on</param>
        /// <param Name="duration">How long to display the error for</param>
        public Error(string error, PCamera camera, int duration = 3000)
        {
            //Slightly shade the background to bring attention to the error
            PPath background = PPath.CreateRectangle(0, 0, camera.ViewBounds.Width, camera.ViewBounds.Height);
            background.Brush = new SolidBrush(Color.FromArgb(30, 220, 220, 220));
            AddChild(background);

            //Add the error text to the center of the screen
            PText errorText = new PText(error);
            errorText.ConstrainWidthToTextWidth = false;
            errorText.Font = new Font("Century Gothic", 18);
            errorText.TextAlignment = StringAlignment.Center;

            float height = errorText.Font.Height;
            float width = camera.Canvas.FindForm().Width;
            float y = (camera.Canvas.FindForm().Height - height) / 2;
            errorText.Bounds = new RectangleF(0, y, width, height);

            AddChild(errorText);

            //Display the error
            camera.AddChild(this);

            //Remove the error after the required time
            PActivity dissapear = new PActivity(duration);
            dissapear.ActivityFinished += activityFinished;
            camera.Canvas.Root.AddActivity(dissapear);
        }
		/// <summary>
		/// Sets the camera the bounds handles will be stuck to and the target node that
		/// will be resized by the sticky bounds handles.
		/// </summary>
		/// <param name="newCamera">The camera to stick the bounds handles to.</param>
		/// <param name="newTarget">
		/// The node that will be resized by the sticky bounds handles.
		/// </param>
		public virtual void SetCameraTarget(PCamera newCamera, PNode newTarget) {
			camera = newCamera;
			camera.AddChild(this);
			target = newTarget;
		}
Пример #3
0
		/// <summary>
		/// Adds sticky bounds handles (with respect to the given camera) to the specified node.
		/// </summary>
		/// <param name="aNode">The node to isLocal sticky bounds handles to.</param>
		/// <param name="camera">The camera to stick the bounds handles to.</param>
		/// <remarks>
		/// Sticky bounds handles are not affected by the view transform of the camera.  That
		/// is, they will remain a constant size as the view is zoomed in and out.
		/// </remarks>
		public static void AddStickyBoundsHandlesTo(PNode aNode, PCamera camera) {
			camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateEastLocator(aNode)));
			camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateWestLocator(aNode)));
			camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthLocator(aNode)));
			camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthLocator(aNode)));
			camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthEastLocator(aNode)));
			camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateNorthWestLocator(aNode)));
			camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthEastLocator(aNode)));
			camera.AddChild(new PBoundsHandle(PBoundsLocator.CreateSouthWestLocator(aNode)));
		}