コード例 #1
0
ファイル: Form1.cs プロジェクト: zhxy323/HUST-BDL-SRC
 public void uc_Click(object sender, EventArgs e)
 {
     if (_IsInit)
     {
         ucPointSelected = sender as UC.UCRefPoint;
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: zhxy323/HUST-BDL-SRC
 private void uc_LocationChanged(object sender, EventArgs e)
 {
     UC.UCRefPoint uc = sender as UC.UCRefPoint;
     if (uc != null)
     {
         if (_dictReaderLoc.ContainsKey(uc.PointName))
         {
             _dictReaderLoc[uc.PointName] = uc.Location;
         }
         else
         {
             _dictReaderLoc.Add(uc.PointName, uc.Location);
         }
     }
 }
コード例 #3
0
ファイル: Form1.cs プロジェクト: zhxy323/HUST-BDL-SRC
        private void AddNewReaderLoc(string pointname, System.Drawing.Color color, Point location)
        {
            PositionManage.UC.UCRefPoint uc = new PositionManage.UC.UCRefPoint();

            uc.PointName  = pointname;
            uc.PointColor = color;
            uc.Location   = location;

            //添加单击选中事件
            uc.Click += new EventHandler(uc_Click);

            //添加拖动事件
            uc.MouseDown       += new MouseEventHandler(uc_MouseDown);
            uc.MouseMove       += new MouseEventHandler(uc_MouseMove);
            uc.MouseUp         += new MouseEventHandler(uc_MouseUp);
            uc.LocationChanged += new EventHandler(uc_LocationChanged);

            this.panMap.Controls.Add(uc);

            _dictReaderLoc.Add(uc.PointName, uc.Location);
            ucPointSelected = uc;
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: zhxy323/HUST-BDL-SRC
        private void DealData(UDPData data)
        {
            //纳入表格
            DataRow dr = dtData.NewRow();

            dr["RowNo"]     = dtData.Rows.Count + 1;
            dr["TagNo"]     = data.TagNo;
            dr["ReferNo1"]  = data.Loc[0].ReferNo;
            dr["Distance1"] = data.Loc[0].Destance;
            dr["ReferNo2"]  = data.Loc[1].ReferNo;
            dr["Distance2"] = data.Loc[1].Destance;
            dr["ReferNo3"]  = data.Loc[2].ReferNo;
            dr["Distance3"] = data.Loc[2].Destance;

            dr["ReadDate"] = DateTime.Now;

            dtData.Rows.Add(dr);

            VoidDelegate dRefresh = new VoidDelegate(delegate
            {
                //this.dgData
                this.dgData.Refresh();
            });

            if (this.dgData.InvokeRequired)
            {
                this.Invoke(dRefresh);
            }
            else
            {
                dRefresh();
            }

            if (string.IsNullOrEmpty(data.Loc[2].ReferNo))
            {
                return;
            }

            //计算网格坐标
            int x, y;

            CalulateLocation(data, out x, out y);

            //显示
            VoidDelegate dShow = new VoidDelegate(delegate
            {
                UC.UCRefPoint ucPoint = null;
                if (!this.panMap.Controls.ContainsKey("uc" + data.TagNo))
                {
                    ucPoint            = new PositionManage.UC.UCRefPoint();
                    ucPoint.Name       = "uc" + data.TagNo;
                    ucPoint.PointName  = data.TagNo;
                    ucPoint.PointColor = Color.Blue;
                    this.panMap.Controls.Add(ucPoint);
                }
                else
                {
                    var ctrls = this.panMap.Controls.Find("uc" + data.TagNo, false);
                    if (ctrls.Length > 0)
                    {
                        ucPoint = ctrls[0] as UC.UCRefPoint;
                    }
                    else
                    {
                        return;
                    }
                }

                int iLocX = 0, iLocY = 0;
                //四顶点  x + y * 3, x + y * 3 + 1, x + y * 3 + 3, x + y * 3 + 4
                if (x == 0)
                {
                    iLocY = 300;
                }
                else
                {
                    iLocY = 100;
                }
                if (y == 0)
                {
                    iLocX = 350;
                }
                else if (y == 1)
                {
                    iLocX = 290;
                }
                else if (y == 2)
                {
                    iLocX = 220;
                }
                else if (y == 3)
                {
                    iLocX = 150;
                }
                else
                {
                    iLocX = 100;
                }

                ucPoint.Location = new Point(iLocX, iLocY);
            });

            if (this.dgData.InvokeRequired)
            {
                this.Invoke(dShow);
            }
            else
            {
                dShow();
            }
        }