本页内容
测量周长与面积
周长与面积测量工具可用于测量用户选择的多边形区域的周长与面积。
配置测量属性后,可通过以下步骤设置 CPDFViewerTool
创建周长和面积测量工具模式:
- 将鼠标模式设置为注释创建模式。
- 创建一个
PolygonMeasureParam
对象,用于设置周长和面积测量工具的属性。
以下是创建距离测量工具的示例代码:
C#
// 将工具类型设置为注释创建模式。
toolManager.SetToolType(ToolType.CreateAnnot);
toolManager.SetCreateAnnotType(C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON);
// 创建一个 PolygonMeasureParam 对象,用于设置周长和面积测量工具的属性。
PolygonMeasureParam polygonMeasureParam = new PolygonMeasureParam();
polygonMeasureParam.CurrentType = C_ANNOTATION_TYPE.C_ANNOTATION_POLYGON;
polygonMeasureParam.LineColor = new byte[] { 255, 0, 0, };
polygonMeasureParam.LineWidth = 2;
polygonMeasureParam.Transparency = 255;
polygonMeasureParam.FontColor = new byte[] { 255, 0, 0, };
polygonMeasureParam.FontName = "Arial";
polygonMeasureParam.FontSize = 14;
polygonMeasureParam.measureInfo = new CPDFMeasureInfo
{
Unit = CPDFMeasure.CPDF_CM,
Precision = CPDFMeasure.PRECISION_VALUE_TWO,
RulerBase = 1,
RulerBaseUnit = CPDFMeasure.CPDF_CM,
RulerTranslate = 1,
RulerTranslateUnit = CPDFMeasure.CPDF_CM,
CaptionType = CPDFCaptionType.CPDF_CAPTION_LENGTH | CPDFCaptionType.CPDF_CAPTION_AREA,
};
tool.GetDefaultSettingParam().SetAnnotParam(polygonMeasureParam);