using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;

using CategoryTheory;
using DiagramUI;

namespace Motion6D
{
    [Serializable()]
    public abstract class Camera : Position, ICategoryObject, ISerializable
    {

        #region Fields
        private List<IPosition> visible = new List<IPosition>();
        private object obj;

        #endregion

        #region Ctor

        public Camera()
        {
        }

        protected Camera(SerializationInfo info, StreamingContext context)
        {
        }

        #endregion

        #region ISerializable Members

        void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)
        {

        }

        #endregion

        #region ICategoryObject Members

        ICategory ICategoryObject.Category
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        ICategoryArrow ICategoryObject.Id
        {
            get { throw new Exception("The method or operation is not implemented."); }
        }

        #endregion

        #region IAssociatedObject Members

        object IAssociatedObject.Object
        {
            get
            {
                return obj;
            }
            set
            {
                obj = value;
            }
        }

        #endregion




        #region Specific Members

        public virtual void AddVisible(IPosition p)
        {
            visible.Add(p);
        }

        public virtual void RemoveVisible(IPosition p)
        {
            visible.Remove(p);
        }

 
        public abstract void UpdateImage();


        public int Count
        {
            get
            {
                return visible.Count;
            }
        }

        public IPosition this[int n]
        {
            get
            {
                return visible[n];
            }
        }


        static public void UpdateAll(IDesktop desktop)
        {
            System.Collections.ICollection objs = desktop.Objects;
            foreach (IAssociatedObject obj in objs)
            {
                object o = obj.Object;
                if (o is Camera)
                {
                    Camera c = o as Camera;
                    c.UpdateImage();
                }
            }
        }

        #endregion


     }
}
