public void Cmd_ShowBounds() { if (!LicensingAgent.Check()) { return; } if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var objIds = acCurEd.GetAllSelection(false); var boolRes = acCurEd.GetBool("Save bounds? "); if (boolRes == null) { return; } var append = boolRes.Value; using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var sol = acTrans.GetBoundingBox(objIds, acCurDb); sol.Transparency = new Transparency(75); sol.Color = Colors.LayerColorBounds; TransientAgent.Add(sol); TransientAgent.Draw(); if (append) { acCurDb.AppendEntity(sol); } else { sol.Dispose(); } TransientAgent.Clear(); acTrans.Commit(); } }
public void SimpleAddGetObject() { var o = new MyObject(); var agent = new TransientAgent(); agent.Set(o); Transient <MyObject> a; var b = agent.TryGet(out a); Assert.IsTrue(b); Assert.IsInstanceOfType(a.Value, typeof(MyObject)); }
public void GetObjectByInterface() { IInput o = new InputInstance(); var agent = new TransientAgent(); agent.Set(o); Transient <IInput> transient; var b = agent.TryGet(out transient); Assert.IsTrue(b); Assert.IsInstanceOfType(transient.Value, typeof(IInput)); }
public void StoreTwoObjectsAndGetOneSecondTimes() { var o1 = new MyObject(); var o2 = new MyObject2(); var agent = new TransientAgent(); agent.Set(o1); agent.Set(o2); Transient <MyObject2> transient2; var b = agent.TryGet(out transient2); b = agent.TryGet(out transient2); Assert.IsFalse(b); }
public void StoreTwoObjectsAndGetOne() { var o1 = new MyObject(); var o2 = new MyObject2(); var agent = new TransientAgent(); agent.Set(o1); agent.Set(o2); Transient <MyObject2> m; var b = agent.TryGet(out m); Assert.IsTrue(b); Assert.IsInstanceOfType(m.Value, typeof(MyObject2)); }
public void StoreTwoObjectsAndGetTwo() { var o1 = new MyObject(); var o2 = new MyObject2(); var agent = new TransientAgent(); agent.Set(o1); agent.Set(o2); Transient <MyObject2> transient2; var b = agent.TryGet(out transient2); Assert.IsTrue(b); Assert.IsInstanceOfType(transient2.Value, typeof(MyObject2)); Transient <MyObject> transient1; var b1 = agent.TryGet(out transient1); Assert.IsTrue(b1); Assert.IsInstanceOfType(transient1.Value, typeof(MyObject)); }
public void Cmd_WeldMark() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; _ = acCurDoc.Editor; try { Entity jigEnt = WeldJig.Jig(out var arrowStart, out var symStart); var jigId = ObjectId.Null; if (jigEnt == null) { //jigEnt.Dispose(); return; } jigId = acCurDb.AppendEntity(jigEnt); Line line = null; var lineId = ObjectId.Null; var leftFacing = false; using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var arrowPt = new Point2d(arrowStart.X, arrowStart.Y); var symPt = new Point2d(symStart.X, symStart.Y); var angle = arrowPt.AngleBetween(symPt); var dDimScale = (double)Application.GetSystemVariable("DIMSCALE"); var length = SettingsUser.WeldSymbolLength * dDimScale; if (angle > 90 || angle < -90) { length = -length; leftFacing = true; } line = new Line(symStart, new Point3d(symStart.X + length, symStart.Y, 0)); lineId = acCurDb.AppendEntity(line, acTrans); acTrans.Commit(); } var weldGui = new WeldGui(line.StartPoint, line.EndPoint); weldGui.LeftFacing = leftFacing; var result = weldGui.ShowDialog(); TransientAgent.Clear(); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { if (result == DialogResult.OK) { foreach (var ent in weldGui.drawnEnts) { acCurDb.AppendEntity(ent, acTrans); } } else { var jigDel = acTrans.GetObject(jigId, OpenMode.ForWrite) as Entity; if (jigDel != null) { jigDel.Erase(); jigDel.Dispose(); } var lineDel = acTrans.GetObject(lineId, OpenMode.ForWrite) as Entity; if (lineDel != null) { lineDel.Erase(); lineDel.Dispose(); } line.Dispose(); } acTrans.Commit(); } weldGui.Dispose(); Utils.SetFocusToDwgView(); } catch (Exception ex) { Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(ex.ToString()); } }