public Form1() { InitializeComponent(); drawArea = MapBox.CreateGraphics(); Control.CheckForIllegalCrossThreadCalls = false; SubnetBox.MaxLength = 11; }
private void MapBox_Click(object sender, EventArgs e) { Point p = MapBox.PointToClient(MousePosition); if (pflag == 0) { Graphics g = MapBox.CreateGraphics(); g.FillEllipse(Brushes.Blue, p.X, p.Y, 3, 3); px = bx = p.X; py = by = (213 - p.Y); label34.Text = bx + "," + by; pflag = 1; } else if (pflag == 1) { dx = p.X - bx; dy = (213 - p.Y) - by; distance = (float)Math.Sqrt(dx * dx + dy * dy * lhp * lhp); RecvBoxAddText = "宽高比=" + lhp + "\r\n" + "锚点距离=" + distance + "\r\n"; xpro = truedist / distance; ypro = xpro * lhp; label36.Text = p.X + "," + (213 - p.Y); RecvBoxAddText = "横向比值=" + xpro + "\r\n" + "纵向比值=" + ypro + "\r\n"; pflag = 2; } }
private void ClearImage_Click(object sender, EventArgs e) { pflag = 0; Graphics g = MapBox.CreateGraphics(); MapBox.Refresh(); label34.Text = label36.Text = "0,0"; }
private void MapBox_MouseMove(object sender, MouseEventArgs e) { if (pflag == 1) { MapBox.Refresh(); Graphics g = MapBox.CreateGraphics(); g.DrawLine(Pens.Blue, bx, (213 - by), e.Location.X, e.Location.Y); } else if (pflag == 2) { Graphics g = MapBox.CreateGraphics(); MapBox.Refresh(); g.FillEllipse(Brushes.Blue, bx, 213 - by, 3, 3); pflag = 3; } label38.Text = e.Location.X + "," + (213 - e.Location.Y); }
private void LabDist_TextChanged(object sender, EventArgs e) { float dist; double angle; double xdist, ydist; Graphics g = MapBox.CreateGraphics(); dist = float.Parse(LabDist.Text) - befordist; befordist = float.Parse(LabDist.Text); angle = double.Parse(LabYaw.Text); xdist = Math.Cos(Math.PI * angle / 180) * dist; ydist = Math.Sin(Math.PI * angle / 180) * dist; px = px + (int)(xdist / xpro); py = py + (int)(ydist / ypro); RecvBoxAddText = "坐标点=" + px + "," + py + "\r\n"; RecvBoxAddText = "路程=" + xdist + "," + ydist + "\r\n"; g.FillEllipse(Brushes.Blue, px, 213 - py, 3, 3); }
public void GenerateMap() { MapBox.CreateGraphics().Clear(AppWindow.DefaultBackColor); int w = 0, h = 0; try { w = Convert.ToInt32(TXTWidth.Text); h = Convert.ToInt32(TXTHeight.Text); } catch { Console.WriteLine("Input string is not a sequence of digits or Overflow"); w = 20; h = 20; } paintMap = new Bitmap(MapBox.Size.Width, MapBox.Size.Height); g = Graphics.FromImage(paintMap); nodes = new MapNodes(w + 2, h + 2, MapBox.Size.Height); // + 2 is borders g.DrawRectangles(stdPen, nodes.nodeRect); FillBorderNodes(); GenerateNoise(); MapBox.Image = paintMap; }
private void GUIForm_Load(object sender, EventArgs e) { ratioX = MapBox.Width / 1035f; ratioY = MapBox.Height / 680f; G = MapBox.CreateGraphics(); }