本文整理汇总了C#中IGraphic.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IGraphic.GetType方法的具体用法?C# IGraphic.GetType怎么用?C# IGraphic.GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IGraphic
的用法示例。
在下文中一共展示了IGraphic.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoGraphicToIMarkup
private static IMarkup DoGraphicToIMarkup(IGraphic graphic)
{
if (graphic == null || graphic.ParentPresentationImage == null)
return null;
IMarkup markup = null;
var roiGraphic = graphic as RoiGraphic;
if (roiGraphic != null)
{
if (roiGraphic.Roi is EllipticalRoi)
{
var ellipse = roiGraphic.Roi as EllipticalRoi;
markup = new MarkupEllipse
{
TopLeft = new PointF(ellipse.BoundingBox.Left, ellipse.BoundingBox.Top),
BottomRight = new PointF(ellipse.BoundingBox.Right, ellipse.BoundingBox.Bottom),
Name = graphic.Name,
GraphicHashcode = graphic.GetHashCode(),
CalloutLocation = roiGraphic.Callout.TextLocation
};
}
else if (roiGraphic.Roi is PolygonalRoi)
{
var polygon = roiGraphic.Roi as PolygonalRoi;
markup = new MarkupPolygonal
{
Name = graphic.Name,
Vertices = polygon.Polygon.Vertices == null ? null : new List<PointF>(polygon.Polygon.Vertices),
GraphicHashcode = graphic.GetHashCode(),
CalloutLocation = roiGraphic.Callout.TextLocation
};
}
else if (roiGraphic.Roi is RectangularRoi)
{
var rectangularRoi = roiGraphic.Roi as RectangularRoi;
markup = new MarkupRectangle
{
TopLeft = new PointF(rectangularRoi.BoundingBox.Left, rectangularRoi.BoundingBox.Top),
BottomRight = new PointF(rectangularRoi.BoundingBox.Right, rectangularRoi.BoundingBox.Bottom),
Name = graphic.Name,
GraphicHashcode = graphic.GetHashCode(),
CalloutLocation = roiGraphic.Callout.TextLocation
};
}
else if (roiGraphic.Roi is ProtractorRoi)
{
var protractorRoi = roiGraphic.Roi as ProtractorRoi;
markup = new MarkupProtractor
{
TopLeft = new PointF(protractorRoi.BoundingBox.Left, protractorRoi.BoundingBox.Top),
BottomRight = new PointF(protractorRoi.BoundingBox.Right, protractorRoi.BoundingBox.Bottom),
Name = graphic.Name,
Points = protractorRoi.Points == null ? null : new List<PointF>(protractorRoi.Points),
GraphicHashcode = graphic.GetHashCode(),
CalloutLocation = roiGraphic.Callout.TextLocation
};
}
else if (roiGraphic.Roi is LinearRoi)
{
var linearRoi = roiGraphic.Roi as LinearRoi;
markup = new MarkupLinear
{
Vertices = linearRoi.Points == null ? null : new List<PointF>(linearRoi.Points),
Name = graphic.Name,
GraphicHashcode = graphic.GetHashCode(),
CalloutLocation = roiGraphic.Callout.TextLocation
};
}
if (markup != null)
markup.CaptionText = roiGraphic.Roi.GetType().Name + Environment.NewLine + roiGraphic.Callout.Text;
}
else if (graphic is UserCalloutGraphic)
{
var userCalloutGraphic = graphic as UserCalloutGraphic;
markup = new MarkupPoint
{
Name = graphic.Name,
CaptionText = userCalloutGraphic.Text,
CalloutText = userCalloutGraphic.Text,
CalloutLocation = userCalloutGraphic.TextLocation,
Point = userCalloutGraphic.AnchorPoint,
GraphicHashcode = graphic.GetHashCode()
};
}
else if (graphic is CrosshairCalloutGraphic)
{
var userCalloutGraphic = graphic as CrosshairCalloutGraphic;
markup = new MarkupPoint
{
Name = graphic.Name,
CaptionText = userCalloutGraphic.Text,
//.........这里部分代码省略.........
示例2: SerializeGraphic
/// <summary>
/// Helper method to serialize a graphic to the supplied serialization state object.
/// </summary>
/// <param name="graphic">The graphic to serialize.</param>
/// <param name="serializationState">The state to which the graphic should be serialized.</param>
/// <returns>True if the graphic was serializable; False otherwise.</returns>
public static bool SerializeGraphic(IGraphic graphic, GraphicAnnotationSequenceItem serializationState)
{
Platform.CheckForNullReference(graphic, "graphic");
Platform.CheckForNullReference(serializationState, "serializationState");
object[] attributes = graphic.GetType().GetCustomAttributes(typeof (DicomSerializableGraphicAnnotationAttribute), true);
if (attributes.Length > 0)
{
((DicomSerializableGraphicAnnotationAttribute) attributes[0]).Serializer.Serialize(graphic, serializationState);
return true;
}
return false;
}