//找到复用梁 public List <string> GetItemAsync(string kval) { List <string> vs = new List <string>(); MxDrawSelectionSet select = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); filter.AddStringEx("TEXT,MTEXT", 5020); select.Select2(MCAD_McSelect.mcSelectionSetAll, null, null, null, filter); for (int i = 0; i < select.Count; i++) { MxDrawEntity entity = select.Item(i); if (entity == null) { continue; } if (entity.ObjectName == "McDbText") { MxDrawText tx = entity as MxDrawText; if (tx.TextString.Trim() != "" && kval.Contains(tx.TextString)) { vs.Add(tx.handle); } } } return(vs); }
//鼠标点击事件 private void axMxDrawX1_MouseEvent(object sender, AxMxDrawXLib._DMxDrawXEvents_MouseEventEvent e) { /* * 事件类型,1鼠标移动,2是鼠标左键按下,3是鼠标右键按下,4是鼠标左键双击 * 5是鼠标左键释放 6是鼠标右键释放 7是鼠标中键按下 8是鼠标中键释放 * 9是鼠标中键双击 10是鼠标中键滚动 */ switch (e.lType) { case 4: //左键选择元素图层--所有元素 //if(bar_state.state==true&& bar_state.id == 1001) { MxDrawSelectionSet mxDrawSelection = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); MxDrawPoint point = new MxDrawPoint(); point.x = e.dX; point.y = e.dY; mxDrawSelection.SelectAtPoint(point, filter); if (mxDrawSelection.Count > 0) { MxDrawEntity entity = mxDrawSelection.Item(1); //MxDrawLayerTable layer = (axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable(); //MxDrawLayerTableRecord dd = layer.GetAt(entity.Layer); if (entity.ObjectName == "McDbLine") { MessageBox.Show(JsonConvert.SerializeObject(new { handle = entity.handle, ID = entity.ObjectID, Line = entity.ObjectName, B = entity.LineType, pt1 = ((MxDrawLine)entity).GetStartPoint(), pt2 = ((MxDrawLine)entity).GetEndPoint(), //color=dd.Color.colorIndex })); } else { MessageBox.Show(JsonConvert.SerializeObject(new { handle = entity.handle, ID = entity.ObjectID, Line = entity.ObjectName, B = entity.LineType, rotate = ((MxDrawText)entity).Rotation //pt1 = ((MxDrawLine)entity).GetStartPoint(), //pt2 = ((MxDrawLine)entity).GetEndPoint(), //color=dd.Color.colorIndex })); } //double c=Models.MathSience.DistanceForPointToABLine(121324.953422, 33700.002475, ((MxDrawLine)entity).GetStartPoint(),((MxDrawLine)entity).GetEndPoint()); //double c1 = Algorithm.MathSience.GetAngle(new MxDrawPoint { x = 121324.95342187915, y = 54350.00279569807 }, ((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint()); double c1 = Algorithm.MathSience.GetLineK(((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint()); MessageBox.Show(c1.ToString()); //double c = Algorithm.MathSience.GetAngle2(((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint()); //MxDrawLine line = axMxDrawX1.HandleToObject("61FCB") as MxDrawLine; //PointF point1 = Algorithm.MathSience.point_intersection(line.GetStartPoint(), line.GetEndPoint(), ((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint()); } } break; } }
//选择集 private void AxMxDrawX1_MouseEvent(object sender, _DMxDrawXEvents_MouseEventEvent e) { MxDrawPoint start = new MxDrawPoint(), end = new MxDrawPoint(); if (PublicValue != null) { dynamic c = PublicValue; start.x = c.Lx; start.y = c.Ly; start.z = c.Lz; end.x = c.Rx; end.y = c.Ry; end.z = c.Rz; } { MxDrawSelectionSet mxDrawSelection; MxDrawResbuf filter; MxDrawPoint point; if (e.lType == 2 && (Control.ModifierKeys & Keys.Control) == Keys.Control) { mxDrawSelection = new MxDrawSelectionSet(); filter = new MxDrawResbuf(); point = new MxDrawPoint(); point.x = e.dX; point.y = e.dY; mxDrawSelection.SelectAtPoint(point, filter); //MessageBox.Show(mxDrawSelection.Count.ToString()); if (mxDrawSelection.Count > 0) { if (start.x != 0 && end.x != 0) { if (!MathSience.IsContains(point, start, end)) { return; } } //MessageBox.Show(mxDrawSelection.Item(0).handle.ToString()); axMxDrawX1.TwinkeEnt(mxDrawSelection.Item(0).ObjectID); if (BeamType == "change_line") { if (beam.beam.side_lines.Find(x => x == mxDrawSelection.Item(0).handle) == null) { beam.beam.side_lines.Add(mxDrawSelection.Item(0).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(0).ObjectID); beam.beam.side_lines.Remove(mxDrawSelection.Item(0).handle); } } if (BeamType == "change_dim") { if (beam.beam.dim_texts.Find(x => x == mxDrawSelection.Item(0).handle) == null) { beam.beam.dim_texts.Add(mxDrawSelection.Item(0).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(0).ObjectID); beam.beam.dim_texts.Remove(mxDrawSelection.Item(0).handle); } } if (BeamType == "change_seat") { if (beam.beam.seat_lines.Find(x => x == mxDrawSelection.Item(0).handle) == null) { beam.beam.seat_lines.Add(mxDrawSelection.Item(0).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(0).ObjectID); beam.beam.seat_lines.Remove(mxDrawSelection.Item(0).handle); } } } } else if (e.lType == 2 && (Control.ModifierKeys & Keys.Shift) == Keys.Shift) { //dynamic pt = PublicValue; //MxDrawPoint sp = new MxDrawPoint { x = pt.Lx, y = pt.Ly }; //MxDrawPoint ep = new MxDrawPoint { x = pt.Rx, y = pt.Ry }; mxDrawSelection = new MxDrawSelectionSet(); filter = new MxDrawResbuf(); point = new MxDrawPoint(); point.x = e.dX; point.y = e.dY; mxDrawSelection.SelectAtPoint(point, filter); if (mxDrawSelection.Count > 0) { MxDrawEntity entity = mxDrawSelection.Item(0); //MessageBox.Show(entity.Layer); filter = new MxDrawResbuf(); mxDrawSelection = new MxDrawSelectionSet(); filter.AddStringEx(entity.Layer, 8);// if (start.x == 0) { mxDrawSelection.Select(MCAD_McSelect.mcSelectionSetAll, null, null, filter);//获取此图层元素 } else { mxDrawSelection.Select(MCAD_McSelect.mcSelectionSetWindow, start, end, filter);//获取此图层元素 } for (int i = 0; i < mxDrawSelection.Count; i++) { axMxDrawX1.TwinkeEnt(mxDrawSelection.Item(i).ObjectID); if (BeamType == "change_line") { if (beam.beam.side_lines.Find(x => x == mxDrawSelection.Item(i).handle) == null) { beam.beam.side_lines.Add(mxDrawSelection.Item(i).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(i).ObjectID); beam.beam.side_lines.Remove(mxDrawSelection.Item(i).handle); } } if (BeamType == "change_dim") { if (beam.beam.dim_texts.Find(x => x == mxDrawSelection.Item(i).handle) == null) { beam.beam.dim_texts.Add(mxDrawSelection.Item(i).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(i).ObjectID); beam.beam.dim_texts.Remove(mxDrawSelection.Item(i).handle); } } if (BeamType == "change_seat") { if (beam.beam.seat_lines.Find(x => x == mxDrawSelection.Item(i).handle) == null) { beam.beam.seat_lines.Add(mxDrawSelection.Item(i).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(i).ObjectID); beam.beam.seat_lines.Remove(mxDrawSelection.Item(i).handle); } } //beam.beam.seat_lines.Add(mxDrawSelection.Item(i).handle); //选中元素 //axMxDrawX1.AddCurrentSelect(mxDrawSelection.Item(i).ObjectID, false, false); } } } //axMxDrawX1.SendStringToExecute(""); }; }