Exemple #1
0
        //****************************************************************
        // Event Handling - Methods for handling events
        //
        // The dispatch manager updates the focus nodes based on the
        // incoming events, and dispatches those events to the appropriate
        // focus nodes.
        //****************************************************************

        /// <summary>
        /// Create a new PInputEvent based on the next windows event and dispatch it to Piccolo.
        /// </summary>
        public virtual void ProcessInput()
        {
            if (nextInput == null)
            {
                return;
            }

            PInputEventArgs e = new PInputEventArgs(this, nextInput, nextType);

            //The EventArgs object for a Click event does not provide the position, so
            //we just ignore it here.
            if (e.IsMouseEvent || e.IsDragDropEvent)
            {
                lastCanvasPosition = currentCanvasPosition;

                if (e.IsMouseEvent)
                {
                    currentCanvasPosition = new PointFx(((MouseEventArgs)nextInput).X, ((MouseEventArgs)nextInput).Y);
                }
                else
                {
                    Point pt  = new Point((int)((DragEventArgs)nextInput).X, (int)((DragEventArgs)nextInput).Y);
                    Point tPt = nextWindowsSource.PointToClient(pt);
                    currentCanvasPosition = new PointFx(tPt.X, tPt.Y);
                }

                PPickPath pickPath = nextInputSource.Pick(currentCanvasPosition.X, currentCanvasPosition.Y, 1);
                MouseOver = pickPath;
            }

            nextInput       = null;
            nextInputSource = null;

            Dispatch(e);
        }
Exemple #2
0
 /// <summary>
 /// Process the given windows event from the camera.
 /// </summary>
 /// <param name="e">The windows event to be processed.</param>
 /// <param name="type">The type of windows event being processed.</param>
 /// <param name="camera">The camera from which to process the windows event.</param>
 /// <param name="canvas">The source of the windows event being processed.</param>
 public virtual void ProcessEventFromCamera(EventArgs e, PInputType type, PCamera camera, PCanvas canvas)
 {
     nextInput         = e;
     nextType          = type;
     nextInputSource   = camera;
     nextWindowsSource = canvas;
     camera.Root.ProcessInputs();
 }
Exemple #3
0
        /// <summary>
        /// Remove the camera at the given index from this layer's camera list.
        /// </summary>
        /// <param name="index">The index of the camera to remove.</param>
        /// <returns>The removed camera.</returns>
        public virtual PCamera RemoveCamera(int index)
        {
            PCamera camera = cameras[index];

            cameras.RemoveAt(index);
            InvalidatePaint();
            FirePropertyChangedEvent(PROPERTY_KEY_CAMERAS, PROPERTY_CODE_CAMERAS, null, cameras);
            return(camera);
        }
Exemple #4
0
        //****************************************************************
        // Serialization - Layers conditionally serialize their cameras.
        // This means that only the camera references that were unconditionally
        // (using GetObjectData) serialized by someone else will be restored
        // when the layer is unserialized.
        //****************************************************************

        /// <summary>
        /// Read this this layer and all its children from the given SerializationInfo.
        /// </summary>
        /// <param name="info">The SerializationInfo to read from.</param>
        /// <param name="context">
        /// The StreamingContext of this serialization operation.
        /// </param>
        /// <remarks>
        /// This constructor is required for Deserialization.
        /// </remarks>
        protected PLayer(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            cameras = new PCameraList();

            int count = info.GetInt32("cameraCount");

            for (int i = 0; i < count; i++)
            {
                PCamera camera = (PCamera)info.GetValue("camera" + i, typeof(PCamera));
                if (camera != null)
                {
                    cameras.Add(camera);
                }
            }
        }
Exemple #5
0
 /// <summary>
 /// Constructs a new PCameraTransformTarget.
 /// </summary>
 /// <param name="target">The target camera.</param>
 public PCameraTransformTarget(PCamera target)
 {
     this.target = target;
 }
Exemple #6
0
 /// <summary>
 /// Remove the camera from this layer's camera list.
 /// </summary>
 /// <param name="camera">The camera to remove.</param>
 /// <returns>The removed camera.</returns>
 public virtual PCamera RemoveCamera(PCamera camera)
 {
     return(RemoveCamera(cameras.IndexOf(camera)));
 }
Exemple #7
0
 /// <summary>
 /// Add a camera to this layer's camera list at the specified index.
 /// </summary>
 /// <param name="index">The index at which to add the new layer.</param>
 /// <param name="camera">The new camera to add.</param>
 /// <remarks>
 /// This method it called automatically when a layer is added to a camera.
 /// </remarks>
 public virtual void AddCamera(int index, PCamera camera)
 {
     cameras.Insert(index, camera);
     InvalidatePaint();
     FirePropertyChangedEvent(PROPERTY_KEY_CAMERAS, PROPERTY_CODE_CAMERAS, null, cameras);
 }
Exemple #8
0
 /// <summary>
 /// Add a camera to this layer's camera list.
 /// </summary>
 /// <param name="camera">The new camera to add.</param>
 /// <remarks>
 /// This method it called automatically when a layer is added to a camera.
 /// </remarks>
 public virtual void AddCamera(PCamera camera)
 {
     AddCamera(CameraCount, camera);
 }