Ejemplo n.º 1
0
 /// <summary>
 /// Add the layer at the given index in this camera's list of layers.  Layers
 /// may be viewed by multiple cameras at once.
 /// </summary>
 /// <param name="index">The index at which to add the layer.</param>
 /// <param name="layer">The layer to add to this camera.</param>
 public virtual void AddLayer(int index, PLayer layer)
 {
     layers.Insert(index, layer);
     layer.AddCamera(this);
     InvalidatePaint();
     FirePropertyChangedEvent(PROPERTY_KEY_LAYERS, PROPERTY_CODE_LAYERS, null, layers);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Remove the layer at the given index from the list of layers managed by this
        /// camera.
        /// </summary>
        /// <param name="index">The index of the layer to remove.</param>
        /// <returns>The removed layer.</returns>
        public virtual PLayer RemoveLayer(int index)
        {
            PLayer layer = layers[index];

            layers.RemoveAt(index);
            layer.RemoveCamera(this);
            InvalidatePaint();
            FirePropertyChangedEvent(PROPERTY_KEY_LAYERS, PROPERTY_CODE_LAYERS, null, layers);
            return(layer);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Pick all the layers that the camera is looking at.
        /// </summary>
        /// <param name="pickPath">The pick path to use for the pick operation.</param>
        /// <returns>
        /// True if an object viewed by the camera was picked; else false.
        /// </returns>
        /// <remarks>
        /// This method is only called when the camera's view matrix and clip are
        /// applied to the pickPath.
        /// </remarks>
        protected virtual bool PickCameraView(PPickPath pickPath)
        {
            int count = LayerCount;

            for (int i = count - 1; i >= 0; i--)
            {
                PLayer each = layers[i];
                if (each.FullPick(pickPath))
                {
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
        //****************************************************************
        // Serialization - Cameras conditionally serialize their layers.
        // This means that only the layer references that were unconditionally
        // (using GetObjectData) serialized by someone else will be restored
        // when the camera is deserialized.
        //****************************************************************/

        /// <summary>
        /// Read this this camera 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 PCamera(SerializationInfo info, StreamingContext context)
            : base(info, context)
        {
            layers = new PLayerList();

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

            for (int i = 0; i < count; i++)
            {
                PLayer layer = (PLayer)info.GetValue("layer" + i, typeof(PLayer));
                if (layer != null)
                {
                    layers.Add(layer);
                }
            }
            canvas = (PCanvas)info.GetValue("canvas", typeof(PCanvas));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Remove the given layer from the list of layers managed by this camera.
 /// </summary>
 /// <param name="layer">The layer to remove.</param>
 /// <returns>The removed layer.</returns>
 public virtual PLayer RemoveLayer(PLayer layer)
 {
     return(RemoveLayer(layers.IndexOf(layer)));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Add the layer to the end of this camera's list of layers.  Layers may be
 /// viewed by multiple cameras at once.
 /// </summary>
 /// <param name="layer">The layer to add to this camera.</param>
 public virtual void AddLayer(PLayer layer)
 {
     AddLayer(LayerCount, layer);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Return the index where the given layer is stored.
 /// </summary>
 /// <param name="layer">The layer whose index is desired.</param>
 /// <returns>The index where the given layer is stored.</returns>
 public virtual int IndexOfLayer(PLayer layer)
 {
     return(layers.IndexOf(layer));
 }