public ListBox () : base() { items = CreateItemCollection (); item_height = -1; selected_indices = new SelectedIndexCollection (this); selected_items = new SelectedObjectCollection (this); requested_height = bounds.Height; InternalBorderStyle = BorderStyle.Fixed3D; //BackColor = ThemeEngine.Current.ColorWindow; /* Vertical scrollbar */ //TODO: add scroll event handler /* Horizontal scrollbar */ //TODO: add scroll event handler /* Events */ SetStyle (ControlStyles.UserPaint, false); #if NET_2_0 custom_tab_offsets = new IntegerCollection (this); #endif }
public void MoveStretchPointsAt(IntegerCollection indices, Vector3d offset) { createInstance(); BaseEntity.MoveStretchPointsAt(indices,offset); tr.Dispose(); }
public void GetGripPoints(Point3dCollection gripPoints, IntegerCollection snapModes, IntegerCollection geometryIds) { createInstance(); BaseEntity.GetGripPoints(gripPoints, snapModes,geometryIds); tr.Dispose(); }
public override void GetObjectSnapPoints(Entity ent, ObjectSnapModes mode, IntPtr gsm, Point3d pick, Point3d last, Matrix3d view, Point3dCollection snaps, IntegerCollection geomIds, Matrix3d insertion) { }
public void AddRange(IntegerCollection value) { AddRangeInternal((ICollection)value); }
public override void GetObjectSnapPoints(Entity entity, ObjectSnapModes snapMode, IntPtr gsSelectionMark, Point3d pickPoint, Point3d lastPoint, Matrix3d viewTransform, Point3dCollection snapPoints, IntegerCollection geometryIds) { base.GetObjectSnapPoints(entity, snapMode, gsSelectionMark, pickPoint, lastPoint, viewTransform, snapPoints, geometryIds); if ((snapMode & ObjectSnapModes.ModeEnd) == ObjectSnapModes.ModeEnd) { Circle c = (Circle)entity; LineSegment3d[] lines = GetLines(c); foreach (LineSegment3d l in lines) { snapPoints.Add(l.StartPoint); snapPoints.Add(l.EndPoint); } } }
/// <inheritdoc /> public override void GetObjectSnapPoints(Entity entity, ObjectSnapModes snapMode, IntPtr gsSelectionMark, Point3d pickPoint, Point3d lastPoint, Matrix3d viewTransform, Point3dCollection snapPoints, IntegerCollection geometryIds) { Debug.Print("WeldJointOsnapOverrule"); if (IsApplicable(entity)) { EntityUtils.OsnapOverruleProcess(entity, snapPoints); } else { base.GetObjectSnapPoints(entity, snapMode, gsSelectionMark, pickPoint, lastPoint, viewTransform, snapPoints, geometryIds); } }
protected override bool WorldDrawData(WorldDraw draw) { if (!base.WorldDrawData(draw)) return false; TransientManager ctm = TransientManager.CurrentTransientManager; IntegerCollection ints = new IntegerCollection(); // Draw any outstanding segments (and do so only once) bool wasCalibrating = _calibrating; while (_lineSegs.Count > 0) { // Get the line segment and remove it from the list LineSegment3d ls = _lineSegs[0]; _lineSegs.RemoveAt(0); // Create an equivalent, red, database line // (or yellow, if calibrating) Line ln = new Line(ls.StartPoint, ls.EndPoint); ln.ColorIndex = (wasCalibrating ? 2 : 1); _lines.Add(ln); // Draw it as transient graphics ctm.AddTransient( ln, TransientDrawingMode.DirectShortTerm, 128, ints ); _calibrating = false; } if (_drawing) { if (_cursor == null) { if (_vertices.Count > 0) { // Clear our skeleton ClearTransients(); _curPt = _vertices[_vertices.Count - 1]; // Make our sphere 10cm in diameter (5cm radius) Solid3d sol = new Solid3d(); sol.CreateSphere(0.05); _cursor = sol; _cursor.TransformBy( Matrix3d.Displacement(_curPt - Point3d.Origin) ); _cursor.ColorIndex = 2; ctm.AddTransient( _cursor, TransientDrawingMode.DirectShortTerm, 128, ints ); } } else { if (_vertices.Count > 0) { Point3d newPt = _vertices[_vertices.Count - 1]; _cursor.TransformBy( Matrix3d.Displacement(newPt - _curPt) ); _curPt = newPt; ctm.UpdateTransient(_cursor, ints); } } } else // !_drawing { if (_cursor != null) { ctm.EraseTransient(_cursor, ints); _cursor.Dispose(); _cursor = null; } } return true; }
protected override bool WorldDrawData(WorldDraw draw) { if (!base.WorldDrawData(draw)) { return(false); } var ctm = TransientManager.CurrentTransientManager; var ints = new IntegerCollection(); while (_lineSegs.Count > 0) { // Get the line segment and remove it from the list var ls = _lineSegs[0]; _lineSegs.RemoveAt(0); // Create an equivalent, red, database line // (or yellow, if calibrating) var ln = new Line(ls.StartPoint, ls.EndPoint); ln.ColorIndex = 1; _lines.Add(ln); // Draw it as transient graphics ctm.AddTransient( ln, TransientDrawingMode.DirectShortTerm, 128, ints ); } if (_drawing) { if (_cursor == null) { if (_vertices.Count > 0) { // Clear our skeleton ClearTransients(); _curPt = _vertices[_vertices.Count - 1]; // Make our sphere 10cm in diameter (5cm radius) var sol = new Solid3d(); sol.CreateSphere(0.05); _cursor = sol; _cursor.TransformBy( Matrix3d.Displacement(_curPt - Point3d.Origin) ); _cursor.ColorIndex = 2; ctm.AddTransient( _cursor, TransientDrawingMode.DirectShortTerm, 128, ints ); } } else { if (_vertices.Count > 0) { var newPt = _vertices[_vertices.Count - 1]; _cursor.TransformBy( Matrix3d.Displacement(newPt - _curPt) ); _curPt = newPt; ctm.UpdateTransient(_cursor, ints); } } } else // !_drawing { if (_cursor != null) { ctm.EraseTransient(_cursor, ints); _cursor.Dispose(); _cursor = null; } } return(true); }
public void Cmd_DimDelete() { var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var prEntOpt = new PromptEntityOptions("\nSelect a dimension system to remove from: "); prEntOpt.SetRejectMessage("\nOnly linear dimensions may be selected."); prEntOpt.AllowNone = false; prEntOpt.AddAllowedClass(typeof(RotatedDimension), false); var prEntRes = acCurEd.GetEntity(prEntOpt); if (prEntRes.Status != PromptStatus.OK) { return; } var objId = prEntRes.ObjectId; var delMatrix = acCurEd.GetAlignedMatrix(); var eqPoint = CalcTol.ReturnCurrentTolerance(); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var acEnt = acTrans.GetObject(objId, OpenMode.ForWrite) as Entity; if (acEnt != null) { acEnt.Unhighlight(); var acRotDim = acEnt as RotatedDimension; if (acRotDim != null) { var dimSys = DimSystem.GetSystem(acRotDim, eqPoint, eqPoint); var prPtOpts = new PromptPointOptions("\nSelect point to delete or press CTRL to start a crossing line: "); PromptPointResult ptRes; while (true) { if (dimSys.Count <= 0) { break; } dimSys.Highlight(); var nArray = DimSystem.GetActiveViewCount(); var ctManager = TransientManager.CurrentTransientManager; var acCirc = new Circle(); var acPreview = new Circle(); var acLine = new Line(new Point3d(0, 0, 0), new Point3d(0, 0, 0)); acCirc.Color = SettingsUser.DynPreviewColor; acPreview.Color = SettingsUser.DynPreviewColor; acLine.Color = SettingsUser.DynPreviewColor; var integerCollections = new IntegerCollection(nArray); ctManager.AddTransient(acCirc, TransientDrawingMode.Main, 128, integerCollections); ctManager.AddTransient(acPreview, TransientDrawingMode.Main, 128, integerCollections); ctManager.AddTransient(acLine, TransientDrawingMode.Highlight, 128, integerCollections); var dPoints = dimSys.GetSystemPoints(eqPoint); void PreviewHandler(object sender, PointMonitorEventArgs e) { var cdPoint = dimSys.GetNearest(e.Context.ComputedPoint, eqPoint); var cPt = dPoints[cdPoint]; var dlPoint = cPt.DimLinePoint; acCirc.Center = dlPoint; var scrSize = ScreenReader.GetSreenSize(); acCirc.Radius = scrSize / 200; acCirc.Normal = acRotDim.Normal; acPreview.Radius = scrSize / 200; acPreview.Normal = acRotDim.Normal; Point3d tempPt; Point3d tempPt1; Point3d tempPt2; if (cPt.IsLast) { tempPt = cPt.Dim1PointIndex != 1 ? cPt.Dim1.XLine2Point : cPt.Dim1.XLine1Point; tempPt2 = tempPt; } else { tempPt = cPt.Dim1PointIndex != 1 ? cPt.Dim1.XLine2Point : cPt.Dim1.XLine1Point; tempPt1 = cPt.Dim2PointIndex != 1 ? cPt.Dim2.XLine2Point : cPt.Dim2.XLine1Point; tempPt2 = dlPoint.DistanceTo(tempPt) <= dlPoint.DistanceTo(tempPt1) ? tempPt1 : tempPt; } acLine.StartPoint = dlPoint; acLine.EndPoint = tempPt2; acPreview.Center = tempPt2; ctManager.UpdateTransient(acCirc, integerCollections); ctManager.UpdateTransient(acPreview, integerCollections); ctManager.UpdateTransient(acLine, integerCollections); } acCurEd.PointMonitor += PreviewHandler; try { ptRes = acCurEd.GetPoint(prPtOpts); } finally { acCurEd.PointMonitor -= PreviewHandler; ctManager.EraseTransient(acCirc, integerCollections); ctManager.EraseTransient(acPreview, integerCollections); ctManager.EraseTransient(acLine, integerCollections); acCirc.Dispose(); acPreview.Dispose(); acLine.Dispose(); } #region CTRL Modifier var ctrlPressed = (Control.ModifierKeys & Keys.Control) > Keys.None; PromptPointResult promptPointResult = null; if (ctrlPressed) { var promptPointOption1 = new PromptPointOptions("\nSelect second point of crossing line:") { UseBasePoint = true, UseDashedLine = true, BasePoint = ptRes.Value }; promptPointResult = acCurEd.GetPoint(promptPointOption1); if (promptPointResult.Status != PromptStatus.OK) { dimSys.Unhighlight(); break; } } if (ptRes.Status != PromptStatus.OK) { dimSys.Unhighlight(); break; } #endregion if (ctrlPressed) { var delPt1 = ptRes.Value.TransformBy(delMatrix); var delPt2 = promptPointResult.Value.TransformBy(delMatrix); dimSys.Delete(delPt1, delPt2); } else { dimSys.Delete(ptRes.Value.TransformBy(delMatrix)); } } dimSys.Unhighlight(); } } acTrans.Commit(); } }
public void AddRange(IntegerCollection value) { }
public void TestMethod() { Document activeDoc = Application.DocumentManager.MdiActiveDocument; Database db = activeDoc.Database; Editor ed = activeDoc.Editor; PromptEntityOptions peo = new PromptEntityOptions("Select a polyline : "); peo.SetRejectMessage("Not a polyline"); peo.AddAllowedClass(typeof(Autodesk.AutoCAD.DatabaseServices.Polyline), true); PromptEntityResult per = ed.GetEntity(peo); if (per.Status != PromptStatus.OK) { return; } ObjectId plOid = per.ObjectId; PromptPointResult ppr = ed.GetPoint(new PromptPointOptions("Select an internal point : ")); if (ppr.Status != PromptStatus.OK) { return; } Point3d testPoint = ppr.Value; PromptAngleOptions pao = new PromptAngleOptions("Specify ray direction"); pao.BasePoint = testPoint; pao.UseBasePoint = true; PromptDoubleResult rayAngle = ed.GetAngle(pao); if (rayAngle.Status != PromptStatus.OK) { return; } Point3d tempPoint = testPoint.Add(Vector3d.XAxis); tempPoint = tempPoint.RotateBy(rayAngle.Value, Vector3d.ZAxis, testPoint); Vector3d rayDir = tempPoint - testPoint; ClearTransientGraphics(); _markers = new DBObjectCollection(); using (Transaction tr = db.TransactionManager.StartTransaction()) { Curve plcurve = tr.GetObject(plOid, OpenMode.ForRead) as Curve; for (int cnt = 0; cnt < 2; cnt++) { if (cnt == 1) { rayDir = rayDir.Negate(); } using (Ray ray = new Ray()) { ray.BasePoint = testPoint; ray.UnitDir = rayDir; Point3dCollection intersectionPts = new Point3dCollection(); plcurve.IntersectWith(ray, Intersect.OnBothOperands, intersectionPts, IntPtr.Zero, IntPtr.Zero); foreach (Point3d pt in intersectionPts) { Circle marker = new Circle(pt, Vector3d.ZAxis, 0.2); marker.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(0, 255, 0); _markers.Add(marker); IntegerCollection intCol = new IntegerCollection(); TransientManager tm = TransientManager.CurrentTransientManager; tm.AddTransient(marker, TransientDrawingMode.Highlight, 128, intCol); ed.WriteMessage("\n" + pt.ToString()); } } } tr.Commit(); } }
public void AddRange(IntegerCollection value) { throw null; }
private static void InsertSampleUsersAndRoles() { // Get list of all album IDs List<int> albumIds = new List<int>(); foreach (IGalleryServerRole role in RoleController.GetGalleryServerRoles()) { if (role.RoleName == "System Administrator") { albumIds.AddRange(role.AllAlbumIds); albumIds.Sort(); } } //// Create roles and assign each one to a random album Random rdm = new Random(); const int numRoles = 100; for (int i = 0; i < numRoles; i++) { int albumId; do { albumId = rdm.Next(albumIds[0], albumIds[albumIds.Count - 1]); } while (!albumIds.Contains(albumId)); IIntegerCollection roleAlbums = new IntegerCollection(); roleAlbums.Add(albumId); RoleController.CreateRole("Role " + i, true, false, true, false, true, false, true, false, true, false, false, false, roleAlbums); } // Create users and assign to random number of roles. const int numUsers = 100; for (int i = 0; i < numUsers; i++) { int numRolesToAssignToUser = rdm.Next(0, 5); // Add up to 5 roles to user List<String> roleNames = new List<string>(numRolesToAssignToUser); for (int j = 0; j < numRolesToAssignToUser; j++) { // Pick a random role string roleName = "Role " + rdm.Next(0, numRoles - 1); if (!roleNames.Contains(roleName)) roleNames.Add(roleName); } string userName = "******" + i; if (UserController.GetUser(userName, false) == null) { UserController.CreateUser(userName, "111", String.Empty, roleNames.ToArray(), false, 1); } } }
public override void MoveGripPointsAt(Entity entity, IntegerCollection indices, Vector3d offset) { base.MoveGripPointsAt(entity, indices, offset); if (Gripindex != null || GripIndexs[0] != null && GripIndexs[1] != null) { Polyline pLine = tr.openObject(DimInc_pLine, OpenMode.ForWrite) as Polyline; if (pLine != null) { Point3dCollection points = new Point3dCollection(); for (int i = 0; i < pLine.NumberOfVertices; i++) { if (i == Gripindex) { points.Add(CurrPoint); continue; } else if (i == GripIndexs[0] || i == GripIndexs[1]) { points.Add(acMath.getPointAtVector(pLine.GetPoint3dAt(i),offset)); continue; } else { points.Add(pLine.GetPoint3dAt(i)); } } tr.closeObject(); Group Texts = tr.openGroup(DimInc_texts, OpenMode.ForWrite); ObjectId[] ids = Texts.GetAllEntityIds(); tr.closeGroup(); int index = 0; foreach (ObjectId id in ids) { DBText txt = tr.openObject(id, OpenMode.ForWrite) as DBText; if (index != points.Count - 1) { txt.TextString = acMath.totalDistance(points, DIMset.DimUnit_Precision, index).ToString(); txt.Rotation = acMath.RetriveRot(points[index], points[index + 1]); txt.AlignmentPoint = acMath.pointOffset(points[index],points[index + 1],DIMset.Dimtxt_Offset)[1]; } else { txt.TextString = acMath.totalDistance(points, DIMset.DimUnit_Precision, index).ToString(); txt.Rotation = acMath.RetriveRot(points[index], points[0]); txt.AlignmentPoint = acMath.pointOffset(points[index], points[0], DIMset.Dimtxt_Offset)[1]; } tr.closeObject(); index++; } needRefresh = true; } } }
public void AddRange (IntegerCollection value) { AddItems (value); }
/// <include file='doc\ListBox.uex' path='docs/doc[@for="ListBox.IntegerCollection.AddRange1"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public void AddRange(IntegerCollection value) { AddRangeInternal((ICollection)value); }
public void AddRange(IntegerCollection value) {}
public void CreatingABlock() { // Get the current database and start a transaction Document zwDoc = Application.DocumentManager.MdiActiveDocument; Database zwCurDb = zwDoc.Database; Editor ed = zwDoc.Editor; //Database zwCurDb; //zwCurDb = Application.DocumentManager.MdiActiveDocument.Database; TypedValue[] zwTypValAr = new TypedValue[1]; zwTypValAr.SetValue(new TypedValue((int)DxfCode.Color, 256), 0); SelectionFilter zwSelFtr = new SelectionFilter(zwTypValAr); PromptDoubleOptions XValue = new PromptDoubleOptions(""); XValue.Message = "\nEnter X scale: "; XValue.AllowZero = false; XValue.AllowNone = false; XValue.AllowNegative = false; PromptDoubleResult XValRes = ed.GetDouble(XValue); PromptDoubleOptions YValue = new PromptDoubleOptions(""); YValue.Message = "\nEnter Y scale: "; YValue.AllowZero = false; YValue.AllowNone = false; YValue.AllowNegative = false; PromptDoubleResult YValRes = ed.GetDouble(YValue); PromptSelectionResult zwSSPrompt = zwDoc.Editor.GetSelection(zwSelFtr); using (Transaction zwTrans = zwCurDb.TransactionManager.StartTransaction()) { //open the Layer Tabel for read LayerTable zwLyrTbl; zwLyrTbl = zwTrans.GetObject(zwCurDb.LayerTableId, OpenMode.ForRead) as LayerTable; if (zwLyrTbl.Has("D0-XYLogo")) { string zwLayerName = "D0-XYLogo"; Application.ShowAlertDialog("Layer exist! Change layer success."); zwCurDb.Clayer = zwLyrTbl[zwLayerName]; } else { string zwLayerName = "D0-XYLogo"; LayerTableRecord zwLyrTblRec = new LayerTableRecord(); zwLyrTblRec.Color = Color.FromColorIndex(ColorMethod.ByAci, 3); zwLyrTblRec.Name = zwLayerName; zwLyrTblRec.IsLocked = true; zwLyrTbl.UpgradeOpen(); zwLyrTbl.Add(zwLyrTblRec); zwTrans.AddNewlyCreatedDBObject(zwLyrTblRec, true); zwCurDb.Clayer = zwLyrTbl[zwLayerName]; //Application.ShowAlertDialog("Layer does not exist!"); } // Open the Block table for read BlockTable zwBlkTbl; zwBlkTbl = zwTrans.GetObject(zwCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; ObjectId blkRecId = ObjectId.Null; if (!zwBlkTbl.Has("DWG-XYLogo")) { using (BlockTableRecord zwBlkTblRec = new BlockTableRecord()) { zwBlkTblRec.Name = "DWG-XYLogo"; // Set the insertion point for the block zwBlkTblRec.Origin = new Point3d(0, 0, 0); // Add a circle to the block // using (Circle acCirc = new Circle()) { //Create Line Line zwLine_1 = new Line(new Point3d(-1, -1, 0), new Point3d(8, -1, 0)); Line zwLine_2 = new Line(new Point3d(8, -1, 0), new Point3d(8, 1, 0)); Line zwLine_3 = new Line(new Point3d(8, 1, 0), new Point3d(1, 1, 0)); Line zwLine_4 = new Line(new Point3d(1, 1, 0), new Point3d(1, 8, 0)); Line zwLine_5 = new Line(new Point3d(1, 8, 0), new Point3d(-1, 8, 0)); Line zwLine_6 = new Line(new Point3d(-1, 8, 0), new Point3d(-1, -1, 0)); Line zwLine_7 = new Line(new Point3d(-1, -1, 0), new Point3d(1, 1, 0)); //Arrow_Horizontal Line zwLine_11 = new Line(new Point3d(8, 0, 0), new Point3d(13, 0, 0)); Line zwLine_12 = new Line(new Point3d(13, 0, 0), new Point3d(10, 0.8, 0)); Line zwLine_13 = new Line(new Point3d(13, 0, 0), new Point3d(10, -0.8, 0)); //Arrow_Vertical Line zwLine_21 = new Line(new Point3d(0, 8, 0), new Point3d(0, 13, 0)); Line zwLine_22 = new Line(new Point3d(0, 13, 0), new Point3d(-0.8, 10, 0)); Line zwLine_23 = new Line(new Point3d(0, 13, 0), new Point3d(0.8, 10, 0)); //Create Text DBText Text_X_Scale = new DBText(); Text_X_Scale.SetDatabaseDefaults(); Text_X_Scale.Position = new Point3d(1, -0.5, 0); Text_X_Scale.Height = 0.7; Text_X_Scale.TextString = string.Format("X = {0}", XValRes.Value.ToString()); DBText Text_Y_Scale = new DBText(); Text_Y_Scale.SetDatabaseDefaults(); Text_Y_Scale.Position = new Point3d(0.5, 1, 0); Text_Y_Scale.Height = 0.7; Text_Y_Scale.Rotation = 1.571; Text_Y_Scale.TextString = string.Format("Y = {0}", YValRes.Value.ToString()); zwLine_1.SetDatabaseDefaults(); zwLine_2.SetDatabaseDefaults(); zwLine_3.SetDatabaseDefaults(); zwLine_4.SetDatabaseDefaults(); zwLine_5.SetDatabaseDefaults(); zwLine_6.SetDatabaseDefaults(); zwLine_7.SetDatabaseDefaults(); zwLine_11.SetDatabaseDefaults(); zwLine_12.SetDatabaseDefaults(); zwLine_13.SetDatabaseDefaults(); zwLine_21.SetDatabaseDefaults(); zwLine_22.SetDatabaseDefaults(); zwLine_23.SetDatabaseDefaults(); //Add object to Block Table record and the transaction zwBlkTblRec.AppendEntity(Text_X_Scale); zwBlkTblRec.AppendEntity(Text_Y_Scale); zwBlkTblRec.AppendEntity(zwLine_1); zwBlkTblRec.AppendEntity(zwLine_2); zwBlkTblRec.AppendEntity(zwLine_3); zwBlkTblRec.AppendEntity(zwLine_4); zwBlkTblRec.AppendEntity(zwLine_5); zwBlkTblRec.AppendEntity(zwLine_6); zwBlkTblRec.AppendEntity(zwLine_7); zwBlkTblRec.AppendEntity(zwLine_11); zwBlkTblRec.AppendEntity(zwLine_12); zwBlkTblRec.AppendEntity(zwLine_13); zwBlkTblRec.AppendEntity(zwLine_21); zwBlkTblRec.AppendEntity(zwLine_22); zwBlkTblRec.AppendEntity(zwLine_23); zwBlkTbl.UpgradeOpen(); zwBlkTbl.Add(zwBlkTblRec); zwTrans.AddNewlyCreatedDBObject(zwBlkTblRec, true); string zwLayer0 = "0"; zwCurDb.Clayer = zwLyrTbl[zwLayer0]; ; zwCurDb.Clayer = zwLyrTbl["Defpoints"]; } blkRecId = zwBlkTblRec.Id; } } else { //blkRecId = zwBlkTbl["DWG-XYLogo"]; string zwLayer0 = "0"; zwCurDb.Clayer = zwLyrTbl[zwLayer0]; ed.WriteMessage("Block already exist. Program stop."); Application.ShowAlertDialog("Block already exist. Program stop."); //Environment.Exit(-1); //Application.Quit(); } if (blkRecId != ObjectId.Null) { using (BlockReference zwBlkRef = new BlockReference(new Point3d(0, 0, 0), blkRecId)) { BlockTableRecord zwCurSpaceBlkTblRec; zwCurSpaceBlkTblRec = zwTrans.GetObject(zwCurDb.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord; zwCurSpaceBlkTblRec.AppendEntity(zwBlkRef); zwTrans.AddNewlyCreatedDBObject(zwBlkRef, true); } } //PromptSelectionResult zwSSPrompt = zwDoc.Editor.GetSelection(zwSelFtr); if (zwSSPrompt.Status == PromptStatus.OK) { SelectionSet zwSSet = zwSSPrompt.Value; //Application.ShowAlertDialog(zwSSet.Count.ToString()); IntegerCollection[] test = new IntegerCollection[zwSSet.Count]; BlockTable zwBlkTbl2; zwBlkTbl2 = zwTrans.GetObject(zwCurDb.BlockTableId, OpenMode.ForWrite) as BlockTable; BlockTableRecord zwBlkTblRec2; zwBlkTblRec2 = zwTrans.GetObject(zwBlkTbl2[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; foreach (var item in zwSSet) { CrossingOrWindowSelectedObject currentObject = item as CrossingOrWindowSelectedObject; if (currentObject != null) { try { BlockReference blockRef = zwTrans.GetObject(currentObject.ObjectId, OpenMode.ForWrite) as BlockReference; if (blockRef != null) { Point3d oldPoint = new Point3d(new double[] { blockRef.Position.X, blockRef.Position.Y, blockRef.Position.Z }); Vector3d newVector = oldPoint.GetVectorTo(new Point3d(new double[] { blockRef.Position.X * 1.1, blockRef.Position.Y * 1.7, blockRef.Position.Z })); blockRef.TransformBy(Matrix3d.Displacement(newVector)); Point3d newPoint = new Point3d(new double[] { blockRef.Position.X * 1.1, blockRef.Position.Y * 1.7, blockRef.Position.Z }); zwTrans.AddNewlyCreatedDBObject(blockRef, true); } } catch (System.Exception ex) { System.Diagnostics.Trace.WriteLine(ex); } } else { Application.ShowAlertDialog("Empty"); } } } // Save the new object to the database zwTrans.Commit(); // Dispose of the transaction } }
//This function is called from point Monitor recator call back "ed_PointMonitor". //This function has a object id as a parameter. Depending of value of passed //object id, this function adds or modifies Transient Graphics static void AddOrModifyTGPoints(ObjectId id) { //Passed entity is same as entity to which point list is present in TGpoints if (m_currentId == id) { modifyTGPoints(); return; } eraseTGPoints(); Point3dCollection pointList = new Point3dCollection(); IntegerCollection colloection = new IntegerCollection(); Transaction trans = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction(); try { m_currentId = id; //memory given to point array is still present and user has moved the mouse over //a new entity, means we need to recreate the point array, so delete the current //point arry DisposePointArray(); // now open the entity below cursor for read Entity ent = (Entity)trans.GetObject(id, OpenMode.ForRead); // if ok //prepare the point list if (Line.GetClass(typeof(Line)) == ent.GetRXClass()) { Line line = (Line)ent; BreakLine(ref line, ref pointList); } else if (Arc.GetClass(typeof(Arc)) == ent.GetRXClass()) { Arc arc = (Arc)ent; BreakArc(ref arc, ref pointList); } else if (Polyline.GetClass(typeof(Polyline)) == ent.GetRXClass()) { Polyline pline = (Polyline)ent; BreakPolyLine(ref pline, ref pointList); } trans.Commit(); } finally { // close everything up trans.Dispose(); } //create DBPoint array... DBPoints are used as "Transient entity" if (pointList.Count != 0) { AddTransientGraphics(); } }
public void Cmd_DimMove() { var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var prEntOpt = new PromptEntityOptions("\nSelect a dimension system to move: "); prEntOpt.SetRejectMessage("\nOnly linear dimensions may be selected."); prEntOpt.AllowNone = false; prEntOpt.AddAllowedClass(typeof(RotatedDimension), false); var prEntRes = acCurEd.GetEntity(prEntOpt); if (prEntRes.Status != PromptStatus.OK) { return; } var objId = prEntRes.ObjectId; var addMatrix = acCurEd.GetAlignedMatrix(); var eqPoint = CalcTol.ReturnCurrentTolerance(); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var acEnt = acTrans.GetObject(objId, OpenMode.ForWrite) as Entity; if (acEnt != null) { acEnt.Unhighlight(); var acRotDim = acEnt as RotatedDimension; if (acRotDim != null) { var dimSys = DimSystem.GetSystem(acRotDim, eqPoint, eqPoint); var prPtOpts = new PromptPointOptions("\nSelect new position for dimensions: "); while (true) { dimSys.Highlight(); var nArray = DimSystem.GetActiveViewCount(); var ctManager = TransientManager.CurrentTransientManager; var intCol = new IntegerCollection(nArray); var rotatedDimensions = new List <RotatedDimension>(); foreach (var dim in dimSys.SysList) { var dimClone = (RotatedDimension)dim.Clone(); ctManager.AddTransient(dimClone, TransientDrawingMode.Highlight, 128, intCol); rotatedDimensions.Add(dimClone); } void Handler(object sender, PointMonitorEventArgs e) { foreach (var tDim in rotatedDimensions) { if (!tDim.UsingDefaultTextPosition) { var dimLinePoint = tDim.DimLinePoint; var textPosition = tDim.TextPosition; tDim.DimLinePoint = e.Context.ComputedPoint; ctManager.UpdateTransient(tDim, intCol); tDim.TextPosition = textPosition.Add(dimLinePoint.GetVectorTo(tDim.DimLinePoint)); } else { tDim.DimLinePoint = e.Context.ComputedPoint; } ctManager.UpdateTransient(tDim, intCol); } } acCurEd.PointMonitor += Handler; PromptPointResult prRes; try { prRes = acCurEd.GetPoint(prPtOpts); } finally { acCurEd.PointMonitor -= Handler; foreach (var acRotRim in rotatedDimensions) { ctManager.EraseTransient(acRotRim, intCol); acRotRim.Dispose(); } } if (prRes.Status != PromptStatus.OK) { break; } dimSys.MoveSystem(prRes.Value.TransformBy(addMatrix), eqPoint); acTrans.TransactionManager.QueueForGraphicsFlush(); } dimSys.Unhighlight(); } } acTrans.Commit(); } }
public void Cmd_DimExtend() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var prEntOpt = new PromptEntityOptions("\nSelect a dimension system to extend: "); prEntOpt.SetRejectMessage("\nOnly linear dimensions may be selected."); prEntOpt.AllowNone = false; prEntOpt.AddAllowedClass(typeof(RotatedDimension), false); var prEntRes = acCurEd.GetEntity(prEntOpt); if (prEntRes.Status != PromptStatus.OK) { return; } var objId = prEntRes.ObjectId; var matrix3d = acCurEd.GetAlignedMatrix(); var eqPoint = CalcTol.ReturnCurrentTolerance(); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var acEnt = acTrans.GetObject(objId, OpenMode.ForWrite) as Entity; if (acEnt != null) { acEnt.Unhighlight(); var acRotDim = acEnt as RotatedDimension; if (acRotDim != null) { var dimSys = DimSystem.GetSystem(acRotDim, eqPoint, eqPoint); dimSys.Highlight(); var promptPointOption2 = new PromptPointOptions( "\nSelect a dimension line to extend or press CTRL to start crossing line:"); while (true) { if (dimSys.Count == 0) { break; } dimSys.Highlight(); var nArray = DimSystem.GetActiveViewCount(); var ctManager = TransientManager.CurrentTransientManager; var acCirc = new Circle(); var acLine = new Line(new Point3d(0, 0, 0), new Point3d(0, 0, 0)); acCirc.Color = SettingsUser.DynPreviewColor; acCirc.Normal = acRotDim.Normal; acLine.Color = SettingsUser.DynPreviewColor; var intCol = new IntegerCollection(nArray); ctManager.AddTransient(acCirc, TransientDrawingMode.Highlight, 128, intCol); ctManager.AddTransient(acLine, TransientDrawingMode.Highlight, 128, intCol); var sysPts = dimSys.GetSystemPoints(eqPoint); void Handler(object sender, PointMonitorEventArgs e) { var cPt = dimSys.GetNearest(e.Context.ComputedPoint, eqPoint); var sysPt = sysPts[cPt]; var dlPt = sysPt.DimLinePoint; var scrSize = ScreenReader.GetSreenSize(); acCirc.Radius = scrSize / 200; var point3d = sysPt.Dim1PointIndex != 1 ? sysPt.Dim1.XLine2Point : sysPt.Dim1.XLine1Point; if (Math.Abs(point3d.DistanceTo(dlPt)) <= eqPoint) { acCirc.Center = dlPt; acLine.StartPoint = dlPt; acLine.EndPoint = dlPt; ctManager.UpdateTransient(acCirc, intCol); ctManager.UpdateTransient(acLine, intCol); return; } var point = new Line3d(dlPt, point3d).GetClosestPointTo(e.Context.ComputedPoint).Point; acLine.StartPoint = dlPt; acLine.EndPoint = point; acCirc.Center = point; ctManager.UpdateTransient(acCirc, intCol); ctManager.UpdateTransient(acLine, intCol); } acCurEd.PointMonitor += Handler; PromptPointResult ptRes; try { ptRes = acCurDoc.Editor.GetPoint(promptPointOption2); } finally { acCurEd.PointMonitor -= Handler; ctManager.EraseTransient(acCirc, intCol); ctManager.EraseTransient(acLine, intCol); acCirc.Dispose(); acLine.Dispose(); } var cntrlPressed = (Control.ModifierKeys & Keys.Control) > Keys.None; PromptPointResult ctrlRes = null; if (cntrlPressed) { var promptPointOption3 = new PromptPointOptions("\nSelect second point of crossing line:") { UseBasePoint = true, UseDashedLine = true, BasePoint = ptRes.Value }; ctrlRes = acCurDoc.Editor.GetPoint(promptPointOption3); if (ctrlRes.Status != PromptStatus.OK) { break; } } if (ptRes.Status != PromptStatus.OK) { break; } if (cntrlPressed) { var point3d6 = ptRes.Value.TransformBy(matrix3d); var point3d7 = ctrlRes.Value.TransformBy(matrix3d); var nums = dimSys.GetSystemByLine(point3d6, point3d7, eqPoint); if (nums.Count <= 0) { continue; } var sysPoints2 = dimSys.GetSystemPoints(eqPoint); foreach (var num3 in nums) { var point3d8 = DimSystem.GetCrossing(dimSys, sysPoints2, num3, point3d6, point3d7, eqPoint); if (point3d8.X != -99999 || point3d8.Y != -99999 || point3d8.Z != -99999) { dimSys.Extend(num3, 0, point3d8, eqPoint); } else { acCurEd.WriteMessage("\nCannot extend lines with zero length."); } } acTrans.TransactionManager.QueueForGraphicsFlush(); } else { var point3d9 = ptRes.Value.TransformBy(matrix3d); var num4 = dimSys.GetNearest(point3d9, eqPoint); var sysPoint = dimSys.GetSystemPoints(eqPoint)[num4]; var point3d10 = sysPoint.DimLinePoint; var point3d11 = sysPoint.Dim1PointIndex != 1 ? sysPoint.Dim1.XLine2Point : sysPoint.Dim1.XLine1Point; if (Math.Abs(point3d10.DistanceTo(point3d11)) >= eqPoint) { dimSys.Extend(num4, 0, point3d9, eqPoint); acTrans.TransactionManager.QueueForGraphicsFlush(); } else { acCurEd.WriteMessage("\nCannot extend lines with zero length."); } } } dimSys.Unhighlight(); acTrans.Commit(); } } } }
private void UpdateText() { Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; Autodesk.AutoCAD.DatabaseServices.Database db = doc.Database; Matrix3d ucs2wcs = AcadUtility.AcadGraphics.UcsToWcs; Matrix3d wcs2ucs = AcadUtility.AcadGraphics.WcsToUcs; Point3d pBaseWorld = mpBase.TransformBy(ucs2wcs); Point3d pTextWorld = mpText.TransformBy(ucs2wcs); MText mtext = Entity as MText; Vector3d dir = (mpText - mpBase); // Text attachment mtext.Location = pTextWorld; bool singleLine = (mtext.Attachment == AttachmentPoint.BottomLeft || mtext.Attachment == AttachmentPoint.BottomRight); // Text rotation and attachment if (mAutoRotateText) { double lineRotation = mTextRotation * Math.PI / 180 + Vector3d.XAxis.GetAngleTo(dir, Vector3d.ZAxis); double rot = lineRotation * 180 / Math.PI; if (rot > 90.0 && rot < 270.0) { lineRotation = lineRotation + Math.PI; mtext.Attachment = (singleLine ? AttachmentPoint.BottomRight : AttachmentPoint.MiddleRight); } else { mtext.Attachment = (singleLine ? AttachmentPoint.BottomLeft : AttachmentPoint.MiddleLeft); } mtext.Rotation = lineRotation; } else { mtext.Rotation = mTextRotation * Math.PI / 180; } // Text to the right or left double textlineAngle = Vector3d.XAxis.RotateBy(mtext.Rotation, Vector3d.XAxis).GetAngleTo(dir) * 180 / Math.PI; if (textlineAngle > 90.0 && textlineAngle < 270.0) { mtext.Attachment = (singleLine ? AttachmentPoint.BottomRight : AttachmentPoint.MiddleRight); } else { mtext.Attachment = (singleLine ? AttachmentPoint.BottomLeft : AttachmentPoint.MiddleLeft); } // Create and update line IntegerCollection vpNumbers = AcadUtility.AcadGraphics.GetActiveViewportNumbers(); if (line == null) { line = new Line(); TransientManager.CurrentTransientManager.AddTransient(line, TransientDrawingMode.DirectShortTerm, 0, vpNumbers); } line.StartPoint = pBaseWorld; line.EndPoint = pTextWorld; TransientManager.CurrentTransientManager.UpdateTransient(line, vpNumbers); }
public CustomTabOffsetsEnumerator(IntegerCollection items) { this.items = items; current = -1; }
public void Cmd_DimAdd() { if (!LicensingAgent.Check()) { return; } var acCurDoc = Application.DocumentManager.MdiActiveDocument; var acCurDb = acCurDoc.Database; var acCurEd = acCurDoc.Editor; var prEntOpt = new PromptEntityOptions("\nSelect a dimension system to add to: "); prEntOpt.SetRejectMessage("\nOnly linear dimensions may be selected."); prEntOpt.AllowNone = false; prEntOpt.AddAllowedClass(typeof(RotatedDimension), false); var prEntRes = acCurEd.GetEntity(prEntOpt); if (prEntRes.Status != PromptStatus.OK) { return; } var objId = prEntRes.ObjectId; var addMatrix = acCurEd.GetAlignedMatrix(); var eqPoint = CalcTol.ReturnCurrentTolerance(); using (var acTrans = acCurDb.TransactionManager.StartTransaction()) { var acEnt = acTrans.GetObject(objId, OpenMode.ForWrite) as Entity; if (acEnt != null) { acEnt.Unhighlight(); var acRotDim = acEnt as RotatedDimension; if (acRotDim != null) { var dimSys = DimSystem.GetSystem(acRotDim, eqPoint, eqPoint); var prPtOpts = new PromptPointOptions("\nSelect point to add: "); while (true) { dimSys.Highlight(); var dPoints = dimSys.GetSystemPoints(eqPoint); var dimLinPt = new Point3d(); var pt = new Point3d(); var bl = false; foreach (var dPt in dPoints) { if (bl) { pt = dPt.DimLinePoint; break; } dimLinPt = dPt.DimLinePoint; bl = true; } var nArray = DimSystem.GetActiveViewCount(); var currentTransientManager = TransientManager.CurrentTransientManager; var acLine = new Line(new Point3d(0, 0, 0), new Point3d(0, 0, 0)); var acPreview = new Line(new Point3d(0, 0, 0), new Point3d(0, 0, 0)); acLine.Color = SettingsUser.DynPreviewColor; acPreview.Color = SettingsUser.DynPreviewColor; var integerCollections = new IntegerCollection(nArray); currentTransientManager.AddTransient(acLine, TransientDrawingMode.Main, 128, integerCollections); currentTransientManager.AddTransient(acPreview, TransientDrawingMode.Main, 128, integerCollections); void PointMonitorEventHandler(object sender, PointMonitorEventArgs e) { var point3dArray = DimSystem.GetSystemPoint(dimLinPt, pt, e.Context.ComputedPoint); acLine.StartPoint = point3dArray[0]; acLine.EndPoint = point3dArray[1]; acPreview.StartPoint = point3dArray[1]; acPreview.EndPoint = e.Context.ComputedPoint; currentTransientManager.UpdateTransient(acLine, integerCollections); currentTransientManager.UpdateTransient(acPreview, integerCollections); } acCurEd.PointMonitor += PointMonitorEventHandler; PromptPointResult ptRes; try { ptRes = acCurEd.GetPoint(prPtOpts); } finally { acCurEd.PointMonitor -= PointMonitorEventHandler; currentTransientManager.EraseTransient(acLine, integerCollections); currentTransientManager.EraseTransient(acPreview, integerCollections); acLine.Dispose(); acPreview.Dispose(); } if (ptRes.Status != PromptStatus.OK) { break; } dimSys.Insert(ptRes.Value.TransformBy(addMatrix)); } dimSys.Unhighlight(); } } acTrans.Commit(); } }
/// <summary> /// Replace the list of root album IDs for the <paramref name="role"/> with the album ID's specified in /// <paramref name="topLevelCheckedAlbumIds"/>. Note that this function will cause the AllAlbumIds property /// to be cleared out (Count = 0). The property can be repopulated by calling <see cref="IGalleryServerRole.Save"/>. /// </summary> /// <param name="role">The role whose root album/role relationships should be updated. When editing /// an existing role, specify this.GalleryRole. For new roles, pass the newly created role before /// saving it.</param> /// <param name="topLevelCheckedAlbumIds">The top level album IDs. May be null.</param> /// <exception cref="ArgumentNullException">Thrown when <paramref name="role" /> is null.</exception> private static void UpdateRoleAlbumRelationships(IGalleryServerRole role, IIntegerCollection topLevelCheckedAlbumIds) { if (role == null) throw new ArgumentNullException("role"); if (topLevelCheckedAlbumIds == null) topLevelCheckedAlbumIds = new IntegerCollection(); int[] rootAlbumIdsOld = new int[role.RootAlbumIds.Count]; role.RootAlbumIds.CopyTo(rootAlbumIdsOld, 0); role.RootAlbumIds.Clear(); if (role.AllowAdministerSite) { // Administer site permission automatically applies to all albums, so all we need to do is get // a reference to the root album ID in each gallery. foreach (IGallery gallery in role.Galleries) { role.RootAlbumIds.Add(Factory.LoadRootAlbumInstance(gallery.GalleryId).Id); } } else if (role.AllowAdministerGallery) { // Administer gallery permission automatically applies to all albums in a gallery, so get a reference // to the root album for each checked album ID. foreach (int albumId in topLevelCheckedAlbumIds) { IAlbum album = AlbumController.LoadAlbumInstance(albumId, false); while (!(album.Parent is GalleryServerPro.Business.NullObjects.NullGalleryObject)) { album = (IAlbum)album.Parent; } if (!role.RootAlbumIds.Contains(album.Id)) { role.RootAlbumIds.Add(album.Id); } } } else { role.RootAlbumIds.AddRange(topLevelCheckedAlbumIds); } if (IsRoleAnAlbumOwnerRole(role.RoleName)) ValidateAlbumOwnerRoles(role.RoleName, rootAlbumIdsOld, role.RootAlbumIds); }
public void Play() { //Doc = Application.DocumentManager.MdiActiveDocument; //Db = Doc.Database; //DL = Doc.LockDocument(DocumentLockMode.ProtectedAutoWrite, null, null, true); //Editor Editor = Application.DocumentManager.MdiActiveDocument.Editor; PromptSelectionResult acPSR = AC.Editor.GetSelection(); // 선택한 객체를 받음 if (acPSR.Status == PromptStatus.OK) { var edgePtrs = new Curve2dCollection(); var edgeTypes = new IntegerCollection(); using (Transaction T = AC.DB.TransactionManager.StartTransaction()) { BlockTable BT = T.GetObject(AC.DB.BlockTableId, OpenMode.ForWrite) as BlockTable; BlockTableRecord BTR = T.GetObject(BT[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; SelectionSet acSSet = acPSR.Value; foreach (var objID in acSSet.GetObjectIds()) { var acEnt = T.GetObject(objID, OpenMode.ForWrite) as Entity; if (acEnt is Polyline) { Polyline acPL = acEnt as Polyline; GetEdgeInformation(acPL, ref edgePtrs, ref edgeTypes); } } } var acPolylines = from a in edgePtrs.Cast <Curve2d>() orderby a.StartPoint.GetDistanceTo(a.EndPoint) descending select a; //var usedCurve = new List<Curve2d>(); var usedCurve = new List <Point2d>(); acPolylines.Cast <Curve2d>().ToList().ForEach(c => { var CenterP = CADUtil.GetCenterPoint2d(c.StartPoint, c.EndPoint); var curves = from a in edgePtrs.Cast <Curve2d>().ToList() where a != c select a; // c와 평행한 선을 받음 var MatchedCurves = from a in curves let d = a.GetDistanceTo(c) where CADUtil.GetVector(a).GetNormal().IsEqualTo(-CADUtil.GetVector(c).GetNormal()) where d > Min && d < Max let cp1 = CADUtil.GetCenterPoint2d(c) let cp2 = CADUtil.GetCenterPoint2d(a) orderby cp1.GetDistanceTo(cp2) ascending select a; if (MatchedCurves.Any()) { //CAD.CreateLine(c.StartPoint, c.EndPoint); bool B = true; MatchedCurves.ToList().ForEach(c1 => { var cp1 = CADUtil.GetCenterPoint2d(c1); usedCurve.ForEach(cp2 => { if (cp1.IsEqualTo(cp2)) { B = false; } }); }); if (B) { CreateRectangle(c, MatchedCurves.ToList()); usedCurve.Add(CADUtil.GetCenterPoint2d(c)); } } }); } else { Application.ShowAlertDialog("Number of objects selected: 0"); } }
public void GetObjectSnapPoints(ObjectSnapModes snapMode, int gsSelectionMark, Point3d pickPoint, Point3d lastPoint, Matrix3d viewTransform, Point3dCollection snapPoints, IntegerCollection geometryIds, Matrix3d insertionMat) { createInstance(); BaseEntity.GetObjectSnapPoints(snapMode, gsSelectionMark, pickPoint, lastPoint, viewTransform, snapPoints, geometryIds, insertionMat); tr.Dispose(); }
private void GetEdgeInformation(Polyline pline, ref Curve2dCollection plCurves, ref IntegerCollection edgeTypes) { int segCount = pline.NumberOfVertices; for (int cnt = 0; cnt < segCount; cnt++) { SegmentType type = pline.GetSegmentType(cnt); switch (type) { case SegmentType.Arc: CircularArc2d arc2d = pline.GetArcSegment2dAt(cnt); plCurves.Add(arc2d); edgeTypes.Add((int)Enum.Parse(typeof(HatchEdgeType), HatchEdgeType.CircularArc.ToString())); break; case SegmentType.Line: LineSegment2d line2d = pline.GetLineSegment2dAt(cnt); plCurves.Add(line2d); edgeTypes.Add((int)Enum.Parse(typeof(HatchEdgeType), HatchEdgeType.Line.ToString())); break; case SegmentType.Coincident: break; case SegmentType.Empty: break; case SegmentType.Point: break; } } }
public ListBox () { items = CreateItemCollection (); selected_indices = new SelectedIndexCollection (this); selected_items = new SelectedObjectCollection (this); requested_height = bounds.Height; InternalBorderStyle = BorderStyle.Fixed3D; BackColor = ThemeEngine.Current.ColorWindow; /* Vertical scrollbar */ vscrollbar = new ImplicitVScrollBar (); vscrollbar.Minimum = 0; vscrollbar.SmallChange = 1; vscrollbar.LargeChange = 1; vscrollbar.Maximum = 0; vscrollbar.ValueChanged += new EventHandler (VerticalScrollEvent); vscrollbar.Visible = false; /* Horizontal scrollbar */ hscrollbar = new ImplicitHScrollBar (); hscrollbar.Minimum = 0; hscrollbar.SmallChange = 1; hscrollbar.LargeChange = 1; hscrollbar.Maximum = 0; hscrollbar.Visible = false; hscrollbar.ValueChanged += new EventHandler (HorizontalScrollEvent); Controls.AddImplicit (vscrollbar); Controls.AddImplicit (hscrollbar); /* Events */ MouseDown += new MouseEventHandler (OnMouseDownLB); MouseMove += new MouseEventHandler (OnMouseMoveLB); MouseUp += new MouseEventHandler (OnMouseUpLB); MouseWheel += new MouseEventHandler (OnMouseWheelLB); KeyUp += new KeyEventHandler (OnKeyUpLB); GotFocus += new EventHandler (OnGotFocus); LostFocus += new EventHandler (OnLostFocus); SetStyle (ControlStyles.UserPaint, false); #if NET_2_0 custom_tab_offsets = new IntegerCollection (this); #endif }
public void GetGripPoints(Point3dCollection gripPoints, IntegerCollection snapModes, IntegerCollection geometryIds) { createInstance(); BaseEntity.GetGripPoints(gripPoints, snapModes, geometryIds); tr.Dispose(); }
/// <summary> /// Get a list of album IDs between the current instance and the specified <paramref name="topAlbumId" />. It works by /// analyzing the parent albums, recursively, of the current gallery object, until reaching either the root album or the specified /// <paramref name="topAlbumId" />. The caller is responsible for iterating through this list and calling /// <see cref="Album.AssignAlbumThumbnail" /> for each album after the move operation is complete. /// This method should be called before the move operation takes place. /// </summary> /// <param name="topAlbumId">The ID of the album the current gallery object will be in after the move operation completes.</param> /// <returns>Return a list of album IDs whose thumbnail images will need updating after the move operation completes.</returns> protected IIntegerCollection GetAlbumHierarchy(int topAlbumId) { IIntegerCollection albumsInHierarchy = new IntegerCollection(); IGalleryObject album = this.Parent; while (!(album is NullObjects.NullGalleryObject)) { // If we're at the same level as the destination album, don't go any further. if (album.Id == topAlbumId) break; albumsInHierarchy.Add(album.Id); album = album.Parent; } return albumsInHierarchy; }
/// <devdoc> /// Creates a new enumerator that will enumerate over the given state. /// </devdoc> public CustomTabOffsetsEnumerator(IntegerCollection items) { this.items = items; this.current = -1; }
public void MoveStretchPointsAt(IntegerCollection indices, Vector3d offset) { createInstance(); BaseEntity.MoveStretchPointsAt(indices, offset); tr.Dispose(); }
private ObjectId ProcessEntity(Polyline curve, BlockTable bt) { Database db = bt.Database; ObjectId createdBtrId = ObjectId.Null; using (Transaction tr = db.TransactionManager.StartTransaction()) { //Масштаб типа линии double ltScale = curve.LinetypeScale; //Глобальная ширина линии double offsetDist = 0; offsetDist = (curve as Polyline).GetStartWidthAt(0) / 2; if (offsetDist == 0) { throw new System.Exception("Не определена глобальная ширина кривой"); } //Анализ типа линии. Получить длину штриха и длину пробела LinetypeTableRecord ltype = tr.GetObject(curve.LinetypeId, OpenMode.ForRead) as LinetypeTableRecord; //Создать слой, который будет называться как тип линии string layerName = curve.Linetype; LayerTableRecord layerSample = tr.GetObject(curve.LayerId, OpenMode.ForRead) as LayerTableRecord; ObjectId layerId = Utils.CreateLayerIfNotExists(layerName, db, tr, layerSample); //string ltypeDef = ltype.Comments; //double patternLength = ltype.PatternLength; //int numDashes = ltype.NumDashes; if (ltype.Name.Equals("ByLayer")) { ltype = tr.GetObject(layerSample.LinetypeObjectId, OpenMode.ForRead) as LinetypeTableRecord; } List <double> pattern = Utils.GetLinePattern(ltype, ltScale); bool startFromDash = false;//паттерн начинается со штриха (не пробела) if (pattern.Count > 0) { startFromDash = pattern[0] > 0; } DoubleCollection splittingParams = new DoubleCollection(); if (pattern.Count > 1) { //Расчитать параметры для разбивки полилинии double currParam = curve.StartParam; double currDist = curve.GetDistanceAtParameter(currParam); double length = curve.GetDistanceAtParameter(curve.EndParam); int dashNum = 0; while (true) { currDist += Math.Abs(pattern[dashNum]); if (currDist < length) { currParam = curve.GetParameterAtDistance(currDist); //Параметр в конце текущего штриха int nextDashNum = (dashNum + 1) % pattern.Count; //следующий штрих согласно паттерну if (Math.Sign(pattern[dashNum]) != Math.Sign(pattern[nextDashNum])) { //Если знаки текущего штриха и следующего разные //(то есть граница между штрихом и пробелом), //то добавить текущий параметр в разделители splittingParams.Add(currParam); } dashNum = nextDashNum;//переход к следующему штриху } else { break; } } } List <Curve> curves = new List <Curve>(); if (splittingParams.Count != 0) { //Использовать метод Curve.GetSplitCurves для создания сегментов DBObjectCollection splitted = curve.GetSplitCurves(splittingParams); foreach (DBObject dbo in splitted) { if (dbo is Curve) { curves.Add(dbo as Curve); } } } else//Сплошная линия { object o = curve.Clone(); if (o != null && o is Curve) { curves.Add(o as Curve); } } if (curves.Count > 0) { //Создать новый блок для сохранения замкнутых контуров BlockTableRecord btr = new BlockTableRecord(); btr.Name = Guid.NewGuid().ToString(); n++; createdBtrId = bt.Add(btr); tr.AddNewlyCreatedDBObject(btr, true); if (createdBtrId != ObjectId.Null) { bool currIsDash = startFromDash; foreach (Curve axisCurve in curves) { if (currIsDash) { //Использовать метод Curve.GetOffsetCurves //для создания линий границ справа и слева в соответствии с глобальной шириной //Создание замкнутого контура в новом блоке DBObjectCollection offsetCurves = axisCurve.GetOffsetCurves(offsetDist); Curve c1 = Utils.GetFirstDBObject(offsetCurves) as Curve; offsetCurves = axisCurve.GetOffsetCurves(-offsetDist); Curve c2 = Utils.GetFirstDBObject(offsetCurves) as Curve; if (!curve.Closed)//Если кривая не замкнута, то попытаться построить замкнутый контур из правой и левой кривой отступа { try { Line concatLine = new Line(c1.EndPoint, c2.EndPoint /*.StartPoint*/); IntegerCollection joined = c1.JoinEntities(new Entity[] { concatLine, c2 }); if (joined.Count < 2) { throw new System.Exception("Соединение примитивов не выполнено"); } if (c1 is Polyline) { PrepareCurve(c1, layerId); } else { throw new System.Exception("При соединении примитивов создан невалидный объект"); } btr.AppendEntity(c1); tr.AddNewlyCreatedDBObject(c1, true); } catch (System.Exception ex) { ed.WriteMessage("\nВНИМАНИЕ: Возникла ошибка при попытке создания контура в блоке " + btr.Name); } } else//Если кривая замкнута, то просто создать левую и правую кривую { PrepareCurve(c1, layerId); PrepareCurve(c2, layerId); btr.AppendEntity(c1); tr.AddNewlyCreatedDBObject(c1, true); btr.AppendEntity(c2); tr.AddNewlyCreatedDBObject(c2, true); } } currIsDash = !currIsDash;//Считаем, что штрихи и пробелы встречаются строго поочереди } } } tr.Commit(); } return(createdBtrId); }
void updateInvisibleGrips() { ExGripDataCollection aOverall = new ExGripDataCollection(); foreach (KeyValuePair <ObjectId, ExGripDataExt> grDataDc in m_gripDataDict) { foreach (ExGripData grData in grDataDc.Value.DataArray) { aOverall.Add(grData); } foreach (ExGripDataSubent grDataSub in grDataDc.Value.DataSub) { foreach (ExGripData grData in grDataSub.SubData) { aOverall.Add(grData); } } } int iSize = aOverall.Count; for (int i = 0; i < iSize; i++) { ExGripData grData = aOverall[i]; grData.Invisible = false; grData.Shared = false; IntegerCollection aEq = new IntegerCollection(); aEq.Add(i); Point3d ptIni = grData.Point; int iNext = i + 1; Tolerance tc = new Tolerance(1E-6, 1E-6); while (iNext < iSize) { Point3d ptCur = aOverall[iNext].Point; if (ptIni.IsEqualTo(ptCur, tc)) { aEq.Add(iNext); iNext++; } else { break; } } if (aEq.Count >= 2) { int iVisible = 0; int jSize = aEq.Count; for (int j = 0; j < iSize; j++) { ExGripData pGrip = aOverall[aEq[j]]; bool bOk = true; if (pGrip.Data != null) { if (pGrip.Data.SkipWhenShared) { bOk = false; } } if (bOk) { iVisible = j; break; } } for (int j = 0; j < iSize; j++) { ExGripData pGrip = aOverall[aEq[j]]; pGrip.Shared = true; pGrip.Invisible = (j != iVisible); } } } }
/// <summary> /// Replace the list of root album IDs for the <paramref name="role"/> with the album ID's specified in /// <paramref name="topLevelCheckedAlbumIds"/>. Note that this function will cause the AllAlbumIds property /// to be cleared out (Count = 0). The property can be repopulated by calling <see cref="IGalleryServerRole.Save"/>. /// </summary> /// <param name="role">The role whose root album/role relationships should be updated. When editing /// an existing role, specify this.GalleryRole. For new roles, pass the newly created role before /// saving it.</param> /// <param name="topLevelCheckedAlbumIds">The top level checked album ids. May be null.</param> public static void UpdateRoleAlbumRelationships(IGalleryServerRole role, IIntegerCollection topLevelCheckedAlbumIds) { if (role == null) throw new ArgumentNullException("role"); if (topLevelCheckedAlbumIds == null) topLevelCheckedAlbumIds = new IntegerCollection(); int[] rootAlbumIdsOld = new int[role.RootAlbumIds.Count]; role.RootAlbumIds.CopyTo(rootAlbumIdsOld, 0); role.RootAlbumIds.Clear(); if (role.AllowAdministerSite) { // Administer site permission automatically applies to all albums, so all we need to do is get // a reference to the root album ID. role.RootAlbumIds.Add(Factory.LoadRootAlbumInstance().Id); } else { role.RootAlbumIds.AddRange(topLevelCheckedAlbumIds); } if (IsRoleAnAlbumOwnerRole(role.RoleName)) ValidateAlbumOwnerRoles(role.RoleName, rootAlbumIdsOld, role.RootAlbumIds); }
private ObjectId TrimPickUP(int nodeNumer, int TriangleNumer, double X, double angle) { //UtilityClasses.ConstantsAndSettings.DoubleGlass_h1 //UtilityClasses.ConstantsAndSettings.DoubleGlass_h2 //UtilityClasses.ConstantsAndSettings.Thickness_of_the_Glass #region basedata Database db = HostApplicationServices.WorkingDatabase; Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("\n"); ed.WriteMessage(angle.ToString()); var node = container.Nodes[nodeNumer]; Triangle TR = container.Triangles[TriangleNumer]; quaternion trNormal = TR.Normal.Second - TR.Normal.First; trNormal /= trNormal.abs(); plane trPlane = new plane(TR.Nodes.First, TR.Nodes.Second, TR.Nodes.Third); Point3dCollection pColl = new Point3dCollection(); IntegerCollection iCol1 = new IntegerCollection(); IntegerCollection iCol2 = new IntegerCollection(); using (Transaction tr = db.TransactionManager.StartTransaction()) { if ((TR.upSolidHandle.First >= 0) && (TR.upSolidHandle.Second != null)) { try { Solid3d upSolid = tr.GetObject(GlobalFunctions.GetObjectId(TR.upSolidHandle.Second), OpenMode.ForWrite) as Solid3d; upSolid.GetGripPoints(pColl, iCol1, iCol2); } catch { } } } Bend bend1 = container.Bends[TR.GetFirstBendNumer()]; Bend bend2 = container.Bends[TR.GetSecondBendNumer()]; Bend bend3 = container.Bends[TR.GetThirdBendNumer()]; #endregion List <Bend> bends = new List <Bend>(); if ((bend1.StartNodeNumer == nodeNumer) || (bend1.EndNodeNumer == nodeNumer)) { bends.Add(bend1); } if ((bend2.StartNodeNumer == nodeNumer) || (bend2.EndNodeNumer == nodeNumer)) { bends.Add(bend2); } if ((bend3.StartNodeNumer == nodeNumer) || (bend3.EndNodeNumer == nodeNumer)) { bends.Add(bend3); } if (bends.Count != 2) { MessageBox.Show("Only two Bends are connected at one point !", "E R R O R"); return(ObjectId.Null); } if (bends[0].IsFictive() || bends[1].IsFictive()) { return(ObjectId.Null); } quaternion Q0 = node.Position; quaternion Q1 = (bends[0].Start + bends[0].End) / 2.0; quaternion Q2 = (bends[1].Start + bends[1].End) / 2.0; // coorinat systems for plane points calculate Q1 = Q1 - Q0; Q1 /= Q1.abs(); Q1 *= X; Q1 = Q0 + Q1; Q2 = Q2 - Q0; Q2 /= Q2.abs(); Q2 *= X; Q2 = Q0 + Q2; UCS ucs = new UCS(Q0, (Q1 + Q2) / 2.0, Q2); ucs = new UCS(Q0, ucs.ToACS(new quaternion(0, 0, 100, 0)), ucs.ToACS(new quaternion(0, 100, 0, 0))); #region UP glass double dist = (node.Position - (quaternion)pColl[0]).abs(); quaternion pick = new quaternion(); foreach (Point3d p in pColl) { quaternion q = (quaternion)p; double z = (node.Position - q).abs(); if (z < dist) { dist = z; pick = new quaternion(0, p.X, p.Y, p.Z); } } pColl.Clear(); pColl.Dispose(); iCol1.Clear(); iCol1.Clear(); #endregion ucs.o = pick; Q1 = pick + Q1 - Q0; Q2 = pick + Q2 - Q0; Q0 = pick; // UtilityClasses.GlobalFunctions.DrawLine((Point3d)Q0, new Point3d(), 1); quaternion t1 = (Q2 - Q1) * 2.0; quaternion t2 = (Q1 - Q2) * 2.0; Q1 = Q1 + t2; Q2 = Q2 + t1; Matrix3d mat = new Matrix3d(ucs.GetAutoCAD_Matrix3d()); Q1 = ucs.FromACS(Q1); Q2 = ucs.FromACS(Q2); quaternion Q3 = new quaternion(0, Q1.GetX(), -Q1.GetY(), Q1.GetZ()); quaternion Q4 = new quaternion(0, Q2.GetX(), -Q2.GetY(), Q2.GetZ()); quaternion[] arr = { Q1, Q2, Q4, Q3, Q1 }; ObjectId obj = ObjectId.Null; using (Transaction tr = db.TransactionManager.StartTransaction()) { BlockTable acBlkTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable; BlockTableRecord acBlkTblRec = tr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; Polyline pol = GlobalFunctions.GetPoly(ref arr); //pol.TransformBy(Matrix3d.Displacement(new Point3d().GetVectorTo(new Point3d(0, 0, -100)))); //pol.TransformBy(mat); //acBlkTblRec.AppendEntity(pol); //tr.AddNewlyCreatedDBObject(pol, true); try { Solid3d sol = new Solid3d(); sol.CreateExtrudedSolid(pol, new Point3d(0, 0, 0).GetVectorTo(new Point3d(0, 0, 100)), new SweepOptions()); sol.TransformBy(Matrix3d.Displacement(new Point3d().GetVectorTo(new Point3d(0, 0, -50)))); sol.TransformBy(mat); acBlkTblRec.AppendEntity(sol); tr.AddNewlyCreatedDBObject(sol, true); obj = sol.ObjectId; } catch { } tr.Commit(); } /* * if (obj != ObjectId.Null) * { * using (Transaction tr = db.TransactionManager.StartTransaction()) * { * * Solid3d sol = tr.GetObject(obj, OpenMode.ForWrite) as Solid3d; * Solid3d ent = tr.GetObject(UtilityClasses.GlobalFunctions.GetObjectId(TR.lowSolidHandle.Second), OpenMode.ForWrite) as Solid3d; * ent.BooleanOperation(BooleanOperationType.BoolSubtract, sol); * * tr.Commit(); * } * }*/ // ed.WriteMessage("\n"); // ed.WriteMessage(ucs.FromACS(Q0).ToString()); // ed.WriteMessage("\n-----------------------------\n"); return(obj); }