private void setInforLayer() { // set information for Layer. ObservableCollection <string> obserCollect = ImplementationDatabase.getLayers(); TextLayer = obserCollect; LineLayer = obserCollect; CircleLayer = obserCollect; }
public void callSettingBalloon() { // get all of the selected group. ImplementationDatabase.LstGroup = ImplementationDatabase.getSelectedGroups(); Settings setting = Settings.getInstance(); BalloonSettingDialog balloonDialog = new BalloonSettingDialog(); balloonDialog.ShowDialog(); }
private void reflectSettingToAutoCAD() { if (IsSelectedAny) { ImplementationDatabase.updateValueForSelectedElements(); } else { ImplementationDatabase.updateValueForAllOfElements(); } }
public void insertBalloon() { Settings setting = Settings.getInstance(); // make the line and circle. Line _lineBal = new Line(); Circle _circleBal = new Circle(); // set properties for line and circle. _lineBal.ColorIndex = setting.IndexColorLine; _circleBal.ColorIndex = setting.IndexColorCircle; _circleBal.Diameter = setting.Diameter; // get the first point. Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; PromptPointOptions ptPointOpt = new PromptPointOptions("Pick the first point: "); PromptPointResult ptPointRes = ed.GetPoint(ptPointOpt); if (ptPointRes.Status != PromptStatus.OK) { return; } // Turn the point at UCS into the point at WCS. Point3d ptUCS = ptPointRes.Value; _lineBal.StartPoint = ptUCS.TransformBy(ed.CurrentUserCoordinateSystem); // Jig action. BalloonJig jigBalloon = new BalloonJig(_lineBal, _circleBal); PromptResult prompt = ed.Drag(jigBalloon); if (prompt.Status == PromptStatus.Cancel || prompt.Status == PromptStatus.Error) { return; } // save all of elements into Database. Database dwg = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database; using (Transaction trans = dwg.TransactionManager.StartTransaction()) { try { BlockTable blk = trans.GetObject(dwg.BlockTableId, OpenMode.ForWrite) as BlockTable; if (blk == null) { return; } // make text for circle. DBText _textBal = makeText(_circleBal.Center); _textBal.ColorIndex = setting.IndexColorText; _textBal.TextString = setting.Text; // make the list of objectId of each elements. List <ObjectId> lstObjectId = new List <ObjectId>(); // append elements into database. BlockTableRecord blkRecord = trans.GetObject(blk[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; ObjectId objLineId = blkRecord.AppendEntity(_lineBal); lstObjectId.Add(objLineId); ObjectId objCircleId = blkRecord.AppendEntity(_circleBal); lstObjectId.Add(objCircleId); ObjectId objTextId = blkRecord.AppendEntity(_textBal); lstObjectId.Add(objTextId); // save id of each elements. ImplementationDatabase.LstObjectId = lstObjectId; trans.AddNewlyCreatedDBObject(_lineBal, true); trans.AddNewlyCreatedDBObject(_circleBal, true); trans.AddNewlyCreatedDBObject(_textBal, true); trans.Commit(); } catch (System.Exception) { trans.Abort(); throw; } } // get name for this group. PromptStringOptions strOptions = new PromptStringOptions("The name of this entity: "); strOptions.AllowSpaces = true; PromptResult promptRes = ed.GetString(strOptions); if (promptRes.Status != PromptStatus.OK) { ImplementationDatabase.NameGroup = "*"; } else { ImplementationDatabase.NameGroup = promptRes.StringResult; } // make group. ImplementationDatabase.makeGroup(); }