Пример #1
0
        private void GetObjectInformation()
        {
            DataTable table = MapDBClass.GetObjectById(MapId, LayerId, ObjectId);

            if (table != null && table.Rows.Count > 0)
            {
                byte[]   data     = (byte[])table.Rows[0]["ObjectData"];
                Geometry geometry = (Geometry)Common.DeserializeObject(data);
                Caption = ObjectName;// geometry.Text;
                if (Caption == null)
                {
                    Caption = "";
                }
                Message = geometry.Message;
                if (Message == null)
                {
                    Message = "";
                }
                tabControl1.TabPages.Clear();
                List <Image> images = MapDBClass.GetPicures(MapId, LayerId, ObjectId);
                _Images = images;
                for (int i = 0; i < images.Count; i++)
                {
                    int index = i + 1;
                    tabControl1.TabPages.Add(index.ToString(), index.ToString());
                    PictureBox pic = new PictureBox();
                    pic.Image    = images[i];
                    pic.SizeMode = PictureBoxSizeMode.Zoom;
                    pic.Click   += new EventHandler(pic_Click);
                    pic.Cursor   = Cursors.Hand;
                    tabControl1.TabPages[i].Controls.Add(pic);
                    pic.Dock = DockStyle.Fill;
                }
                if (images == null || images.Count <= 0)
                {
                    tabControl1.Visible = false;
                }
                else
                {
                    tabControl1.Visible = true;
                    //tabControl1.Location = new System.Drawing.Point(10, this.Height-100);
                }
            }
            try
            {
                List <SqlParameter> param = new List <SqlParameter>();
                param.Add(new SqlParameter("MapId", MapId));
                param.Add(new SqlParameter("LayerId", LayerId));
                param.Add(new SqlParameter("ObjectId", ObjectId));
                table = SqlHelper.Select(SqlHelper.GetSql("SelectProjectByObject"), param);
                btnProjectArea.Visible      = table != null && table.Rows.Count > 0;
                btnProjectAreaPrice.Visible = btnProjectArea.Visible;
            }
            catch (Exception ex)
            {
                Common.ShowError(ex);
            }
        }
Пример #2
0
        /// <summary>
        /// 添加元素
        /// </summary>
        /// <param name="map"></param>
        /// <param name="tree"></param>
        /// <param name="cmd"></param>
        private void AddObject(MapImage map, MyTree tree, string[] cmd)
        {
            if (cmd.Length != 4)
            {
                return;
            }
            decimal  mapid     = GetId(cmd[1]);
            decimal  layerid   = GetId(cmd[2]);
            decimal  objectid  = GetId(cmd[3]);
            TreeNode layerNode = FindLayer(tree.Nodes[0], layerid);

            if (layerNode == null)
            {
                return;
            }
            if (!(layerNode.Tag is VectorLayer))
            {
                return;
            }
            VectorLayer layer = layerNode.Tag as VectorLayer;

            if (!(layer.DataSource is GeometryProvider))
            {
                return;
            }
            GeometryProvider      provider   = layer.DataSource as GeometryProvider;
            Collection <Geometry> geometries = provider.Geometries as Collection <Geometry>;
            //取得元素信息
            DataTable objecttable = MapDBClass.GetObjectById(mapid, layerid, objectid);

            for (int j = 0; j < objecttable.Rows.Count; j++)
            {
                byte[]   data     = (byte[])objecttable.Rows[j]["ObjectData"];
                Geometry geometry = (Geometry)Common.DeserializeObject(data);
                geometry.ID     = objectid;
                geometry.Select = false;
                geometries.Add(geometry);
                AddGeometryToTree(layerNode, geometry, geometry.Text);
            }
        }