Exemple #1
0
        // Remove camera from the collection and signal to stop it
        public void Remove(Camera camera)
        {
            InnerList.Remove(camera);

            // signal to stop
            camera.SignalToStop();
        }
        // Add new camera
        public void AddCamera(Camera camera)
        {
            camera.ID = nextCameraID++;
            cameras.Add(camera);

            // save
            SaveCameras();
        }
Exemple #3
0
 // Add new camera to the collection and run it
 public void Add(Camera camera)
 {
     // lock
     Monitor.Enter(this);
     // add to the pool
     InnerList.Add(camera);
     // unlock
     Monitor.Exit(this);
 }
Exemple #4
0
        // Add new camera to the collection and run it
        public bool Add(Camera camera)
        {
            // create video source
            if (camera.CreateVideoSource())
            {
                // add to the pool
                InnerList.Add(camera);

                camera.Start();
                return true;
            }
            return false;
        }
Exemple #5
0
        // Ensure the camera is stopped
        public void Remove(Camera camera)
        {
            // lock
            Monitor.Enter(this);

            int n = InnerList.Count;
            for (int i = 0; i < n; i++)
            {
                if (InnerList[i] == camera)
                {
                    if (camera.Running)
                        camera.Stop();
                    camera.CloseVideoSource();
                    InnerList.RemoveAt(i);
                    break;
                }
            }

            // unlock
            Monitor.Exit(this);
        }
Exemple #6
0
        public Form1()
        {
            InitializeComponent();
            multiplexer1.CloseAll();
            multiplexer1.CamerasVisible = true;
            multiplexer1.CellWidth = 320;
            multiplexer1.CellHeight = 240;
            for (int i = 0; i < 2; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    // get camera

                    Camera camera = new Camera("aa");
                    multiplexer1.SetCamera(i, j, camera);

                }
            }

            multiplexer1.Rows = 2;
            multiplexer1.Cols = 2;
            multiplexer1.SingleCameraMode = false;
            multiplexer1.CamerasVisible = true;
        }
Exemple #7
0
        /// <summary>
        /// load all camera
        /// </summary>
        private void LoadAllCamera()
        {
            multiplexer1.CloseAll();
            multiplexer1.CamerasVisible = true;
            multiplexer1.CellWidth = 320;
            multiplexer1.CellHeight = 240;
            multiplexer1.FitToWindow = true;
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    // get camera

                    Camera camera = new Camera("aa");
                    multiplexer1.SetCamera(i, j, camera);

                }
            }

            multiplexer1.Rows = 5;
            multiplexer1.Cols = 5;
            multiplexer1.SingleCameraMode = false;
            multiplexer1.CamerasVisible = true;
        }
Exemple #8
0
        // Add camera
        public TreeNode AddCamera(Camera camera, TreeNode parentNode)
        {
            // create new
            TreeNode node = new TreeNode(camera.Name, cameraImage, cameraSelectedImage);
            // add it to tree
            if (parentNode == null)
                Nodes.Add(node);
            else
                parentNode.Nodes.Add(node);

            return node;
        }
Exemple #9
0
        // Edit camera
        private void EditCamera(TreeNode node)
        {
            CameraPropertiesForm form = new CameraPropertiesForm();
            string	fullName = camerasTree.GetCameraFullName(node);

            // set providers
            form.VideoProviders = config.providers;
            // set callback for camera name checking
            form.CheckCameraFunction = new CheckCameraHandler(CheckCamera);
            // get camera
            form.Camera = cameraToEdit = config.GetCameraByName(fullName);
            // catch Apply event
            form.Apply += new EventHandler(editCamera_Apply);

            nodeToEdit = node;

            if (form.ShowDialog() == DialogResult.OK)
            {
                config.SaveCameras();

                // modify tree
                node.Text = cameraToEdit.Name;
            }

            nodeToEdit = null;
        }
Exemple #10
0
 // Ñheck if the camera is already exist
 private bool CheckCamera(Camera camera)
 {
     return config.CheckCamera(camera);
 }
Exemple #11
0
 // Set camera to the specified position of the multiplexer
 public void SetCamera(int row, int col, Camera camera)
 {
     if ((row >= 0) && (col >= 0) && (row < MaxRows) && (col < MaxCols))
     {
         camWindows[row, col].Camera = camera;
     }
 }
        // Load cameras
        private void LoadCameras(XmlTextReader reader, Group parent)
        {
            // load all groups
            while (reader.Name == "Group")
            {
                int	depth = reader.Depth;

                // create new group
                Group group = new Group(reader.GetAttribute("name"));
                group.ID = int.Parse(reader.GetAttribute("id"));
                group.Description = reader.GetAttribute("desc");
                group.Parent = parent;

                // add group
                camerasGroups.Add(group);

                if (group.ID >= nextCamerasGroupID)
                    nextCamerasGroupID = group.ID + 1;

                // move to next node
                reader.Read();

                // move to next element node
                while (reader.NodeType == XmlNodeType.EndElement)
                    reader.Read();
                // read children
                if (reader.Depth > depth)
                    LoadCameras(reader, group);
                //
                if (reader.Depth < depth)
                    return;
            }
            // load all cameras
            while (reader.Name == "Camera")
            {
                int	depth = reader.Depth;

                // create new camera
                Camera camera = new Camera(reader.GetAttribute("name"));

                camera.ID			= int.Parse(reader.GetAttribute("id"));
                camera.Description	= reader.GetAttribute("desc");
                camera.Parent		= parent;
                camera.Provider		= providers.GetProviderByName(reader.GetAttribute("provider"));

                // load configuration
                if (camera.Provider != null)
                    camera.Configuration = camera.Provider.LoadConfiguration(reader);

                // add camera
                cameras.Add(camera);

                if (camera.ID >= nextCameraID)
                    nextCameraID = camera.ID + 1;

                // move to next node
                reader.Read();

                // move to next element node
                while (reader.NodeType == XmlNodeType.EndElement)
                    reader.Read();
                if (reader.Depth < depth)
                    return;
            }
        }
 // Delete camera
 public bool DeleteCamera(Camera camera)
 {
     cameras.Remove(camera);
     // save
     SaveCameras();
     return true;
 }
 // Check camera
 // check if there is already a camera with such name
 // return true, if there is no such camera
 public bool CheckCamera(Camera camera)
 {
     foreach (Camera c in cameras)
     {
         if ((camera.Name == c.Name) && (camera.Parent == c.Parent) && ((camera.ID == 0) || (camera.ID != c.ID)))
             return false;
     }
     return true;
 }
Exemple #15
0
 // Add new camera to the collection
 public void Add(Camera camera)
 {
     InnerList.Add(camera);
 }
Exemple #16
0
        // Apply the page
        public bool Apply()
        {
            string name = nameBox.Text.Replace('\\', ' ');

            if (checkCameraFunction != null)
            {
                Camera tmpCamera = new Camera(name);

                tmpCamera.ID = camera.ID;
                tmpCamera.Parent = camera.Parent;

                // check camera
                if (checkCameraFunction(tmpCamera) == false)
                {
                    Color	tmp = this.nameBox.BackColor;

                    // highligh name edit box
                    this.nameBox.BackColor = Color.LightCoral;
                    // error message
                    MessageBox.Show(this, "A camera with such name is already exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    // restore & focus name edit box
                    this.nameBox.BackColor = tmp;
                    this.nameBox.Focus();

                    return false;
                }
            }

            // update camera name and description
            camera.Name = name;
            camera.Description = descriptionBox.Text;
            camera.Provider = providers[videoSourceCombo.SelectedIndex - 1];

            return true;
        }
Exemple #17
0
 // Remove camera from the collection
 public void Remove(Camera camera)
 {
     InnerList.Remove(camera);
 }