RsTray增加扫码失败和被选择两种状态

master
lhiven 3 months ago
parent ee0a534e16
commit d062eea589

@ -39,6 +39,8 @@
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.scanFailToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.selectedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.panel1.SuspendLayout(); this.panel1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout();
this.contextMenuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout();
@ -91,7 +93,9 @@
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ToolStripMenuItem, this.ToolStripMenuItem,
this.ToolStripMenuItem, this.ToolStripMenuItem,
this.ToolStripMenuItem}); this.ToolStripMenuItem,
this.scanFailToolStripMenuItem,
this.selectedToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1"; this.contextMenuStrip1.Name = "contextMenuStrip1";
resources.ApplyResources(this.contextMenuStrip1, "contextMenuStrip1"); resources.ApplyResources(this.contextMenuStrip1, "contextMenuStrip1");
// //
@ -113,6 +117,18 @@
resources.ApplyResources(this.ToolStripMenuItem, "禁用ToolStripMenuItem"); resources.ApplyResources(this.ToolStripMenuItem, "禁用ToolStripMenuItem");
this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click);
// //
// scanFailToolStripMenuItem
//
this.scanFailToolStripMenuItem.Name = "scanFailToolStripMenuItem";
resources.ApplyResources(this.scanFailToolStripMenuItem, "scanFailToolStripMenuItem");
this.scanFailToolStripMenuItem.Click += new System.EventHandler(this.scanFailToolStripMenuItem_Click);
//
// selectedToolStripMenuItem
//
this.selectedToolStripMenuItem.Name = "selectedToolStripMenuItem";
resources.ApplyResources(this.selectedToolStripMenuItem, "selectedToolStripMenuItem");
this.selectedToolStripMenuItem.Click += new System.EventHandler(this.selectedToolStripMenuItem_Click);
//
// RsTray // RsTray
// //
resources.ApplyResources(this, "$this"); resources.ApplyResources(this, "$this");
@ -139,5 +155,7 @@
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label lblStatus; private System.Windows.Forms.Label lblStatus;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.ToolStripMenuItem scanFailToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem selectedToolStripMenuItem;
} }
} }

@ -49,12 +49,38 @@ namespace Rs.Controls
public enum ESlotStatus public enum ESlotStatus
{ {
/// <summary>
/// 有料
/// </summary>
Have, Have,
/// <summary>
/// 无料
/// </summary>
NotHave, NotHave,
/// <summary>
/// 测试OK
/// </summary>
Ok, Ok,
/// <summary>
/// 测试NG
/// </summary>
Ng, Ng,
/// <summary>
/// 禁用
/// </summary>
Disable, Disable,
Null /// <summary>
///
/// </summary>
Null,
/// <summary>
/// 扫码失败
/// </summary>
ScanFail,
/// <summary>
/// 被选择
/// </summary>
Selected
} }
public partial class RsTray : UserControl public partial class RsTray : UserControl
@ -197,6 +223,31 @@ namespace Rs.Controls
return null; return null;
} }
public TraySlot GetSlot(ESlotStatus[] status, bool reverse = false)
{
if (reverse)
{
for (int row = 0; row < RowNum; row++)
{
for (int col = ColumnNum; col > 0; col--)
{
int index = row * (ColumnNum) + col;
if (status.Contains( traySlotsDic[index].SlotStatus))
return traySlotsDic[index];
}
}
}
else
{
foreach (KeyValuePair<int, TraySlot> kv in traySlotsDic)
{
if (status.Contains(kv.Value.SlotStatus))
return kv.Value;
}
}
return null;
}
/// <summary> /// <summary>
/// 根据穴位的状态获取穴位 /// 根据穴位的状态获取穴位
/// </summary> /// </summary>
@ -724,6 +775,34 @@ namespace Rs.Controls
{ {
UpdateSlotPos(); UpdateSlotPos();
} }
private void scanFailToolStripMenuItem_Click(object sender, EventArgs e)
{
ChangeSlotStatus(ESlotStatus.ScanFail);
List<TraySlot> slots = new List<TraySlot>();
foreach (KeyValuePair<int, TraySlot> kvSlot in traySlotsDic)
{
if (drawRect.IntersectsWith(kvSlot.Value.Bound))
{
slots.Add(kvSlot.Value);
}
}
DrawTrayAfterEvent?.Invoke(this, ESlotStatus.ScanFail, slots);
}
private void selectedToolStripMenuItem_Click(object sender, EventArgs e)
{
ChangeSlotStatus(ESlotStatus.Selected);
List<TraySlot> slots = new List<TraySlot>();
foreach (KeyValuePair<int, TraySlot> kvSlot in traySlotsDic)
{
if (drawRect.IntersectsWith(kvSlot.Value.Bound))
{
slots.Add(kvSlot.Value);
}
}
DrawTrayAfterEvent?.Invoke(this, ESlotStatus.Selected, slots);
}
} }
/// <summary> /// <summary>
@ -805,6 +884,12 @@ namespace Rs.Controls
case ESlotStatus.Null: case ESlotStatus.Null:
g.FillRectangle(new SolidBrush(Color.FromArgb(11, 16, 36)), Bound.X, Bound.Y, Bound.Width - 1, Bound.Height - 1); g.FillRectangle(new SolidBrush(Color.FromArgb(11, 16, 36)), Bound.X, Bound.Y, Bound.Width - 1, Bound.Height - 1);
break; break;
case ESlotStatus.ScanFail:
g.FillRectangle(new SolidBrush(Color.FromArgb(235, 23, 110)), Bound.X, Bound.Y, Bound.Width - 1, Bound.Height - 1);
break;
case ESlotStatus.Selected:
g.FillRectangle(new SolidBrush(Color.FromArgb(255, 0, 0)), Bound.X, Bound.Y, Bound.Width - 1, Bound.Height - 1);
break;
default: default:
break; break;
} }

@ -282,8 +282,20 @@
<data name="禁用ToolStripMenuItem.Text" xml:space="preserve"> <data name="禁用ToolStripMenuItem.Text" xml:space="preserve">
<value>Disable</value> <value>Disable</value>
</data> </data>
<data name="scanFailToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>134, 22</value>
</data>
<data name="scanFailToolStripMenuItem.Text" xml:space="preserve">
<value>ScanFail</value>
</data>
<data name="selectedToolStripMenuItem.Size" type="System.Drawing.Size, System.Drawing">
<value>134, 22</value>
</data>
<data name="selectedToolStripMenuItem.Text" xml:space="preserve">
<value>Selected</value>
</data>
<data name="contextMenuStrip1.Size" type="System.Drawing.Size, System.Drawing"> <data name="contextMenuStrip1.Size" type="System.Drawing.Size, System.Drawing">
<value>135, 70</value> <value>135, 114</value>
</data> </data>
<data name="&gt;&gt;contextMenuStrip1.Name" xml:space="preserve"> <data name="&gt;&gt;contextMenuStrip1.Name" xml:space="preserve">
<value>contextMenuStrip1</value> <value>contextMenuStrip1</value>
@ -318,6 +330,18 @@
<data name="&gt;&gt;禁用ToolStripMenuItem.Type" xml:space="preserve"> <data name="&gt;&gt;禁用ToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data> </data>
<data name="&gt;&gt;scanFailToolStripMenuItem.Name" xml:space="preserve">
<value>scanFailToolStripMenuItem</value>
</data>
<data name="&gt;&gt;scanFailToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;selectedToolStripMenuItem.Name" xml:space="preserve">
<value>selectedToolStripMenuItem</value>
</data>
<data name="&gt;&gt;selectedToolStripMenuItem.Type" xml:space="preserve">
<value>System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve"> <data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>RsTray</value> <value>RsTray</value>
</data> </data>

Loading…
Cancel
Save