Example #1
0
        //  Edit view
        private void EditView(TreeNode node)
        {
            ViewPropertiesForm form = new ViewPropertiesForm();
            string	fullName = camerasTree.GetViewFullName(node);

            // build cameras tree
            form.BuildCamerasTree(config.camerasGroups, config.cameras);
            // set callback for view name checking
            form.CheckViewFunction = new CheckViewHandler(CheckView);
            // get view
            form.View = viewToEdit = config.GetViewByName(fullName);
            // catch Apply event
            form.Apply += new EventHandler(editView_Apply);

            nodeToEdit = node;

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

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

            nodeToEdit = null;
        }
Example #2
0
        // Add new view
        public void AddView(View view)
        {
            view.ID = nextViewID++;
            views.Add(view);

            // save
            SaveViews();
        }
Example #3
0
 // Ñheck if the view is already exist
 private bool CheckView(View view)
 {
     return config.CheckView(view);
 }
Example #4
0
 // Delete view
 public bool DeleteView(View view)
 {
     views.Remove(view);
     // save
     SaveViews();
     return true;
 }
Example #5
0
        // Load views
        private void LoadViews(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
                viewsGroups.Add(group);

                if (group.ID >= nextViewsGroupID)
                    nextViewsGroupID = 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)
                    LoadViews(reader, group);
                //
                if (reader.Depth < depth)
                    return;
            }
            // load all views
            while (reader.Name == "View")
            {
                int	depth = reader.Depth;

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

                view.ID				= int.Parse(reader.GetAttribute("id"));
                view.Description	= reader.GetAttribute("desc");
                view.Parent			= parent;

                // view size
                view.Rows			= short.Parse(reader.GetAttribute("rows"));
                view.Cols			= short.Parse(reader.GetAttribute("cols"));
                view.CellWidth		= short.Parse(reader.GetAttribute("width"));
                view.CellHeight		= short.Parse(reader.GetAttribute("height"));

                // read cameras
                string[] strIDs = reader.GetAttribute("cameras").Split(',');
                for (int i = 0, k = 0; i < View.MaxRows; i++)
                {
                    for (int j = 0; j < View.MaxCols; j++, k++)
                    {
                        view.SetCamera(i, j, int.Parse(strIDs[k]));
                    }
                }

                // add view
                views.Add(view);

                if (view.ID >= nextViewID)
                    nextViewID = view.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;
            }
        }
Example #6
0
 // Check view
 // check if there is already a view with such name
 // return true, if there is no such view
 public bool CheckView(View view)
 {
     foreach (View v in views)
     {
         if ((view.Name == v.Name) && (view.Parent == v.Parent) && ((view.ID == 0) || (view.ID != v.ID)))
             return false;
     }
     return true;
 }
        // Apply the page
        public bool Apply()
        {
            string name = nameBox.Text.Replace('\\', ' ');

            if (checkViewFunction != null)
            {
                View tmpView = new View(name);

                tmpView.ID = view.ID;
                tmpView.Parent = view.Parent;

                // check view
                if (checkViewFunction(tmpView) == false)
                {
                    Color	tmp = this.nameBox.BackColor;

                    // highlight name edit box
                    this.nameBox.BackColor = Color.LightCoral;
                    // error message
                    XtraMessageBox.Show(this, "A view 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 view name and description
            view.Name = name;
            view.Description = descriptionBox.Text;

            try
            {
                view.CellWidth = short.Parse(cellWidthBox.Text);
                view.CellHeight = short.Parse(cellHeightBox.Text);
            }
            catch (Exception)
            {
            }

            return true;
        }
Example #8
0
 // Remove view from the collection
 public void Remove(View view)
 {
     InnerList.Remove(view);
 }
Example #9
0
 // Add new view to the collection
 public void Add(View view)
 {
     InnerList.Add(view);
 }
Example #10
0
        // Add view
        public TreeNode AddView(View view, TreeNode parentNode)
        {
            // create new
            TreeNode node = new TreeNode(view.Name, viewImage, viewSelectedImage);
            // add it to tree
            parentNode.Nodes.Add(node);

            return node;
        }