|
|
@ -11,19 +11,43 @@ using System.Xml.Serialization;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Rs.Controls
|
|
|
|
namespace Rs.Controls
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
public enum ESortDir
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Horizontal,
|
|
|
|
|
|
|
|
Vertical
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public enum ESlotStatus
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Have,
|
|
|
|
|
|
|
|
NotHave,
|
|
|
|
|
|
|
|
Ok,
|
|
|
|
|
|
|
|
Ng
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public partial class RsTray : UserControl
|
|
|
|
public partial class RsTray : UserControl
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
public ESortDir SortDir { get; set; } = ESortDir.Horizontal;
|
|
|
|
public event Action<TraySlot, MouseEventArgs> SlotClickEvent;
|
|
|
|
public event Action<TraySlot, MouseEventArgs> SlotClickEvent;
|
|
|
|
public RsTray()
|
|
|
|
public RsTray()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
InitializeComponent();
|
|
|
|
InitializeComponent();
|
|
|
|
DoubleBuffered = true;
|
|
|
|
DoubleBuffered = true;
|
|
|
|
InitSlot();
|
|
|
|
InitSlot(InitSlotStatus);
|
|
|
|
this.SizeChanged += (s, e) => {
|
|
|
|
this.SizeChanged += (s, e) => {
|
|
|
|
UpdateSlotPos();
|
|
|
|
UpdateSlotPos();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ESlotStatus _InitSlotStatus = ESlotStatus.Have;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ESlotStatus InitSlotStatus
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get { return _InitSlotStatus; }
|
|
|
|
|
|
|
|
set { _InitSlotStatus = value; InitSlot(InitSlotStatus); Invalidate(); }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public bool CanDraw { get; set; } = true;
|
|
|
|
public bool CanDraw { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
|
|
private List<TraySlot> traySlots = new List<TraySlot>();
|
|
|
|
private List<TraySlot> traySlots = new List<TraySlot>();
|
|
|
@ -45,7 +69,7 @@ namespace Rs.Controls
|
|
|
|
public int RowNum
|
|
|
|
public int RowNum
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get { return _RowNum; }
|
|
|
|
get { return _RowNum; }
|
|
|
|
set { _RowNum = value; InitSlot(); Invalidate(); }
|
|
|
|
set { _RowNum = value; InitSlot(InitSlotStatus); Invalidate(); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int _ColumnNum = 10;
|
|
|
|
private int _ColumnNum = 10;
|
|
|
@ -56,7 +80,7 @@ namespace Rs.Controls
|
|
|
|
public int ColumnNum
|
|
|
|
public int ColumnNum
|
|
|
|
{
|
|
|
|
{
|
|
|
|
get { return _ColumnNum; }
|
|
|
|
get { return _ColumnNum; }
|
|
|
|
set { _ColumnNum = value; InitSlot(); Invalidate(); }
|
|
|
|
set { _ColumnNum = value; InitSlot(InitSlotStatus); Invalidate(); }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int _TopSpaceHeight = 20;
|
|
|
|
private int _TopSpaceHeight = 20;
|
|
|
@ -80,6 +104,23 @@ namespace Rs.Controls
|
|
|
|
set { _LeftSpaceWidth = value; }
|
|
|
|
set { _LeftSpaceWidth = value; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int _RowSpace = 3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int RowSpace
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get { return _RowSpace; }
|
|
|
|
|
|
|
|
set { _RowSpace = value; }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int _ColSpace = 5;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int ColSpace
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get { return _ColSpace; }
|
|
|
|
|
|
|
|
set { _ColSpace = value; }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private bool _ShowText;
|
|
|
|
private bool _ShowText;
|
|
|
|
|
|
|
|
|
|
|
|
public bool ShowText
|
|
|
|
public bool ShowText
|
|
|
@ -91,11 +132,13 @@ namespace Rs.Controls
|
|
|
|
private Bitmap drawImage;
|
|
|
|
private Bitmap drawImage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void InitSlot()
|
|
|
|
private void InitSlot(ESlotStatus status)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int index = 0;
|
|
|
|
int index = 0;
|
|
|
|
traySlots.Clear();
|
|
|
|
traySlots.Clear();
|
|
|
|
traySlotsDic.Clear();
|
|
|
|
traySlotsDic.Clear();
|
|
|
|
|
|
|
|
if(SortDir== ESortDir.Vertical)
|
|
|
|
|
|
|
|
{
|
|
|
|
for (int c = 0; c < ColumnNum; c++)
|
|
|
|
for (int c = 0; c < ColumnNum; c++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (int r = 0; r < RowNum; r++)
|
|
|
|
for (int r = 0; r < RowNum; r++)
|
|
|
@ -105,20 +148,62 @@ namespace Rs.Controls
|
|
|
|
slot.Index = index;
|
|
|
|
slot.Index = index;
|
|
|
|
slot.Row = r;
|
|
|
|
slot.Row = r;
|
|
|
|
slot.Column = c;
|
|
|
|
slot.Column = c;
|
|
|
|
|
|
|
|
slot.SlotStatus = status;
|
|
|
|
//slot.Bound = new RectangleF((LeftSpaceWidth + widthPer * c), (TopSpaceHeight + heightPer * r), (int)widthPer - 5, (int)heightPer - 5);
|
|
|
|
//slot.Bound = new RectangleF((LeftSpaceWidth + widthPer * c), (TopSpaceHeight + heightPer * r), (int)widthPer - 5, (int)heightPer - 5);
|
|
|
|
//slot.Draw(g2);
|
|
|
|
//slot.Draw(g2);
|
|
|
|
traySlots.Add(slot);
|
|
|
|
traySlots.Add(slot);
|
|
|
|
traySlotsDic.Add(index, slot);
|
|
|
|
traySlotsDic.Add(index, slot);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int r = 0; r < RowNum; r++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int c = 0; c < ColumnNum; c++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
TraySlot slot = new TraySlot();
|
|
|
|
|
|
|
|
slot.Index = index;
|
|
|
|
|
|
|
|
slot.Row = r;
|
|
|
|
|
|
|
|
slot.Column = c;
|
|
|
|
|
|
|
|
slot.SlotStatus = status;
|
|
|
|
|
|
|
|
//slot.Bound = new RectangleF((LeftSpaceWidth + widthPer * c), (TopSpaceHeight + heightPer * r), (int)widthPer - 5, (int)heightPer - 5);
|
|
|
|
|
|
|
|
//slot.Draw(g2);
|
|
|
|
|
|
|
|
traySlots.Add(slot);
|
|
|
|
|
|
|
|
traySlotsDic.Add(index, slot);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UpdateSlotPos();
|
|
|
|
UpdateSlotPos();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void ChangeStatus(int index,int status)
|
|
|
|
public void Fill()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach (TraySlot item in traySlots)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
traySlotsDic[index].Status = status;
|
|
|
|
ChangeStatus(item.Index, ESlotStatus.Have);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Clear()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach (TraySlot item in traySlots)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ChangeStatus(item.Index, ESlotStatus.NotHave);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void ChangeStatus(int index,ESlotStatus status)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(traySlotsDic.ContainsKey(index))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
traySlotsDic[index].SlotStatus = status;
|
|
|
|
traySlotsDic[index].Refresh(this.panel2.CreateGraphics(), ShowText);
|
|
|
|
traySlotsDic[index].Refresh(this.panel2.CreateGraphics(), ShowText);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//panel2_Paint(null, null);
|
|
|
|
//panel2_Paint(null, null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -127,6 +212,8 @@ namespace Rs.Controls
|
|
|
|
float slotWidth = (this.panel2.Width - LeftSpaceWidth) / ColumnNum;
|
|
|
|
float slotWidth = (this.panel2.Width - LeftSpaceWidth) / ColumnNum;
|
|
|
|
float slotHeight = (this.panel2.Height - TopSpaceHeight) / RowNum;
|
|
|
|
float slotHeight = (this.panel2.Height - TopSpaceHeight) / RowNum;
|
|
|
|
int index = 0;
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
if(SortDir== ESortDir.Vertical)
|
|
|
|
|
|
|
|
{
|
|
|
|
for (int c = 0; c < ColumnNum; c++)
|
|
|
|
for (int c = 0; c < ColumnNum; c++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (int r = 0; r < RowNum; r++)
|
|
|
|
for (int r = 0; r < RowNum; r++)
|
|
|
@ -134,18 +221,26 @@ namespace Rs.Controls
|
|
|
|
index++;
|
|
|
|
index++;
|
|
|
|
if (traySlotsDic.ContainsKey(index))
|
|
|
|
if (traySlotsDic.ContainsKey(index))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
traySlotsDic[index].Bound = new RectangleF((LeftSpaceWidth + slotWidth * c), (TopSpaceHeight + slotHeight * r), (int)slotWidth - 5, (int)slotHeight - 3);
|
|
|
|
traySlotsDic[index].Bound = new RectangleF((LeftSpaceWidth + slotWidth * c), (TopSpaceHeight + slotHeight * r), (int)slotWidth - ColSpace, (int)slotHeight - RowSpace);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//TraySlot slot = new TraySlot();
|
|
|
|
|
|
|
|
//slot.Index = index;
|
|
|
|
|
|
|
|
//slot.Row = r;
|
|
|
|
|
|
|
|
//slot.Column = c;
|
|
|
|
|
|
|
|
//slot.Bound = new RectangleF((LeftSpaceWidth + widthPer * c), (TopSpaceHeight + heightPer * r), (int)widthPer - 5, (int)heightPer - 5);
|
|
|
|
|
|
|
|
//slot.Draw(g2);
|
|
|
|
|
|
|
|
//traySlots.Add(slot);
|
|
|
|
|
|
|
|
//traySlotsDic.Add(index, slot);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int r = 0; r < RowNum; r++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int c = 0; c < ColumnNum; c++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
|
|
|
if (traySlotsDic.ContainsKey(index))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
traySlotsDic[index].Bound = new RectangleF((LeftSpaceWidth + slotWidth * c), (TopSpaceHeight + slotHeight * r), (int)slotWidth - ColSpace, (int)slotHeight - RowSpace);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
panel2.Refresh();
|
|
|
|
panel2.Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -271,6 +366,7 @@ namespace Rs.Controls
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public class TraySlot
|
|
|
|
public class TraySlot
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
public ESlotStatus SlotStatus { get; set; } = ESlotStatus.Have;
|
|
|
|
|
|
|
|
|
|
|
|
private PointF _Position;
|
|
|
|
private PointF _Position;
|
|
|
|
|
|
|
|
|
|
|
@ -280,14 +376,6 @@ namespace Rs.Controls
|
|
|
|
set { _Position = value; }
|
|
|
|
set { _Position = value; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private int _Status;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public int Status
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
get { return _Status; }
|
|
|
|
|
|
|
|
set { _Status = value; }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int _Index;
|
|
|
|
private int _Index;
|
|
|
|
|
|
|
|
|
|
|
|
public int Index
|
|
|
|
public int Index
|
|
|
@ -331,16 +419,33 @@ namespace Rs.Controls
|
|
|
|
StringFormat sf = new StringFormat();
|
|
|
|
StringFormat sf = new StringFormat();
|
|
|
|
sf.Alignment = StringAlignment.Center;
|
|
|
|
sf.Alignment = StringAlignment.Center;
|
|
|
|
sf.LineAlignment = StringAlignment.Center;
|
|
|
|
sf.LineAlignment = StringAlignment.Center;
|
|
|
|
|
|
|
|
switch (SlotStatus)
|
|
|
|
if(Status==1)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
case ESlotStatus.Have:
|
|
|
|
g.FillRectangle(new SolidBrush(Color.Red), Bound.X, Bound.Y, Bound.Width - 1, Bound.Height - 1);
|
|
|
|
g.FillRectangle(new SolidBrush(Color.Red), Bound.X, Bound.Y, Bound.Width - 1, Bound.Height - 1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
else if(Status==0)
|
|
|
|
case ESlotStatus.NotHave:
|
|
|
|
{
|
|
|
|
|
|
|
|
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);
|
|
|
|
// g.FillRectangle(new SolidBrush(Color.Red), Bound.X, Bound.Y, Bound.Width , Bound.Height );
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ESlotStatus.Ok:
|
|
|
|
|
|
|
|
g.FillRectangle(new SolidBrush(Color.Green), Bound.X, Bound.Y, Bound.Width - 1, Bound.Height - 1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ESlotStatus.Ng:
|
|
|
|
|
|
|
|
g.FillRectangle(new SolidBrush(Color.Gray), Bound.X, Bound.Y, Bound.Width - 1, Bound.Height - 1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if(Status==1)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// g.FillRectangle(new SolidBrush(Color.Red), Bound.X, Bound.Y, Bound.Width - 1, Bound.Height - 1);
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
//else if(Status==0)
|
|
|
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
// g.FillRectangle(new SolidBrush(Color.FromArgb(11, 16, 36)), Bound.X, Bound.Y, Bound.Width-1, Bound.Height-1);
|
|
|
|
|
|
|
|
// // g.FillRectangle(new SolidBrush(Color.Red), Bound.X, Bound.Y, Bound.Width , Bound.Height );
|
|
|
|
|
|
|
|
//}
|
|
|
|
g.DrawRectangle(Pens.White, Bound.X, Bound.Y, Bound.Width, Bound.Height);
|
|
|
|
g.DrawRectangle(Pens.White, Bound.X, Bound.Y, Bound.Width, Bound.Height);
|
|
|
|
if (isShowText)
|
|
|
|
if (isShowText)
|
|
|
|
{
|
|
|
|
{
|
|
|
|