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 = Color.Blue;
            n.SetBounds(0, 0, 100, 80);

            Canvas.Layer.AddChild(n);
            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);

            Canvas.AddInputEventListener(new GridDragHandler(Canvas));
        }
        /// <summary>
        /// Determines if the specified node is selectable (i.e., if it is a child
        /// of a node in the list of selectable parents).
        /// </summary>
        /// <param name="node">The node to test.</param>
        /// <returns>True if the node is selectable; otherwise, false.</returns>
        protected virtual bool IsSelectable(PNode node)
        {
            bool selectable = false;

            foreach (PNode parent in selectableParents)
            {
                if (parent.ChildrenReference.Contains(node))
                {
                    selectable = true;
                    break;
                }
                else if (parent is PCamera)
                {
                    PCamera cameraParent = (PCamera)parent;
                    for (int i = 0; i < cameraParent.LayerCount; i++)
                    {
                        PLayer layer = cameraParent.GetLayer(i);
                        if (layer.ChildrenReference.Contains(node))
                        {
                            selectable = true;
                            break;
                        }
                    }
                }
            }

            return(selectable);
        }
Example #3
0
    public IEnumerator Die()
    {
        m_CoroutineRunning = true;

        PCamera camera = FindObjectOfType <PCamera>();

        Time.timeScale = 0.3f;

        yield return(new WaitForSecondsRealtime(1.0f));

        Instantiate(m_Debris, transform.position, transform.rotation);

        yield return(new WaitForSecondsRealtime(1.0f));

        StartCoroutine(camera.Shake(60.0f, 4.0f, 3f));

        yield return(new WaitForSecondsRealtime(1.0f));

        Time.timeScale = 1f;

        while (transform.position.y > -2000)
        {
            transform.position += new Vector3(0.0f, -1.0f, -0.77f) * 300.0f * Time.deltaTime;

            yield return(null);
        }

        yield return(new WaitForSecondsRealtime(1.0f));

        UnityEngine.SceneManagement.SceneManager.LoadScene(0);

        m_CoroutineRunning = false;
    }
        /// <summary>
        /// Installs the scroll director and adds the appropriate handlers.
        /// </summary>
        /// <param name="scrollableControl">
        /// The scrollable control on which this director directs.
        /// </param>
        /// <param name="view">The PCanvas that the scrollable control scrolls.</param>
        public virtual void Install(PScrollableControl scrollableControl, PCanvas view)
        {
            this.scrollableControl = scrollableControl;
            this.view = view;

            if (view != null)
            {
                this.camera = view.Camera;
                this.root   = view.Root;
            }

            if (camera != null)
            {
                camera.ViewTransformChanged += new PPropertyEventHandler(camera_ViewTransformChanged);
                camera.BoundsChanged        += new PPropertyEventHandler(camera_BoundsChanged);
                camera.FullBoundsChanged    += new PPropertyEventHandler(camera_FullBoundsChanged);
            }
            if (root != null)
            {
                root.BoundsChanged     += new PPropertyEventHandler(root_BoundsChanged);
                root.FullBoundsChanged += new PPropertyEventHandler(root_FullBoundsChanged);
            }

            if (scrollableControl != null)
            {
                scrollableControl.UpdateScrollbars();
            }
        }
Example #5
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();
        }
Example #6
0
 public ZoomController(GraphEditor graphEditor)
 {
     this.camera = graphEditor.Camera;
     camera.Canvas.ZoomEventHandler = null;
     camera.MouseWheel   += new PInputEventHandler(OnMouseWheel);
     graphEditor.KeyDown += OnKeyDown;
 }
        /// <summary>
        /// Animate the camera's view matrix from its current value when the activity
        /// starts to the new destination matrix value.
        /// </summary>
        /// <param name="aCamera">The camera whose view matrix will be animated.</param>
        /// <param name="aMatrix">The final matrix value.</param>
        /// <param name="duration">
        /// The amount of time that the animation should take.
        /// </param>
        /// <returns>
        /// The newly scheduled activity, if the duration is greater than 0; else null.
        /// </returns>
        protected virtual PActivity AnimateCameraViewMatrixTo(PCamera aCamera, PMatrix aMatrix, int duration)
        {
            bool wasOldAnimation = false;

            // first stop any old animations.
            if (navigationActivity != null)
            {
                navigationActivity.Terminate();
                wasOldAnimation = true;
            }

            if (duration == 0)
            {
                aCamera.ViewMatrix = aMatrix;
                return(null);
            }

            PMatrix source = aCamera.ViewMatrixReference;

            if (!source.MatrixReference.Equals(aMatrix.MatrixReference))
            {
                navigationActivity = aCamera.AnimateViewToMatrix(aMatrix, duration);
                ((PTransformActivity)navigationActivity).SlowInSlowOut = !wasOldAnimation;
                return(navigationActivity);
            }

            return(null);
        }
Example #8
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);
        }
Example #9
0
        /// <summary>
        /// Animates the camera's view to keep the focus node on the screen and at 100
        /// percent scale with minimal view movement.
        /// </summary>
        /// <param name="aCamera">The camera whose view will be animated.</param>
        /// <param name="aFocusNode">The focus node to animate to.</param>
        /// <param name="duration">The length of the animation.</param>
        /// <returns>
        /// The activity that animates the camera's view to the focus node.
        /// </returns>
        public virtual PActivity DirectCameraViewToFocus(PCamera aCamera, PNode aFocusNode, int duration)
        {
            PMatrix originalViewMatrix = aCamera.ViewMatrix;

            // Scale the canvas to include
            SizeF s = new SizeF(1, 0);

            s = focusNode.GlobalToLocal(s);

            float  scaleFactor = s.Width / aCamera.ViewScale;
            PointF scalePoint  = PUtil.CenterOfRectangle(focusNode.GlobalFullBounds);

            if (scaleFactor != 1)
            {
                aCamera.ScaleViewBy(scaleFactor, scalePoint.X, scalePoint.Y);
            }

            // Pan the canvas to include the view bounds with minimal canvas
            // movement.
            aCamera.AnimateViewToPanToBounds(focusNode.GlobalFullBounds, 0);

            // Get rid of any white space. The canvas may be panned and
            // zoomed in to do this. But make sure not stay constrained by max
            // magnification.
            //FillViewWhiteSpace(aCamera);

            PMatrix resultingMatrix = aCamera.ViewMatrix;

            aCamera.ViewMatrix = originalViewMatrix;

            // Animate the canvas so that it ends up with the given
            // view transform.
            return(AnimateCameraViewMatrixTo(aCamera, resultingMatrix, duration));
        }
Example #10
0
        /// <summary>
        /// Removes any white space.  The canvas may be panned and zoomed in to do this.
        /// </summary>
        /// <param name="aCamera">The camera whose view will be adjusted.</param>
        protected virtual void FillViewWhiteSpace(PCamera aCamera)
        {
            RectangleF rootBounds = aCamera.Root.FullBounds;
            RectangleF viewBounds = aCamera.ViewBounds;

            if (!rootBounds.Contains(aCamera.ViewBounds))
            {
                aCamera.AnimateViewToPanToBounds(rootBounds, 0);
                aCamera.AnimateViewToPanToBounds(focusNode.GlobalFullBounds, 0);

                // center content.
                float dx = 0;
                float dy = 0;
                viewBounds = aCamera.ViewBounds;

                if (viewBounds.Width > rootBounds.Width)                     // then center along x axis.
                {
                    float rootBoundsMinX    = Math.Min(rootBounds.X, rootBounds.Right);
                    float viewBoundsMinX    = Math.Min(viewBounds.X, viewBounds.Right);
                    float boundsCenterX     = rootBoundsMinX + (rootBounds.Width / 2);
                    float viewBoundsCenterX = viewBoundsMinX + (viewBounds.Width / 2);
                    dx = viewBoundsCenterX - boundsCenterX;
                }

                if (viewBounds.Height > rootBounds.Height)                   // then center along y axis.
                {
                    float rootBoundsMinY    = Math.Min(rootBounds.Y, rootBounds.Right);
                    float viewBoundsMinY    = Math.Min(viewBounds.Y, viewBounds.Right);
                    float boundsCenterY     = rootBoundsMinY + (rootBounds.Height / 2);
                    float viewBoundsCenterY = viewBoundsMinY + (viewBounds.Height / 2);
                    dy = viewBoundsCenterY - boundsCenterY;
                }
                aCamera.TranslateViewBy(dx, dy);
            }
        }
Example #11
0
 public ZoomController(PCanvas graphEditor)
 {
     this.graphEditor = graphEditor;
     this.camera      = graphEditor.Camera;
     camera.Canvas.ZoomEventHandler = null;
     camera.MouseWheel   += OnMouseWheel;
     graphEditor.KeyDown += OnKeyDown;
 }
Example #12
0
 public void Dispose()
 {
     //Remove event handlers for memory cleanup
     graphEditor.KeyDown           -= OnKeyDown;
     graphEditor.Camera.MouseWheel -= OnMouseWheel;
     graphEditor = null;
     camera      = null;
 }
 public ZoomController(ConvGraphEditor ConvGraphEditor)
 {
     this.ConvGraphEditor           = ConvGraphEditor;
     this.camera                    = ConvGraphEditor.Camera;
     camera.Canvas.ZoomEventHandler = null;
     camera.MouseWheel             += OnMouseWheel;
     ConvGraphEditor.KeyDown       += OnKeyDown;
 }
Example #14
0
		/// <summary>
		/// Constructs a new PPickPath.
		/// </summary>
		/// <param name="aCamera">The camera that originated the pick action.</param>
		/// <param name="aScreenPickBounds">The bounds being picked.</param>
		public PPickPath(PCamera aCamera, RectangleF aScreenPickBounds) {
			pickBoundsStack = new Stack();
			bottomCamera = null;
			topCamera = aCamera;
			nodeStack = new Stack();
			matrixStack = new Stack();
			pickBoundsStack.Push(aScreenPickBounds);
		}
Example #15
0
 public void OnCameraChanged(PCamera c)
 {
     listEntry.Width    = c.Width;
     listEntry[1].Width = c.Width;
     foreach (InterpTrack t in InterpTracks)
     {
         t.listEntry[1].Width = c.Width;
     }
 }
Example #16
0
 public void OnCameraChanged(PCamera c)
 {
     TimelineView.Height = c.Height;
     TimeScale.OffsetY   = c.Height - Timeline.InfoHeight;
     foreach (InterpGroup g in InterpGroups)
     {
         g.OnCameraChanged(c);
     }
 }
        /// <summary>
        /// Create a new ShowInterfaceHandler for a specific Interface
        /// </summary>
        /// <param Name="camera">The PCamera to attach the interface to</param>
        /// <param Name="showInterface">The interface this should control</param>
        public ShowInterfaceHandler(PCamera camera, AbstractInterface showInterface)
        {
            Camera    = camera;
            IsPressed = false;
            Interface = showInterface;

            //This handler needs to be hooked in to the interface so it can listen for the keyup event
            Interface.Entry.AddInputEventListener(this);
        }
Example #18
0
		/// <summary>
		/// Constructs a new PPickPath.
		/// </summary>
		/// <param name="aCamera">The camera that originated the pick action.</param>
		/// <param name="aScreenPickBounds">The bounds being picked.</param>
		public PPickPath(PCamera aCamera, RectangleF aScreenPickBounds) {
			pickBoundsStack = new Stack();
			bottomCamera = null;
			topCamera = aCamera;
			nodeStack = new Stack();
			matrixStack = new Stack();
			pickBoundsStack.Push(aScreenPickBounds);

			CURRENT_PICK_PATH = this;
		}
        /// <summary>
        /// Pans the camera as the mouse is dragged.
        /// </summary>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        protected virtual void Pan(PInputEventArgs e)
        {
            PCamera c = e.Camera;
            PointF  l = e.Position;

            if (c.ViewBounds.Contains(l))
            {
                SizeF s = e.Delta;
                c.TranslateViewBy(s.Width, s.Height);
            }
        }
Example #20
0
        public WidthAxis(PVCFrame aFrame, PLayer aLayer)
        {
            layer  = aLayer;
            frame  = aFrame;
            camera = layer.GetCamera(0);
            camera.ViewTransformChanged += CameraVisibleChanged;
            frame.DimensionChanged      += FrameDimensionChanged;
            frame.ChildrenChanged       += FrameChildrenChanged;

            SetBounds(DefaultX, DefaultY, DefaultWidth, DefaultHeight);
        }
Example #21
0
 /// <summary>
 /// Adds sticky bounds handles (with respect to the given camera) to the specified node.
 /// </summary>
 /// <param name="aNode">The node to add 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)));
 }
Example #22
0
        /// <summary>
        /// Constructs a new PPickPath.
        /// </summary>
        /// <param name="aCamera">The camera that originated the pick action.</param>
        /// <param name="aScreenPickBounds">The bounds being picked.</param>
        public PPickPath(PCamera aCamera, RectangleFx aScreenPickBounds)
        {
            pickBoundsStack = new Stack();
            bottomCamera    = null;
            topCamera       = aCamera;
            nodeStack       = new Stack();
            matrixStack     = new Stack();
            pickBoundsStack.Push(aScreenPickBounds);

            CURRENT_PICK_PATH = this;
        }
        /// <summary>
        /// Pans the camera as the mouse is dragged.
        /// </summary>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        protected virtual void Pan(PInputEventArgs e)
        {
            PCamera c = e.Camera;
            Vector2 l = new Vector2(e.Position.X, e.Position.Y);

            if (c.ViewBounds.Contains(l))
            {
                SizeFx s = e.Delta;
                c.TranslateViewBy(s.Width, s.Height);
            }
        }
        public override PActivity DirectCameraViewToFocus(PCamera aCamera, PNode aFocusNode, int duration)
        {
            PActivity animateViewToMatrix = base.DirectCameraViewToFocus(aCamera, aFocusNode, duration);

            PControl controlNode = (PControl)aFocusNode;

            aCamera.Root.WaitForActivities();
            controlNode.CurrentCamera = aCamera;
            controlNode.Editing       = true;

            return(animateViewToMatrix);
        }
Example #25
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);
        }
Example #26
0
        /// <summary>
        /// Create a new Translate command with a given default to language
        /// </summary>
        /// <param Name="defaultToLanguage">The default language the command should be translated to</param>
        public TranslateCommand(string defaultToLanguage, PCamera camera)
        {
            DefaultToLanguage = defaultToLanguage;
            Camera            = camera;

            //Request a _AccessToken from the Azure Bing Translate service
            TranslateToken = new AzureToken(Resources.ClientSecrets.ClientID, Resources.ClientSecrets.ClientSecret, @"http://api.microsofttranslator.com");

            //Create hooks for the translate and language detection services using the translate _AccessToken for authorisation
            TranslateService      = new AzureServiceHelper(@"http://api.microsofttranslator.com/v2/Http.svc/Translate", TranslateToken);
            LanguageDetectService = new AzureServiceHelper(@"http://api.microsofttranslator.com/v2/Http.svc/Detect", TranslateToken);
        }
        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();
        }
        /// <summary>
        /// Update the marquee bounds based on the given event data.
        /// </summary>
        /// <param name="e">A PInputEventArgs that contains the event data.</param>
        protected virtual void UpdateMarquee(PInputEventArgs e)
        {
            RectangleF r = RectangleF.Empty;

            if (marqueeParent is PCamera)
            {
                r = PUtil.AddPointToRect(r, canvasPressPt);
                r = PUtil.AddPointToRect(r, e.CanvasPosition);
            }
            else
            {
                r = PUtil.AddPointToRect(r, presspt);
                r = PUtil.AddPointToRect(r, e.Position);
            }

            r = marquee.GlobalToLocal(r);
            marquee.Reset();
            SetSafeMarqueePen(r.Width, r.Height);
            marquee.AddRectangle(r.X, r.Y, r.Width, r.Height);

            r = RectangleF.Empty;
            r = PUtil.AddPointToRect(r, presspt);
            r = PUtil.AddPointToRect(r, e.Position);

            allItems.Clear();
            PNodeFilter filter = CreateNodeFilter(r);

            foreach (PNode parent in selectableParents)
            {
                PNodeList items;
                if (parent is PCamera)
                {
                    items = new PNodeList();
                    PCamera cameraParent = (PCamera)parent;
                    for (int i = 0; i < cameraParent.LayerCount; i++)
                    {
                        cameraParent.GetLayer(i).GetAllNodes(filter, items);
                    }
                }
                else
                {
                    items = parent.GetAllNodes(filter, null);
                }

                foreach (PNode node in items)
                {
                    allItems.Add(node, true);
                }
            }
        }
Example #29
0
        public override void Initialize()
        {
            PCanvas c   = Canvas;
            PLayer  l   = c.Layer;
            PCamera cam = c.Camera;

            cam.ScaleViewBy(2.0f);
            PPath path = PPath.CreateRectangle(0, 0, 100, 100);

            l.AddChild(path);
            path.TranslateBy(100, 10);
            path.ScaleBy(0.2f);
            cam.AnimateViewToCenterBounds(path.GlobalFullBounds, true, 1000);
        }
Example #30
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        EditorGUILayout.Space();

        CheckPoint myCP  = target as CheckPoint;
        PCamera    myCam = FindObjectOfType <PCamera>();

        if (GUILayout.Button("Move Camera Here"))
        {
            myCam.transform.position = new Vector3(myCam.transform.position.x, myCP.transform.position.y + myCam.YDifference, myCam.transform.position.z);
        }
    }
Example #31
0
        /// <summary>
        /// Animates the camera's view to keep the control node on the screen and at 100
        /// percent scale with minimal view movement.
        /// </summary>
        /// <param name="aCamera">The camera whose view will be animated.</param>
        /// <param name="aControlNode">The control node to animate to.</param>
        /// <param name="path">The pick path through which the control node was picked.</param>
        /// <param name="duration">The length of the animation.</param>
        /// <returns>
        /// The activity that animates the camera's view to the control node.
        /// </returns>
        public virtual PActivity DirectCameraViewToControl(PCamera aCamera, PControl aControlNode, PPickPath path, int duration)
        {
            Matrix originalViewMatrix = aCamera.ViewMatrix;

            // Scale the canvas to include
            SizeFx s = new SizeFx(1, 0);

            s = aControlNode.GlobalToLocal(s);

            float   scaleFactor = s.Width / aCamera.ViewScale;
            PointFx scalePoint  = PUtil.CenterOfRectangle(aControlNode.GlobalFullBounds);

            if (scaleFactor != 1)
            {
                aCamera.ScaleViewBy(scaleFactor, scalePoint.X, scalePoint.Y);
            }

            // Pan the canvas to include the view bounds with minimal canvas
            // movement.
            aCamera.AnimateViewToPanToBounds(aControlNode.GlobalFullBounds, 0);

            // Get rid of any white space. The canvas may be panned and
            // zoomed in to do this. But make sure not stay constrained by max
            // magnification.
            //FillViewWhiteSpace(aCamera);

            Matrix resultingMatrix = aCamera.ViewMatrix;

            aCamera.ViewMatrix = originalViewMatrix;

            PControl controlNode = (PControl)aControlNode;

            // Animate the canvas so that it ends up with the given
            // view transform.
            PActivity animateCameraViewActivity = AnimateCameraViewMatrixTo(aCamera, resultingMatrix, duration);

            aCamera.Root.WaitForActivities();

            Matrix  pathTransform = path.GetPathTransformTo(controlNode);
            PointFx point         = new PointFx(controlNode.X, controlNode.Y);
            PointFx pf            = MatrixExtensions.Transform(pathTransform, point);

            controlNode.ControlLocation = new System.Drawing.Point((int)pf.X, (int)pf.Y);
            controlNode.CurrentCanvas   = path.TopCamera.Canvas;
            controlNode.Editing         = true;

            return(animateCameraViewActivity);
        }
Example #32
0
		/// <summary>
		/// Pops a camera from the camera stack.
		/// </summary>
		/// <param name="camera">The camera to pop.</param>
		public virtual void PopCamera(PCamera camera) {
			cameraStack.Pop();
		}
Example #33
0
		//****************************************************************
		// Context Attribute Stacks - Attributes that can be pushed and
		// popped.
		//****************************************************************

		/// <summary>
		/// Pushes the given camera onto the camera stack.
		/// </summary>
		/// <param name="camera">The camera to push.</param>
		public virtual void PushCamera(PCamera camera) {
			cameraStack.Push(camera);
		}