private void NodeEdit() { CameraTreeNode n = this.GetSelectedTreeNode(); if (n != null) { if (!n.IsGroup()) { CameraClass m = n.Item as CameraClass; CameraClass e = m.Clone() as CameraClass; CameraEditForm fmEdit = new CameraEditForm(e); fmEdit.ShowDialog(this); if (DialogResult.OK == fmEdit.DialogResult) { fmEdit.Camera.Copy(m); RootClass.Instance.SaveConfig(); MotionConfiguration.Instance.Save(); m.FireItemValueChangedEvent(); } } else { n.BeginEdit(); } } }
private void SetToolStripButtonState() { CameraTreeNode n = GetSelectedTreeNode(); this.toolStripButtonEdit.Enabled = (n != null && !n.IsGroup()); this.toolStripButtonDel.Enabled = (n != null); }
private void toolStripMenuItemCemeraAdd_Click(object sender, EventArgs e) { CameraTreeNode n = this.GetSelectedTreeNode(); if (n != null && !n.IsGroup()) { this.OnCameraTreeOnBoard(new CameraTreeEventArgs((CameraClass)n.Item)); } }
private void treeViewCamera_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { CameraTreeNode n = (CameraTreeNode)e.Node; if (n != null && !n.IsGroup()) { this.OnCameraTreeOnBoard(new CameraTreeEventArgs((CameraClass)n.Item)); } }
private CameraTreeNode GetSelectedGroupNode() { CameraTreeNode n = this.GetSelectedTreeNode(); if (null != n && n.IsGroup() == false) { return((CameraTreeNode)(n.Parent)); } return(n); }
private bool NodeDelete(CameraTreeNode node) { if (node.IsGroup()) { if (node.Nodes.Count > 0) { ArrayList list = new ArrayList(); foreach (TreeNode n in node.Nodes) { list.Add(n); } foreach (TreeNode n in list) { if (false == this.NodeDelete(n as CameraTreeNode)) { return(false); } } } if (node.Nodes.Count == 0) { node.Item.Remove(); node.Item.Clean(); node.Remove(); return(true); } } else { CameraClass c = node.Item as CameraClass; if (c.Capturing == true) { MessageBox.Show(string.Format(Translator.Instance.T("删除摄像头[{0}]失败! 该摄像头正在录像中, 您必须首先停止录像, 然后再删除该摄像头."), c.Name), MotionPreference.Instance.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } CameraTreeNodeDeleteEventArgs e = new CameraTreeNodeDeleteEventArgs(c); this.OnCameraTreeBeforeDelete(e); if (e.Cancel == false) { node.Item.Remove(); node.Item.Clean(); node.Remove(); this.OnCameraTreeAfterDelete(e); return(true); } } return(false); }
private int NodeCount(CameraTreeNode p) { int r = 0; if (p.IsGroup()) { foreach (CameraTreeNode n in p.Nodes) { r += this.NodeCount(n); } } else { r++; } return(r); }
public void NodeReloadGlobalSettings(CameraTreeNode p) { if (p.IsGroup()) { foreach (CameraTreeNode n in p.Nodes) { this.NodeReloadGlobalSettings(n); } } else { CameraClass c = p.Item as CameraClass; if (c != null) { c.ReloadGlobalSettings(); } } }
private void NodeOnBoard(CameraTreeNode node) { if (node == null) { return; } if (node.IsGroup()) { foreach (TreeNode n in node.Nodes) { this.NodeOnBoard((CameraTreeNode)n); } } else { this.OnCameraTreeOnBoard(new CameraTreeEventArgs((CameraClass)node.Item)); } }
private bool NodeDelete() { CameraTreeNode n = this.GetSelectedTreeNode(); if (n != null) { string msg = ""; if (n.IsGroup()) { msg = Translator.Instance.T("您确实要删除这个视频监控组吗? 如果该组被删除, 则该组内的所有摄像头及其监控信息都将被删除."); } else { msg = Translator.Instance.T("您确实要删除这个摄像头吗? 如果该摄像头被删除, 则该摄像头的所有监控信息也将被删除."); } if (DialogResult.Yes == MessageBox.Show(msg, MotionPreference.Instance.MessageBoxCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning)) { return(this.NodeDelete(n)); } } return(false); }
private void treeViewCamera_DragOver(object sender, DragEventArgs e) { // Compute drag position and move image Point formP = this.PointToClient(new Point(e.X, e.Y)); ImageListDragHelper.ImageList_DragMove(formP.X - this.treeViewCamera.Left, formP.Y - this.treeViewCamera.Top + this.treeViewCamera.Location.Y); // Get actual drop node CameraTreeNode dropNode = (CameraTreeNode)this.treeViewCamera.GetNodeAt(this.treeViewCamera.PointToClient(new Point(e.X, e.Y))); if (dropNode != null) { if (!dropNode.IsGroup() || dropNode == this.mDragNode) { e.Effect = DragDropEffects.None; return; } } // Avoid that drop node is child of drag node TreeNode tmpNode = dropNode; while (tmpNode != null && tmpNode.Parent != null) { if (tmpNode.Parent == this.mDragNode) { e.Effect = DragDropEffects.None; return; } tmpNode = tmpNode.Parent; } e.Effect = DragDropEffects.Move; // if mouse is on a new node select it ImageListDragHelper.ImageList_DragShowNolock(false); this.treeViewCamera.SelectedNode = dropNode; ImageListDragHelper.ImageList_DragShowNolock(true); }
private void treeViewCamera_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { // Point where the mouse is clicked. Point p = new Point(e.X, e.Y); // Get the node that the user has clicked. CameraTreeNode node = (CameraTreeNode)this.treeViewCamera.GetNodeAt(p); if (node == null) { return; } this.treeViewCamera.SelectedNode = node; if (node.IsGroup()) { this.contextMenuStripGroup.Show(this.treeViewCamera, p); } else { this.contextMenuStripCamera.Show(this.treeViewCamera, p); } } }
public void NodeReloadGlobalSettings(CameraTreeNode p) { if (p.IsGroup()) { foreach (CameraTreeNode n in p.Nodes) { this.NodeReloadGlobalSettings(n); } } else { CameraClass c = p.Item as CameraClass; if (c != null) { c.ReloadGlobalSettings(); } } }
private void NodeOnBoard(CameraTreeNode node) { if (node == null) { return; } if (node.IsGroup()) { foreach (TreeNode n in node.Nodes) { this.NodeOnBoard((CameraTreeNode)n); } } else { this.OnCameraTreeOnBoard(new CameraTreeEventArgs((CameraClass)node.Item)); } }
private bool NodeDelete(CameraTreeNode node) { if (node.IsGroup()) { if (node.Nodes.Count > 0) { ArrayList list = new ArrayList(); foreach (TreeNode n in node.Nodes) { list.Add(n); } foreach (TreeNode n in list) { if (false == this.NodeDelete(n as CameraTreeNode)) { return false; } } } if (node.Nodes.Count == 0) { node.Item.Remove(); node.Item.Clean(); node.Remove(); return true; } } else { CameraClass c = node.Item as CameraClass; if (c.Capturing == true) { MessageBox.Show(string.Format(Translator.Instance.T("删除摄像头[{0}]失败! 该摄像头正在录像中, 您必须首先停止录像, 然后再删除该摄像头."), c.Name), MotionPreference.Instance.MessageBoxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } CameraTreeNodeDeleteEventArgs e = new CameraTreeNodeDeleteEventArgs(c); this.OnCameraTreeBeforeDelete(e); if (e.Cancel == false) { node.Item.Remove(); node.Item.Clean(); node.Remove(); this.OnCameraTreeAfterDelete(e); return true; } } return false; }
private int NodeCount(CameraTreeNode p) { int r = 0; if (p.IsGroup()) { foreach (CameraTreeNode n in p.Nodes) { r += this.NodeCount(n); } } else { r ++; } return r; }