Пример #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;
        }
Пример #2
0
        // Add new view
        public void AddView(View view)
        {
            view.ID = nextViewID++;
            views.Add(view);

            // save
            SaveViews();
        }
Пример #3
0
 // Ñheck if the view is already exist
 private bool CheckView(View view)
 {
     return config.CheckView(view);
 }
Пример #4
0
 // Delete view
 public bool DeleteView(View view)
 {
     views.Remove(view);
     // save
     SaveViews();
     return true;
 }
Пример #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;
            }
        }
Пример #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;
 }
Пример #7
0
        // 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;
        }
Пример #8
0
 // Remove view from the collection
 public void Remove(View view)
 {
     InnerList.Remove(view);
 }
Пример #9
0
 // Add new view to the collection
 public void Add(View view)
 {
     InnerList.Add(view);
 }
Пример #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;
        }