private void button3_Click(object sender, EventArgs e) { try { if (waringPointList.Count > 0) { for (int i = 0; i < waringPointList.Count; i++) { WarningRegionClass wariningregion = new WarningRegionClass(); string strJson = JsonConvert.SerializeObject(waringPointList[i]); mainform.dbBridge.onDBnodearea_Insert(strJson); } } } catch { } }
private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { int nx = e.X; int ny = e.Y; W_x_2 = e.X; W_y_2 = e.Y; Graphics g = pictureBox1.CreateGraphics(); Pen pen = new Pen(Color.Red, 2); if (bMapMouseDN) { RectangleF rectT = RectTmp; //rectT.X = (float)((rectT.X / ratio) -translate_x); //rectT.Y = (float)((rectT.Y / ratio)-translate_y); rectT.X = (float)((rectT.X - 0) / Wheelratio); rectT.Y = (float)((rectT.Y - 0) / Wheelratio); rectT.Width = (float)(rectT.Width / Wheelratio); rectT.Height = (float)(rectT.Height / Wheelratio); waringRectList.Add(rectT); WarningRegionClass wariningregion = new WarningRegionClass(); wariningregion.nX1 = (float)(((W_x_1 - dOrignX) * resolution)) / Wheelratio; wariningregion.nY1 = (float)(((W_y_1 - dOrignY) * resolution)) / Wheelratio * -1; wariningregion.nX2 = (float)(((W_x_2 - dOrignX) * resolution)) / Wheelratio; wariningregion.nY2 = (float)(((W_y_2 - dOrignY) * resolution)) / Wheelratio * -1; waringPointList.Add(wariningregion); picturebox_paint(); g.Dispose(); pen.Dispose(); } }
private void picturebox_paint() { try { dOrignX = ((ori_x * -1) / resolution); dOrignY = ((ori_y) / resolution); if (dOrignY < 0) { dOrignY *= -1; } dOrignY = img.Height - dOrignY; dOrignX = dOrignX * (float)Wheelratio; dOrignY = dOrignY * (float)Wheelratio; Bitmap sourceBMP = new Bitmap(img, img.Width, img.Height); Image image_resize; image_resize = ZoomIn(sourceBMP, (float)Wheelratio); Bitmap displayBMP = new Bitmap(image_resize.Width, image_resize.Height); displayBMP.SetResolution(image_resize.HorizontalResolution, image_resize.VerticalResolution); Graphics g = Graphics.FromImage(displayBMP); g.DrawImage(image_resize, new PointF(0, 0)); Pen pen4 = new Pen(Brushes.Red, 5); pen4.DashStyle = DashStyle.Dot; if (pictureBox1.Image != null) { if (Data.Instance.isConnected) { if (Data.Instance.robot_liveinfo.robotinfo.msg != null) { for (int i = 0; i < Data.Instance.robot_liveinfo.robotinfo.msg.robolist.Count; i++) { if (Data.Instance.robot_liveinfo.robotinfo.msg.robolist.Count > 0) { float robotx = (float)Data.Instance.robot_liveinfo.robotinfo.msg.robolist[i].pose.x; float roboty = (float)Data.Instance.robot_liveinfo.robotinfo.msg.robolist[i].pose.y; float cellX = (float)(robotx / resolution); float cellY = (float)(roboty / resolution); PointF pos = new PointF(); pos.X = dOrignX + cellX * (float)Wheelratio; pos.Y = dOrignY - cellY * (float)Wheelratio; Pen pen_robot = new Pen(Brushes.BlueViolet, 3); pen_robot.DashStyle = DashStyle.Solid; g.DrawEllipse(pen_robot, pos.X - 10, pos.Y - 10, 20, 20); g.DrawString(string.Format("{0}", Data.Instance.robot_liveinfo.robotinfo.msg.robolist[i].RID), new Font("고딕체", 30), Brushes.Black, pos.X - 20, pos.Y + 10); pen_robot.Dispose(); } } } } } Pen bb = new Pen(Brushes.Red, 4); if (aa.Count > 0) { for (int i = 0; i < save.Count; i++) { g.DrawEllipse(bb, aa[i].X - 1, aa[i].Y - 1, 2, 2); } } Paint_conveyor(); if (mainform.node_area_.Count() > 0) { for (int i = 0; i < waringPointList.Count; i++) { WarningRegionClass wariningregion = new WarningRegionClass(); wariningregion = waringPointList[i]; float wx = wariningregion.nX1; float wy = wariningregion.nY1; float wx2 = wariningregion.nX2; float wy2 = wariningregion.nY2; float cellX = wx / resolution; float cellY = wy / resolution; float cellX2 = wx2 / resolution; float cellY2 = wy2 / resolution; PointF pos = new PointF(); pos.X = dOrignX + cellX * Wheelratio; pos.Y = dOrignY - cellY * Wheelratio; PointF pos2 = new PointF(); pos2.X = dOrignX + cellX2 * Wheelratio; pos2.Y = dOrignY - cellY2 * Wheelratio; g.DrawRectangle(pen4, pos.X, pos.Y, pos2.X - pos.X, pos2.Y - pos.Y); } } pictureBox1.Image = displayBMP; if (pictureBox1.Image != null) { sourceBMP.Dispose(); g.Dispose(); pen4.Dispose(); } } catch { } }