public CompleteDxfDrawingStruct(CompleteDxfDrawingStruct structToCopy) { // https://stackoverflow.com/questions/14520698/i-can-access-private-members-in-a-copy-ctor-in-c-sharp if (structToCopy != null) { XLowerLeft = structToCopy.XLowerLeft; YLowerLeft = structToCopy.YLowerLeft; XUpperRight = structToCopy.XUpperRight; YUpperRight = structToCopy.YUpperRight; foreach (var item in structToCopy.allEntriesUsingInDisplay) { allEntriesUsingInDisplay.Add(item); } } }
public CompleteDxfDrawingStruct(CompleteDxfDrawingStruct structToCopy, double in_initialRotationAngleRad) { if (structToCopy != null) { XLowerLeft = structToCopy.XLowerLeft; YLowerLeft = structToCopy.YLowerLeft; XUpperRight = structToCopy.XUpperRight; YUpperRight = structToCopy.YUpperRight; //obtain center of rotation double horizontalMidPoint = (structToCopy.XLowerLeft + structToCopy.XUpperRight) / 2.0; double verticalMidPoint = (structToCopy.YLowerLeft + structToCopy.YUpperRight) / 2.0; //obtain rotation matrix double[,] currentRotationMatrix = MathHelperForTransformations.getRotationMatrixAroundPoint(horizontalMidPoint, verticalMidPoint, in_initialRotationAngleRad); //iterate over all entries in dxf structure altering them int allCount = structToCopy.allEntriesUsingInDisplay.Count; for (int iiii = 0; iiii < allCount; iiii++) { DXFentryForDisplay item = structToCopy.allEntriesUsingInDisplay[iiii]; //get bound box and rotate it if (item is MyDxfLineForDisplay) { Tuple <double, double> coord1 = MathHelperForTransformations.rotateImageUsingPrecalculatedTransformationMatrix(currentRotationMatrix, (item as MyDxfLineForDisplay).XStart, (item as MyDxfLineForDisplay).YStart); double item2XStart = coord1.Item1; double item2YStart = coord1.Item2; Tuple <double, double> coord2 = MathHelperForTransformations.rotateImageUsingPrecalculatedTransformationMatrix(currentRotationMatrix, (item as MyDxfLineForDisplay).XEnd, (item as MyDxfLineForDisplay).YEnd); double item2XEnd = coord2.Item1; double item2YEnd = coord2.Item2; MyDxfLineForDisplay item2 = new MyDxfLineForDisplay(item2XStart, item2YStart, item2XEnd, item2YEnd, (item as MyDxfLineForDisplay).penStructure); } else if (item is MyDxfArcForDisplay) { Tuple <double, double> coordUpper = MathHelperForTransformations.rotateImageUsingPrecalculatedTransformationMatrix(currentRotationMatrix, (item as MyDxfArcForDisplay).XUpper, (item as MyDxfArcForDisplay).YUpper); double startAngleDegree = (item as MyDxfArcForDisplay).startAngle + MathHelperForTransformations.ConvertRadiansToDegrees(in_initialRotationAngleRad); MyDxfArcForDisplay item2 = new MyDxfArcForDisplay((item as MyDxfArcForDisplay).penStructure, coordUpper.Item1, coordUpper.Item2, (item as MyDxfArcForDisplay).Width, (item as MyDxfArcForDisplay).Height, startAngleDegree, (item as MyDxfArcForDisplay).sweepAngle); } } } }