check point
This commit is contained in:
96
Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.Designer.cs
generated
Normal file
96
Hawkeye.VisionBuilder/Features/ImageStatistics/ImageStatisticsDialog.Designer.cs
generated
Normal file
@@ -0,0 +1,96 @@
|
||||
namespace Hawkeye.VisionBuilder.Features.ImageStatistics
|
||||
{
|
||||
partial class ImageStatisticsDialog
|
||||
{
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
private System.Windows.Forms.TreeView treeView;
|
||||
private System.Windows.Forms.Button btnReset;
|
||||
private System.Windows.Forms.Button btnClose;
|
||||
private System.Windows.Forms.Button btnBackward;
|
||||
private System.Windows.Forms.Button btnForward;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.treeView = new System.Windows.Forms.TreeView();
|
||||
this.btnReset = new System.Windows.Forms.Button();
|
||||
this.btnClose = new System.Windows.Forms.Button();
|
||||
this.btnBackward = new System.Windows.Forms.Button();
|
||||
this.btnForward = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// treeView
|
||||
//
|
||||
this.treeView.Location = new System.Drawing.Point(12, 12);
|
||||
this.treeView.Name = "treeView";
|
||||
this.treeView.Size = new System.Drawing.Size(360, 300);
|
||||
this.treeView.TabIndex = 0;
|
||||
this.treeView.NodeMouseClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.treeView_NodeMouseClick);
|
||||
//
|
||||
// btnReset
|
||||
//
|
||||
this.btnReset.Location = new System.Drawing.Point(12, 320);
|
||||
this.btnReset.Name = "btnReset";
|
||||
this.btnReset.Size = new System.Drawing.Size(75, 30);
|
||||
this.btnReset.TabIndex = 1;
|
||||
this.btnReset.Text = "Reset";
|
||||
this.btnReset.UseVisualStyleBackColor = true;
|
||||
this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
|
||||
//
|
||||
// btnClose
|
||||
//
|
||||
this.btnClose.Location = new System.Drawing.Point(297, 320);
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.Size = new System.Drawing.Size(75, 30);
|
||||
this.btnClose.TabIndex = 2;
|
||||
this.btnClose.Text = "Close";
|
||||
this.btnClose.UseVisualStyleBackColor = true;
|
||||
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
||||
//
|
||||
// btnBackward
|
||||
//
|
||||
this.btnBackward.Location = new System.Drawing.Point(100, 320);
|
||||
this.btnBackward.Name = "btnBackward";
|
||||
this.btnBackward.Size = new System.Drawing.Size(75, 30);
|
||||
this.btnBackward.TabIndex = 3;
|
||||
this.btnBackward.Text = "<";
|
||||
this.btnBackward.UseVisualStyleBackColor = true;
|
||||
this.btnBackward.Click += new System.EventHandler(this.btnBackward_Click);
|
||||
//
|
||||
// btnForward
|
||||
//
|
||||
this.btnForward.Location = new System.Drawing.Point(190, 320);
|
||||
this.btnForward.Name = "btnForward";
|
||||
this.btnForward.Size = new System.Drawing.Size(75, 30);
|
||||
this.btnForward.TabIndex = 4;
|
||||
this.btnForward.Text = ">";
|
||||
this.btnForward.UseVisualStyleBackColor = true;
|
||||
this.btnForward.Click += new System.EventHandler(this.btnForward_Click);
|
||||
//
|
||||
// ImageStatisticsDialog
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(384, 361);
|
||||
this.Controls.Add(this.btnForward);
|
||||
this.Controls.Add(this.btnBackward);
|
||||
this.Controls.Add(this.btnClose);
|
||||
this.Controls.Add(this.btnReset);
|
||||
this.Controls.Add(this.treeView);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "ImageStatisticsDialog";
|
||||
this.Text = "Image Statistics";
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Hawkeye.VisionBuilder.Features.ImageStatistics
|
||||
{
|
||||
public partial class ImageStatisticsDialog : Form
|
||||
{
|
||||
private TreeNode _goodNode;
|
||||
private TreeNode _badNode;
|
||||
private HashSet<string> _allFiles = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
private TreeNode? _selectedLeafNode = null;
|
||||
private Dictionary<string, int> _badDefectCounts = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public event Action<string>? FileSelected;
|
||||
|
||||
public ImageStatisticsDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeTree();
|
||||
treeView.AfterSelect += treeView_AfterSelect;
|
||||
UpdateNavigationButtons();
|
||||
}
|
||||
|
||||
private void InitializeTree()
|
||||
{
|
||||
treeView.Nodes.Clear();
|
||||
_goodNode = new TreeNode(GetBranchText("Good", 0));
|
||||
_badNode = new TreeNode(GetBranchText("Bad", 0));
|
||||
treeView.Nodes.Add(_goodNode);
|
||||
treeView.Nodes.Add(_badNode);
|
||||
treeView.ExpandAll();
|
||||
_allFiles.Clear();
|
||||
_badDefectCounts.Clear();
|
||||
}
|
||||
|
||||
public void AddGoodImage(string filePath)
|
||||
{
|
||||
if (_allFiles.Contains(filePath))
|
||||
return;
|
||||
string nodeText = System.IO.Path.GetFileName(filePath);
|
||||
_goodNode.Nodes.Add(new TreeNode(nodeText) { Tag = filePath });
|
||||
_allFiles.Add(filePath);
|
||||
UpdateBranchText(_goodNode, "Good");
|
||||
treeView.ExpandAll();
|
||||
}
|
||||
|
||||
public void AddBadImage(string filePath, string[]? defects = null)
|
||||
{
|
||||
if (_allFiles.Contains(filePath))
|
||||
return;
|
||||
string nodeText = System.IO.Path.GetFileName(filePath);
|
||||
if (defects != null && defects.Length > 0)
|
||||
{
|
||||
nodeText += " (" + string.Join(", ", defects) + ")";
|
||||
foreach (var defect in defects)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(defect)) continue;
|
||||
if (_badDefectCounts.ContainsKey(defect))
|
||||
_badDefectCounts[defect]++;
|
||||
else
|
||||
_badDefectCounts[defect] = 1;
|
||||
}
|
||||
}
|
||||
_badNode.Nodes.Add(new TreeNode(nodeText) { Tag = filePath });
|
||||
_allFiles.Add(filePath);
|
||||
UpdateBranchText(_badNode, "Bad");
|
||||
treeView.ExpandAll();
|
||||
}
|
||||
|
||||
private void UpdateBranchText(TreeNode node, string name)
|
||||
{
|
||||
if (node == _badNode)
|
||||
{
|
||||
node.Text = GetBranchText(name, node.Nodes.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
node.Text = GetBranchText(name, node.Nodes.Count);
|
||||
}
|
||||
}
|
||||
|
||||
private string GetBranchText(string name, int count)
|
||||
{
|
||||
if (name == "Bad")
|
||||
{
|
||||
if (_badDefectCounts.Count > 0)
|
||||
{
|
||||
var defectSummary = string.Join(", ",
|
||||
_badDefectCounts
|
||||
.OrderByDescending(kv => kv.Value)
|
||||
.ThenBy(kv => kv.Key)
|
||||
.Select(kv => $"{kv.Key} {kv.Value}")
|
||||
);
|
||||
return $"{name} ({defectSummary})";
|
||||
}
|
||||
}
|
||||
return $"{name} ({count})";
|
||||
}
|
||||
|
||||
private void btnReset_Click(object sender, EventArgs e)
|
||||
{
|
||||
InitializeTree();
|
||||
_badDefectCounts.Clear();
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
|
||||
{
|
||||
// Only fire event for leaf nodes (filenames)
|
||||
if (e.Node.Parent != null && e.Node.Tag is string filePath)
|
||||
{
|
||||
_selectedLeafNode = e.Node;
|
||||
FileSelected?.Invoke(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedLeafNode = null;
|
||||
}
|
||||
UpdateNavigationButtons();
|
||||
}
|
||||
|
||||
private void treeView_AfterSelect(object? sender, TreeViewEventArgs e)
|
||||
{
|
||||
// Only consider leaf nodes (filenames)
|
||||
if (e.Node.Parent != null && e.Node.Tag is string)
|
||||
{
|
||||
_selectedLeafNode = e.Node;
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedLeafNode = null;
|
||||
}
|
||||
UpdateNavigationButtons();
|
||||
}
|
||||
|
||||
private void UpdateNavigationButtons()
|
||||
{
|
||||
if (_selectedLeafNode == null)
|
||||
{
|
||||
btnBackward.Enabled = false;
|
||||
btnForward.Enabled = false;
|
||||
return;
|
||||
}
|
||||
var parent = _selectedLeafNode.Parent;
|
||||
if (parent == null)
|
||||
{
|
||||
btnBackward.Enabled = false;
|
||||
btnForward.Enabled = false;
|
||||
return;
|
||||
}
|
||||
int idx = parent.Nodes.IndexOf(_selectedLeafNode);
|
||||
btnBackward.Enabled = idx > 0;
|
||||
btnForward.Enabled = idx < parent.Nodes.Count - 1;
|
||||
}
|
||||
|
||||
private void btnBackward_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_selectedLeafNode == null) return;
|
||||
var parent = _selectedLeafNode.Parent;
|
||||
if (parent == null) return;
|
||||
int idx = parent.Nodes.IndexOf(_selectedLeafNode);
|
||||
if (idx > 0)
|
||||
{
|
||||
var prev = parent.Nodes[idx - 1];
|
||||
treeView.SelectedNode = prev;
|
||||
treeView.Focus();
|
||||
if (prev.Tag is string filePath)
|
||||
FileSelected?.Invoke(filePath);
|
||||
}
|
||||
}
|
||||
|
||||
private void btnForward_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_selectedLeafNode == null) return;
|
||||
var parent = _selectedLeafNode.Parent;
|
||||
if (parent == null) return;
|
||||
int idx = parent.Nodes.IndexOf(_selectedLeafNode);
|
||||
if (idx < parent.Nodes.Count - 1)
|
||||
{
|
||||
var next = parent.Nodes[idx + 1];
|
||||
treeView.SelectedNode = next;
|
||||
treeView.Focus();
|
||||
if (next.Tag is string filePath)
|
||||
FileSelected?.Invoke(filePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
Reference in New Issue
Block a user