public SetParentChildForm(decimal mapid)
        {
            InitializeComponent();

            DataTable roottable = MapDBClass.GetTifInformation(mapid);

            //查询影像图结构
            PhotoList        = MapDBClass.GetPhotoList();
            ParentChildTable = MapDBClass.GetChildList();
            treeView1.Nodes.Clear();
            if (roottable != null && roottable.Rows.Count == 1)
            {
                TreeNode rootnode = new TreeNode(roottable.Rows[0]["Name"].ToString())
                {
                    Tag = roottable.Rows[0]["PhotoId"]
                };
                treeView1.Nodes.Add(rootnode);
                AddNode(rootnode);
                treeView1.SelectedNode = rootnode;
            }
        }
Пример #2
0
        /// <summary>
        /// 影像图树初始化
        /// </summary>
        public static void Initial()
        {
            //查询影像图结构
            DataTable table = MapDBClass.GetPhotoParentChildList();

            //循环向树中添加节点
            for (int i = 0; table != null && i < table.Rows.Count; i++)
            {
                //取得父区域名称
                string parentName = (string)table.Rows[i]["ParentName"];
                //取得子区域名称
                string childName = (string)table.Rows[i]["ChildName"];
                //查询父节点
                TreeNode node = FindNode(_PhotoRoot, parentName);
                //如果父区域不存在,则增加父节点
                if (node == null)
                {
                    node = new TreeNode(parentName);
                    for (int j = 0; j < table.Rows.Count; j++)
                    {
                        //取得父区域名称
                        string parentName1 = (string)table.Rows[j]["ParentName"];
                        if (parentName == parentName1)
                        {
                            //取得子区域名称
                            string   childName1 = (string)table.Rows[j]["ChildName"];
                            TreeNode subnode1   = FindNode(_PhotoRoot, childName1);
                            if (subnode1 != null)
                            {
                                subnode1.Parent.Nodes.Remove(subnode1);
                                node.Nodes.Add(subnode1);
                            }
                        }
                    }
                    _PhotoRoot.Nodes.Add(node);
                    continue;
                }
                //增加子节点
                TreeNode subnode = new TreeNode(childName);
                node.Nodes.Add(subnode);
            }
            //取得区域范围数据
            table = MapDBClass.GetPhotoList();
            //循环更新区域范围数据到影像图树中
            for (int i = 0; table != null && i < table.Rows.Count; i++)
            {
                PhotoData data = new PhotoData();
                data.PhotoId    = (int)table.Rows[i]["PhotoId"];
                data.Name       = (string)table.Rows[i]["Name"];
                data.FileName   = (string)table.Rows[i]["FileName"];
                data.MinX       = (double)table.Rows[i]["MinX"];
                data.MinY       = (double)table.Rows[i]["MinY"];
                data.MaxX       = (double)table.Rows[i]["MaxX"];
                data.MaxY       = (double)table.Rows[i]["MaxY"];
                data.Transform1 = (double)table.Rows[i]["Transform1"];
                data.Transform2 = (double)table.Rows[i]["Transform2"];
                data.Transform3 = (double)table.Rows[i]["Transform3"];
                data.Transform4 = (double)table.Rows[i]["Transform4"];
                data.Transform5 = (double)table.Rows[i]["Transform5"];
                data.Transform6 = (double)table.Rows[i]["Transform6"];
                data.Width      = (int)table.Rows[i]["Width"];
                data.Height     = (int)table.Rows[i]["Height"];
                TreeNode node = FindNode(_PhotoRoot, data.Name);
                if (node == null)
                {
                    continue;
                }
                node.Tag = data;
                SetParentData(node);
            }
            SetTreeNodeBoundingBox(_PhotoRoot);
        }