You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
5.5 KiB
C#
135 lines
5.5 KiB
C#
using Rs.DataAccess;
|
|
using Rs.Framework;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using System.Xml;
|
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
|
|
|
namespace Rs.Controls
|
|
{
|
|
public partial class NormalTray : UserControl
|
|
{
|
|
SqliteHelper db = new SqliteHelper();
|
|
public string TrayName { get; set; }
|
|
public int LeftSpace { get; set; }
|
|
public int TopSpace { get; set; }
|
|
public double RowOffset { get; set; }
|
|
public double ColumnOffset { get; set; }
|
|
public int RowNum { get; set; } = 9;
|
|
public int ColumnNum { get; set; } = 10;
|
|
public NormalTray()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private List<TraySlot> traySlots = new List<TraySlot>();
|
|
private Dictionary<int, TraySlot> traySlotsDic = new Dictionary<int, TraySlot>();
|
|
float slotWidth = 0.0f;
|
|
float slotHeight = 0.0f;
|
|
private void NormalTray_Load(object sender, EventArgs e)
|
|
{
|
|
if(!DesignMode)
|
|
{
|
|
if (!string.IsNullOrEmpty(TrayName))
|
|
{
|
|
string querySql = $"select * from normaltray where trayname='{TrayName}'";
|
|
DataTable dt = db.GetDataTable(querySql);
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
LeftSpace = int.Parse(dt.Rows[0]["LeftSpace"].ToString());
|
|
TopSpace = int.Parse(dt.Rows[0]["TopSpace"].ToString());
|
|
RowOffset = double.Parse(dt.Rows[0]["RowOffset"].ToString());
|
|
ColumnOffset = double.Parse(dt.Rows[0]["ColumnNum"].ToString());
|
|
RowNum = int.Parse(dt.Rows[0]["RowNum"].ToString());
|
|
ColumnNum = int.Parse(dt.Rows[0]["ColumnNum"].ToString());
|
|
tableLayoutPanel1.RowStyles.Clear();
|
|
tableLayoutPanel1.ColumnStyles.Clear();
|
|
tableLayoutPanel1.RowCount = RowNum + 1;
|
|
tableLayoutPanel1.ColumnCount= ColumnNum + 1;
|
|
// tableLayoutPanel1.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
|
|
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, 30));
|
|
|
|
for (int i = 0; i < RowNum; i++)
|
|
{
|
|
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Absolute, (panelSlots.Height - 30) / RowNum));
|
|
}
|
|
|
|
|
|
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 30));
|
|
for(int i=0;i<ColumnNum;i++)
|
|
{
|
|
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, (panelSlots.Width - 30) / ColumnNum));
|
|
}
|
|
|
|
|
|
for(int i=1;i<=ColumnNum;i++)
|
|
{
|
|
Label lbl = new Label();
|
|
lbl.ForeColor = Color.Wheat;
|
|
lbl.Margin = new Padding(0);
|
|
lbl.Font = new Font("宋体", 5);
|
|
lbl.AutoSize = false;
|
|
lbl.Dock = DockStyle.Fill;
|
|
lbl.Text = i.ToString();
|
|
lbl.TextAlign = ContentAlignment.MiddleCenter;
|
|
//lbl.Margin = new Padding(2);
|
|
tableLayoutPanel1.Controls.Add(lbl, i, 0);
|
|
}
|
|
|
|
for (int i = 1; i <= RowNum; i++)
|
|
{
|
|
Label lbl = new Label();
|
|
lbl.ForeColor = Color.Wheat;
|
|
lbl.Margin = new Padding(0);
|
|
lbl.Font = new Font("宋体",5);
|
|
lbl.AutoSize = false;
|
|
lbl.Dock = DockStyle.Fill;
|
|
lbl.Text = i.ToString();
|
|
lbl.TextAlign = ContentAlignment.MiddleCenter;
|
|
//lbl.Margin = new Padding(2);
|
|
tableLayoutPanel1.Controls.Add(lbl, 0, i);
|
|
}
|
|
|
|
for (int row=1;row<=RowNum;row++)
|
|
{
|
|
for(int col=1;col<=ColumnNum;col++)
|
|
{
|
|
Label lbl = new Label();
|
|
lbl.MouseDown += Lbl_MouseDown;
|
|
lbl.AutoSize = false;
|
|
lbl.Dock= DockStyle.Fill;
|
|
lbl.Text = "";// $"{row}_{col}";
|
|
lbl.BackColor = Color.Green;
|
|
lbl.Margin=new Padding(1);
|
|
tableLayoutPanel1.Controls.Add(lbl, col, row);
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Lbl_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
if(e.Button== MouseButtons.Right)
|
|
{
|
|
contextMenuStrip1.Show((Control)sender, 20, 20);
|
|
}
|
|
}
|
|
|
|
private void Lbl_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|