private void btnOK(object sender, EventArgs e) { if (this.comboBox1.SelectedIndex == -1) { return; } if (this.comboBox1.SelectedIndex == 0) { return; } if (hintMsg.Initializing) { return; } try { hintMsg.pCurrent.x = double.Parse(this.textBox5.Text); } catch { } try { hintMsg.pCurrent.y = double.Parse(this.textBox4.Text); } catch { } try { hintMsg.pCurrent.w = double.Parse(this.textBox3.Text); } catch { } DataArea.mapModel.Points[this.comboBox1.SelectedIndex] = hintMsg.pCurrent; this.panel1.Visible = false; DataArea.drawFormat.selfAdjustSize(DataArea.mapModel); DrawPath path = new DrawPath(DataArea.mapModel, DataArea.drawFormat); path.drawCurPos(new KeyPoint()); this.picPath.Image = path.getDrawImg(); this.picPath.BackgroundImage = new DrawPolygon(DataArea.mapModel, DataArea.drawFormat).getDrawImg(); }
private void evtClickedPictureBox(object sender, EventArgs e) { Point ptMouse = this.picPath.PointToClient(MousePosition); DrawPath path = new DrawPath(DataArea.mapModel, DataArea.drawFormat); List <Point> ptKey = path.getPtLocInPic(); int ptSize = DataArea.drawFormat.PointSize; if (ptSize < 3) { ptSize = 3; } int hint = -1; for (int i = 0; i < ptKey.Count; i++) { int xerr = Math.Abs(ptKey[i].X - ptMouse.X); int yerr = Math.Abs(ptKey[i].Y - ptMouse.Y); if (xerr <= ptSize && yerr <= ptSize) { hint = i; break; } } showHint(hint, ptMouse.X, ptMouse.Y); }
private void updatePath(KeyPoint curPos) { DrawPath path = new DrawPath(DataArea.mapModel, DataArea.drawFormat); path.drawCurPos(curPos); this.picPath.Image = path.getDrawImg(); }
private static void showNewMap() { // 添加当前点以及环境信息 MapModel m = new MapModel(DataArea.mapModel); m.Points.Add(PortManager.drPort.getPosition()); if (proSeg != null) { m.Segments.Add(proSeg.getSegment()); } // 100ms刷新一次显示 DataArea.drawFormat.selfAdjustSize(m); DrawPath drawP = new DrawPath(m, DataArea.drawFormat); DrawPolygon drawB = new DrawPolygon(m, DataArea.drawFormat); if (!Form1.closing && DisplayMethod.curState == DisplayMethod.displayItem.RefPath) { Form1.MForms[1].Invoke(Form_Path.refreshMethod, drawP.getDrawImg(), drawB.getDrawImg()); } }
private void btnOpen_Click(object sender, EventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { // 打开对应文件 DataArea.mapFile = new MapFile(dialog.FileName); DataArea.mapModel = new MapModel(); DataArea.mapFile.readNodeData(DataArea.mapModel); // 填写相关信息 //this.textBox1.Text = FilenameUtil.getFilename(dialog.FileName, ".xml"); //this.textBox2.Text = dialog.FileName; // 绘制路径 DataArea.drawFormat.selfAdjustSize(DataArea.mapModel); DrawPath path = new DrawPath(DataArea.mapModel, DataArea.drawFormat); path.drawCurPos(new KeyPoint()); this.picGenMap.Image = path.getDrawImg(); this.picGenMap.BackgroundImage = new DrawPolygon(DataArea.mapModel, DataArea.drawFormat).getDrawImg(); } }
private void btnDelete(object sender, EventArgs e) { if (hintMsg.Initializing) { return; } if (this.comboBox1.SelectedIndex == 0) { return; } DataArea.mapModel.Points.RemoveAt(this.comboBox1.SelectedIndex); this.panel1.Visible = false; DataArea.drawFormat.selfAdjustSize(DataArea.mapModel); DrawPath path = new DrawPath(DataArea.mapModel, DataArea.drawFormat); path.drawCurPos(new KeyPoint()); this.picPath.Image = path.getDrawImg(); this.picPath.BackgroundImage = new DrawPolygon(DataArea.mapModel, DataArea.drawFormat).getDrawImg(); }