工具如下:
工具CogIDTool1设置如下:
脚本关键代码如下:
在自带的构造函数中添加代码
public override bool GroupRun(ref string message, ref CogToolResultConstants result)
CogGraphicCollection gs = new CogGraphicCollection();
if(gs == null)
gs.Clear();
CogIDTool IDCode = mToolBlock.Tools["CogIDTool1"] as CogIDTool;
CogGraphicLabel IDLabel = new CogGraphicLabel();
IDCode.Run();
if(IDCode.Results.Count > 0)
{
IDLabel.Font = new Font("Arial", 30, FontStyle.Bold, GraphicsUnit.Point);
IDLabel.Alignment = CogGraphicLabelAlignmentConstants.BottomLeft;
IDLabel.Color = CogColorConstants.Green;
IDLabel.SelectedSpaceName = "#";
IDLabel.SetXYText(0, 400, "二维码:" + IDCode.Results[0].DecodedData.DecodedString);
mToolBlock.Outputs["Out_X1"].Value = 1;
}
else
{
IDLabel.Font = new Font("Arial", 30, FontStyle.Bold, GraphicsUnit.Point);
IDLabel.Alignment = CogGraphicLabelAlignmentConstants.BottomLeft;
IDLabel.Color = CogColorConstants.Red;
IDLabel.SelectedSpaceName = "#";
IDLabel.SetXYText(0, 400, "二维码:NG");
mToolBlock.Outputs["Out_X1"].Value = 0;
mToolBlock.Outputs["Out_Out_jieguofujiazifuchuan"].Value = null;
}