private void deleteCurrentRegionBtn_Click(object sender, EventArgs e) { if (currentFindRegionComb.SelectedItem == null) { MessageHelper.ShowWarning("请选择一个模板搜索框进行删除"); return; } GrayMatchToolInfo info = Infos.Find(p => p.ToolName == currentFindRegionComb.SelectedItem.ToString()); if (info == null) { return; } else { info.FindModelROIParam = null; } }
private void modifyFindRegionBtn_Click(object sender, EventArgs e) { if (currentImage == null) { MessageHelper.ShowWarning("请获取图像后再修改搜索框"); return; } if (currentFindRegionComb.SelectedItem == null) { MessageHelper.ShowWarning("请选择一个模板进行修改搜索框"); return; } GrayMatchToolInfo info = Infos.Find(p => p.ToolName == currentFindRegionComb.SelectedItem.ToString()); if (info == null) { MessageHelper.ShowWarning("无法修改模板搜索框,请删除该模板后重新创建!"); return; } if (info.FindModelROIParam != null) { switch (info.FindModelROIParam.type) { case ROI.Line: break; case ROI.Circle: CircleParam circle = info.FindModelROIParam as CircleParam; if (circle != null) { bDrawFindROI = false; bModifyFindROI = true; displayForm.DrawCircleROI(Convert.ToInt32(circle.CircleRow), Convert.ToInt32(circle.CircleColumn), circle.Radius); } else { MessageHelper.ShowError("创建搜索框失败,请删除后再重新创建!"); } break; case ROI.Ellipse: EllipseParam ellipse = info.FindModelROIParam as EllipseParam; if (ellipse != null) { bDrawFindROI = false; bModifyFindROI = true; displayForm.DrawEllipseROI(ellipse.EllipseCenterRow, ellipse.EllipseCenterColumn, ellipse.EllipseAngle, ellipse.EllipseRadius1, ellipse.EllipseRadius2); } else { MessageHelper.ShowError("修改模板出现错误,请删除当前模板后重修创建"); } break; case ROI.Rectangle1: Rectangle1Param rectangle1 = info.FindModelROIParam as Rectangle1Param; if (rectangle1 != null) { bDrawFindROI = false; bModifyFindROI = true; displayForm.DrawRectangle1ROI(rectangle1.RectangleStartRow, rectangle1.RectangleStartColumn, rectangle1.RectangleEndRow, rectangle1.RectangleEndColumn); } else { MessageHelper.ShowError("修改模板出现错误,请删除当前模板后重修创建"); } break; case ROI.Rectangle2: Rectangle2Param rectangle2 = info.FindModelROIParam as Rectangle2Param; if (rectangle2 != null) { bDrawFindROI = false; bModifyFindROI = true; displayForm.DrawRectangle2ROI(rectangle2.Rectangle2CenterRow, rectangle2.Retangle2CenterColumn, rectangle2.Retangle2Angle, rectangle2.Rectangle2Length1, rectangle2.Rectangle2Length2); } else { MessageHelper.ShowError("修改模板出现错误,请删除当前模板后重修创建"); } break; default: break; } } }
private void DisplayForm_Rectangle1ROIEvent(double t1, double t2, double t3, double t4, object t5) { if (!bModifyModelROI && !bModifyFindROI && !bDrawFindROI) { if (!string.IsNullOrEmpty(newModelName)) { //Create a new setting info GrayMatchToolInfo info = new GrayMatchToolInfo(); info.ToolName = newModelName; info.ModelROIParam = new Rectangle1Param() { RectangleStartRow = t1, RectangleStartColumn = t2, RectangleEndRow = t3, RectangleEndColumn = t4, GraphName = newModelName }; //Create a new match tool GrayMatchTool tool = new GrayMatchTool(info, displayForm); if (!tool.CreateMatchTool()) { MessageHelper.ShowError("模板创建失败,请重新创建"); return; } Infos.Add(info); Tools.Add(info.ToolName, tool); CurrentModelComb.Items.Add(info.ToolName); currentFindRegionComb.Items.Add(info.ToolName); } } else if (bModifyModelROI && !bModifyFindROI && !bDrawFindROI) { bModifyModelROI = false; if (Info != null) { Rectangle1Param rectangle1 = Info.ModelROIParam as Rectangle1Param; if (rectangle1 != null) { rectangle1.RectangleStartRow = t1; rectangle1.RectangleStartColumn = t2; rectangle1.RectangleEndRow = t3; rectangle1.RectangleEndColumn = t4; } } } else if (!bModifyModelROI && !bModifyFindROI && bDrawFindROI) { bDrawFindROI = false; GrayMatchToolInfo info = Infos.Find(p => p.ToolName == currentFindRegionComb.SelectedItem.ToString()); if (info != null) { info.FindModelROIParam = new Rectangle1Param() { GraphName = currentFindRegionComb.SelectedItem.ToString(), RectangleStartRow = t1, RectangleStartColumn = t2, RectangleEndRow = t3, RectangleEndColumn = t4, }; } } else if (!bModifyModelROI && bModifyFindROI && bDrawFindROI) { bDrawFindROI = false; bModifyFindROI = false; GrayMatchToolInfo info = Infos.Find(p => p.ToolName == currentFindRegionComb.SelectedItem.ToString()); if (info != null) { Rectangle1Param rectangle1 = info.FindModelROIParam as Rectangle1Param; if (rectangle1 != null) { rectangle1.RectangleStartRow = t1; rectangle1.RectangleStartColumn = t2; rectangle1.RectangleEndRow = t3; rectangle1.RectangleEndColumn = t4; } } } }
private void DisplayForm_CircleROIEvent(int t1, int t2, double t3, object t4, object t5) { if (!bModifyModelROI && !bModifyFindROI && !bDrawFindROI) { if (!string.IsNullOrEmpty(newModelName)) { //Create a new setting info GrayMatchToolInfo info = new GrayMatchToolInfo(); info.ToolName = newModelName; info.ModelROIParam = new CircleParam() { CircleRow = t1, CircleColumn = t2, Radius = t3, GraphName = newModelName }; //Create a new match tool GrayMatchTool tool = new GrayMatchTool(info, displayForm); if (!tool.CreateMatchTool()) { MessageHelper.ShowError("模板创建失败,请重新创建"); return; } Infos.Add(info); Tools.Add(info.ToolName, tool); CurrentModelComb.Items.Add(info.ToolName); currentFindRegionComb.Items.Add(info.ToolName); } } else if (bModifyModelROI && !bModifyFindROI && !bDrawFindROI) { bModifyModelROI = false; if (Info != null) { CircleParam circle = Info.ModelROIParam as CircleParam; if (circle != null) { circle.CircleRow = t1; circle.CircleColumn = t2; circle.Radius = t3; } } } else if (!bModifyModelROI && !bModifyFindROI && bDrawFindROI) { bDrawFindROI = false; GrayMatchToolInfo info = Infos.Find(p => p.ToolName == currentFindRegionComb.SelectedItem.ToString()); if (info != null) { info.FindModelROIParam = new CircleParam() { GraphName = currentFindRegionComb.SelectedItem.ToString(), CircleRow = t1, CircleColumn = t2, Radius = t3 }; } } else if (!bModifyModelROI && bModifyFindROI && bDrawFindROI) { bDrawFindROI = false; bModifyFindROI = false; GrayMatchToolInfo info = Infos.Find(p => p.ToolName == currentFindRegionComb.SelectedItem.ToString()); if (info != null) { CircleParam circle = info.FindModelROIParam as CircleParam; if (circle != null) { circle.CircleRow = t1; circle.CircleColumn = t2; circle.Radius = t3; } } } }
private void DisplayForm_EllipseROIEvent(double t1, double t2, double t3, double t4, double t5) { if (!bModifyModelROI && !bModifyFindROI && !bDrawFindROI) { if (!string.IsNullOrEmpty(newModelName)) { //Create a new setting info GrayMatchToolInfo info = new GrayMatchToolInfo(); info.ToolName = newModelName; info.ModelROIParam = new EllipseParam() { EllipseCenterRow = t1, EllipseCenterColumn = t2, EllipseAngle = t3, EllipseRadius1 = t4, EllipseRadius2 = t5, GraphName = newModelName }; //Create a new match tool GrayMatchTool tool = new GrayMatchTool(info, displayForm); if (!tool.CreateMatchTool()) { MessageHelper.ShowError("模板创建失败,请重新创建"); return; } Infos.Add(info); Tools.Add(info.ToolName, tool); CurrentModelComb.Items.Add(info.ToolName); currentFindRegionComb.Items.Add(info.ToolName); } } else if (bModifyModelROI && !bModifyFindROI && !bDrawFindROI) { bModifyModelROI = false; if (Info != null) { EllipseParam ellipse = Info.ModelROIParam as EllipseParam; if (ellipse != null) { ellipse.EllipseCenterRow = t1; ellipse.EllipseCenterColumn = t2; ellipse.EllipseAngle = t3; ellipse.EllipseRadius1 = t4; ellipse.EllipseRadius2 = t5; } } } else if (!bModifyModelROI && !bModifyFindROI && bDrawFindROI) { bDrawFindROI = false; GrayMatchToolInfo info = Infos.Find(p => p.ToolName == currentFindRegionComb.SelectedItem.ToString()); if (info != null) { info.FindModelROIParam = new EllipseParam() { GraphName = currentFindRegionComb.SelectedItem.ToString(), EllipseCenterRow = t1, EllipseCenterColumn = t2, EllipseAngle = t3, EllipseRadius1 = t4, EllipseRadius2 = t5 }; } } else if (!bModifyModelROI && bModifyFindROI && bDrawFindROI) { bDrawFindROI = false; bModifyFindROI = false; GrayMatchToolInfo info = Infos.Find(p => p.ToolName == currentFindRegionComb.SelectedItem.ToString()); if (info != null) { EllipseParam ellipse = info.FindModelROIParam as EllipseParam; if (ellipse != null) { ellipse.EllipseCenterRow = t1; ellipse.EllipseCenterColumn = t2; ellipse.EllipseAngle = t3; ellipse.EllipseRadius1 = t4; ellipse.EllipseRadius2 = t5; } } } }