Exemplo n.º 1
0
 private void MoveSHBItem_Click(object sender, EventArgs e)
 {
     try
     {
         var isLock = DBEntityFinder.Instance.VerifyLTTID(detail_fid);
         if (!isLock)
         {
             PublicMethod.Instance.AlertDialog("抄表箱没有被工单锁定,不能迁移户表!");
             Show();
             return;
         }
         var movept = dddMap.screen2geo(mouseLocation.X, mouseLocation.Y);
         var detail = DBManager.Instance.GetEntities <Detailreference_n>(o => o.G3E_FID == detail_fid && o.EntityState != EntityState.Delete).FirstOrDefault();
         if (detail != null)
         {
             if (detail.G3E_DETAILID == null)
             {
                 return;
             }
             var tt  = new SHBMove((long)detail.G3E_DETAILID, movept);
             var res = tt.ShowDialog();
             //var res = acApi.ShowModalDialog(tt);
             if (res == DialogResult.OK)
             {
                 // 加一个散户表,刷新窗口
                 var pb = new Dyhb();
                 pb.Height   = picWheight;
                 pb.Width    = picWwidth;
                 pb.Location = new System.Drawing.Point((int)mouseLocation.X - picWwidth / 2,
                                                        (int)mouseLocation.Y - picWheight / 2);
                 pb.Image             = imageList1.Images[0];
                 pb.Tag               = tt.g3e_Fid;
                 pb.ContextMenuStrip  = contextMenuStrip2;
                 pb.DyhbPosition      = new Point3d(movept[1], movept[0], 0);
                 pb.DyhbFid           = tt.g3e_Fid;
                 pb.DyhbDz            = tt.AZDZ;
                 pb.SizeMode          = PictureBoxSizeMode.StretchImage;
                 pb.MouseDoubleClick += pb_MouseDoubleClick;
                 pb.MouseDown        += pb_MouseDown;
                 pb.MouseHover       += pb_MouseHover;
                 pb.MouseUp          += pb_MouseUp;
                 pb.MouseMove        += pb_MouseMove;
                 pbs.Add(pb);
                 Controls.Add(pb);
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.Instance.Error(ex);
     }
 }
Exemplo n.º 2
0
 private void AddSHBItem_Click(object sender, EventArgs e)
 {
     try
     {
         var isLock = DBEntityFinder.Instance.VerifyLTTID(detail_fid);
         if (!isLock)
         {
             PublicMethod.Instance.AlertDialog("抄表箱没有被工单锁定,不能新增户表!");
             Show();
             return;
         }
         var mi = sender as ToolStripMenuItem;
         if (mi != null)
         {
             var tshbgeo = dddMap.screen2geo(mouseLocation.X, mouseLocation.Y);
             var tt      = new SHBEditer(formType.regionAdd, detail_fid, tshbgeo, true)
             {
                 Tag = mi.Text
             };
             if (DialogResult.OK == tt.ShowDialog())
             {
                 // 加一个散户表,刷新窗口
                 var pb = new Dyhb();
                 pb.Height   = picWheight;
                 pb.Width    = picWwidth;
                 pb.Location = new System.Drawing.Point((int)mouseLocation.X - picWwidth / 2,
                                                        (int)mouseLocation.Y - picWheight / 2);
                 pb.Image             = imageList1.Images[0];
                 pb.Tag               = tt.g_newFid;
                 pb.ContextMenuStrip  = contextMenuStrip2;
                 pb.DyhbPosition      = new Point3d(tshbgeo[1], tshbgeo[0], 0);
                 pb.DyhbFid           = tt.g_newFid;
                 pb.DyhbDz            = tt.AZDZ;
                 pb.SizeMode          = PictureBoxSizeMode.StretchImage;
                 pb.MouseDoubleClick += pb_MouseDoubleClick;
                 pb.MouseDown        += pb_MouseDown;
                 pb.MouseHover       += pb_MouseHover;
                 pb.MouseUp          += pb_MouseUp;
                 pb.MouseMove        += pb_MouseMove;
                 pbs.Add(pb);
                 Controls.Add(pb);
             }
         }
     }
     catch (Exception ex)
     {
         PublicMethod.Instance.AlertDialog(ex.Message);
     }
 }
Exemplo n.º 3
0
        private void SHBMap_Load(object sender, EventArgs e)
        {
            bMove = false;
            double min_x = 0;
            double min_y = 0;
            double max_x = 0;
            double max_y = 0;

            #region 计算出它的外围矩形。
            // 得到户表集合
            var shbs = GetSHB_NS();
            // 1 当前集抄箱有户表时,取出户表集合坐标范围
            if (shbs != null)
            {
                dyshbs = shbs.ToList();
                var allx = new List <double>();
                var ally = new List <double>();
                // 遍历户表集合的坐标
                foreach (var shb in shbs)
                {
                    var shb1   = shb;
                    var shbsdo = DBManager.Instance.GetEntities <Gg_jx_shbd_pt_sdogeom>(o => shb1 != null && (o.G3E_FID == shb1.G3E_FID && o.EntityState != EntityState.Delete)).FirstOrDefault();
                    if (shbsdo == null)
                    {
                        LogManager.Instance.Error("没有设备 " + shb.G3E_FID + " 对应的坐标数据,请联系数据管理人员。\n");
                        //PublicMethod.Instance.ShowMessage("没有设备 " + shb.G3E_FID + " 对应的坐标数据,请联系数据管理人员。\n");
                        continue;
                    }
                    var multipoint = shbsdo.G3E_GEOMETRY as Multipoint;
                    if (multipoint == null)
                    {
                        continue;
                    }
                    var pt = new Point3d(multipoint.Points[0].X, multipoint.Points[0].Y, 0);
                    allx.Add(pt.X);
                    ally.Add(pt.Y);
                }
                // 得到x轴的最大点、最小点
                if (allx.Count > 0)
                {
                    min_x = allx.Min();
                    max_x = allx.Max();
                }
                // 得到y轴的最大点、最小点
                if (ally.Count > 0)
                {
                    min_y = ally.Min();
                    max_y = ally.Max();
                }
            }
            //2 当没有没有设备时候,以沿布图集抄箱坐标为中心点,上下加减250米
            var    vcbx = DBManager.Instance.GetEntities <Gg_pd_cbx_pt_sdogeom>(o => o.G3E_FID == detail_fid).First();
            double dx   = 250 / DMap.DD;
            double dy   = dx;
            if (min_x == 0 || max_x == 0 || min_y == 0 || max_x == 0)
            {
                var vcbxpoint = vcbx.G3E_GEOMETRY as Multipoint;
                if (vcbxpoint != null)
                {
                    min_y = vcbxpoint.Points[0].Y - dy;
                    min_x = vcbxpoint.Points[0].X - dy;
                    max_y = vcbxpoint.Points[0].Y + dy;
                    max_x = vcbxpoint.Points[0].X + dy;
                }
            }
            // 当长宽比超过3时,拉伸窗口
            if ((max_x - min_x) / (max_y - min_y) > 3)
            {
                min_y = max_y - (max_x - min_x);
            }
            else if ((max_y - min_y) / (max_x - min_x) > 3)
            {
                max_x = min_x + (max_y - min_y);
            }

            // 3 当设备只有一个,或者成一直线时
            if (min_x == max_x)
            {
                min_x -= dx;
                max_x += dx;
            }
            else // 放大
            {
                var t = (max_x - min_x) / 4;
                min_x -= t;
                max_x += t;
            }
            if (min_y == max_y)
            {
                min_y -= dy;
                max_y += dy;
            }
            else
            {
                var t = (max_y - min_y) / 4;
                min_y -= t;
                max_y += t;
            }
            #endregion

            wWidth  = this.ClientSize.Width;
            wHeight = this.ClientSize.Height;

            dddMap.createDmap(min_x, max_x, min_y, max_y, wWidth, wHeight);

            if (shbs != null)
            {
                dyshbs = shbs.ToList();
            }
            List <int> xindex = new List <int>();
            List <int> yindex = new List <int>();
            foreach (var shb in dyshbs)
            {
                var      pt = GetPtFromGg_jx_shbd_pt_sdogeom(shb.G3E_FID);
                double[] xy = dddMap.geo2screen(pt.Y, pt.X);

                xindex.Add((int)xy[0]);
                yindex.Add((int)xy[0]);
            }
            int xcount = 0, ycount = 0;
            int i = 0;
            for (i = 0; i < xindex.Count - 1; i++)
            {
                if (Math.Floor((double)(xindex[i] - xindex[i + 1])) < 8)
                {
                    xcount++;
                }
            }
            if (xindex.Count >= 2)
            {
                if (Math.Floor((double)(xindex[i - 1] - xindex[i])) < 8)
                {
                    xcount++;
                }
            }
            for (i = 0; i < yindex.Count - 1; i++)
            {
                if (Math.Floor((double)(yindex[i] - yindex[i + 1])) < 10)
                {
                    ycount++;
                }
            }
            if (yindex.Count >= 2)
            {
                if (Math.Floor((double)(yindex[i - 1] - yindex[i])) < 10)
                {
                    ycount++;
                }
            }

            if (xcount > wWidth / 16)
            {
                xcount = (int)(wWidth * 0.75 / xcount);
            }
            else
            {
                xcount = 16;
            }
            if (ycount > wHeight / 16)
            {
                ycount = (int)(wHeight * 0.75 / ycount);
            }
            else
            {
                ycount = 16;
            }

            picMapWidth  = ((double)xcount / wWidth) * (dddMap.ScreenMapMaxX - dddMap.ScreenMapMinX);
            picMapHeight = (double)ycount / wHeight * (dddMap.ScreenMapMaxY - dddMap.ScreenMapMinY_In);

            picWwidth  = (int)(picMapWidth / (dddMap.ScreenMapMaxX - dddMap.ScreenMapMinX) * wWidth);
            picWheight = (int)(picMapHeight / (dddMap.ScreenMapMaxY - dddMap.ScreenMapMinY_In) * wHeight);

            #region 初始化低压户表

            foreach (var shb in dyshbs)
            {
                var      pt = GetPtFromGg_jx_shbd_pt_sdogeom(shb.G3E_FID);
                double[] xy = dddMap.geo2screen(pt.Y, pt.X);

                var pb = new Dyhb();
                pb.Height   = picWheight;
                pb.Width    = picWwidth;
                pb.Location = new System.Drawing.Point((int)xy[0] - xcount / 2, (int)xy[1] - ycount / 2);
                pb.Image    = imageList1.Images[0];
                if (search_fid == shb.G3E_FID)
                {
                    pb.Image = imageList1.Images[1];
                }
                pb.Tag = shb.G3E_FID;
                pb.ContextMenuStrip  = contextMenuStrip2;
                pb.DyhbPosition      = pt;
                pb.DyhbFid           = shb.G3E_FID;
                pb.DyhbDz            = shb.AZDZ;
                pb.SizeMode          = PictureBoxSizeMode.StretchImage;
                pb.MouseDoubleClick += pb_MouseDoubleClick;
                pb.MouseDown        += pb_MouseDown;
                pb.MouseHover       += pb_MouseHover;
                pb.MouseUp          += pb_MouseUp;
                pb.MouseMove        += pb_MouseMove;
                pbs.Add(pb);
                Controls.Add(pb);
            }

            #endregion

            drawBackImg();
        }