You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
812 lines
28 KiB
812 lines
28 KiB
3 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Drawing;
|
||
|
using System.Data;
|
||
|
using System.Data.SqlClient;
|
||
|
using System.Text;
|
||
|
using System.Windows.Forms;
|
||
|
using DBFactory;
|
||
|
|
||
|
namespace CommonClassLib
|
||
|
{
|
||
|
public partial class UCellPanel : UserControl
|
||
|
{
|
||
|
#region ��������
|
||
|
DBOperator dbo = CommonClassLib.AppSettings.dbo;//20130510
|
||
|
//�����ߴ�
|
||
|
int bigWidth = 30;
|
||
|
|
||
|
int bigHeight = 20;
|
||
|
|
||
|
//���ݵIJ���
|
||
|
Form parentForm;
|
||
|
Control controlCellCode;
|
||
|
|
||
|
|
||
|
Control controlShow;
|
||
|
int taskType = -1;
|
||
|
|
||
|
DataTable tableCellInfoList; //V_CellInfoList
|
||
|
DataTable tableLines; //��ȡcmbLines��DataSource
|
||
|
|
||
|
List<Rectangle> listRecCell = new List<Rectangle>(); //�洢���ƻ���
|
||
|
List<string> listCellCode = new List<string>(); //�洢������λ����
|
||
|
List<int> listCellID = new List<int>(); //�洢��λ��FID
|
||
|
|
||
|
int cellID = -1; //ST_CELL���е�FID
|
||
|
string goodsName; //��������
|
||
|
|
||
|
#region -------��ͼ����
|
||
|
private const int tickFontSpac = 10; //��������ʱ�߽�
|
||
|
private const int tickTopBounds = 20; //���˱߽�
|
||
|
private const int tickBottomBounds = 30; //�ײ��߽�
|
||
|
private const int tickLeftBounds = 60; //���߽�
|
||
|
private const int tickRightBounds = 10; //�Ҷ˱߽�
|
||
|
private const int tickScroll = 15; //�������߶�
|
||
|
private const int tickClearance = 3; //������϶
|
||
|
private Font fontCoordinate; //��������������
|
||
|
#endregion
|
||
|
|
||
|
#region -------��ͼ����
|
||
|
private int intXMax, intYMax, intXMin, intYMin;
|
||
|
private Rectangle selectedRec; //��ǰѡ���Ļ�λ
|
||
|
private Rectangle drawedRec; //�Ѿ����ƵĻ�λ
|
||
|
SolidBrush brushSelectedRec = new SolidBrush(Color.FromArgb(80, Color.Transparent)); //ѡ�л�λ����ɫ
|
||
|
Color paintBorderColor = Color.Navy; //��ͼ�����߿���ɫ
|
||
|
|
||
|
string stackDevice = string.Empty; //�Ѷ����豸����
|
||
|
string laneway = string.Empty;
|
||
|
|
||
|
string wareHouse = string.Empty; //ѡ���IJֿ�
|
||
|
string wareHouseDescription = string.Empty; //�ֿ�������
|
||
|
private int selectedZ; //ѡ������
|
||
|
private string selectedCellCode = string.Empty; //ѡ���Ļ�λ������
|
||
|
private int selectedCellStatus; //ѡ���Ļ�λ�洢״̬
|
||
|
private int selectedRunStatus; //ѡ���Ļ�λ����״̬
|
||
|
#endregion
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ����
|
||
|
/// <summary>
|
||
|
/// ��������
|
||
|
/// </summary>
|
||
|
public string GoodsName
|
||
|
{
|
||
|
set { goodsName = value; }
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// �ֿ�����
|
||
|
/// </summary>
|
||
|
public string WareHouse
|
||
|
{
|
||
|
get { return this.wareHouse; }
|
||
|
set
|
||
|
{
|
||
|
this.wareHouse = value;
|
||
|
if (!this.DesignMode)
|
||
|
{
|
||
|
//object obj = bllOperation.GetSingle("FNAME", "T_ITEMWAREHOUSE", "FCODE = '" + value + "'");
|
||
|
//if (obj != null)
|
||
|
//{
|
||
|
cmbWareHouse.SelectedValue = value;
|
||
|
//wareHouseDescription = obj.ToString();
|
||
|
//}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// �Ѷ����豸����
|
||
|
/// </summary>
|
||
|
public string StackDevice
|
||
|
{
|
||
|
get { return stackDevice; }
|
||
|
set
|
||
|
{
|
||
|
stackDevice = value;
|
||
|
DataView dv = dbo.ExceSQL("SELECT min(F_Z) FROM ST_CELL WHERE (FStack = " + stackDevice + ")").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
SelectedZ = Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// �����豸��
|
||
|
/// </summary>
|
||
|
public string Laneway
|
||
|
{
|
||
|
get { return laneway; }
|
||
|
set
|
||
|
{
|
||
|
|
||
|
laneway = value;
|
||
|
DataView dv = dbo.ExceSQL("SELECT min(F_Z) FROM ST_CELL WHERE (Flaneway = " + laneway + ")").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
SelectedZ = Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// ���ط������ݵĿؼ�
|
||
|
/// </summary>
|
||
|
public Control ControlCellCode
|
||
|
{
|
||
|
get { return controlCellCode; }
|
||
|
set { controlCellCode = value; }
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��
|
||
|
/// </summary>
|
||
|
public int SelectedZ
|
||
|
{
|
||
|
get { return this.selectedZ; }
|
||
|
set
|
||
|
{
|
||
|
if (!this.DesignMode)
|
||
|
{
|
||
|
this.selectedZ = value;
|
||
|
//��ʼ������
|
||
|
InitDataTable();
|
||
|
this.cmbLine.Text = value.ToString();
|
||
|
|
||
|
//���»���
|
||
|
panelCell.Invalidate();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// �����CellCode
|
||
|
/// </summary>
|
||
|
public string CellCode
|
||
|
{
|
||
|
get { return this.selectedCellCode.TrimEnd(); }
|
||
|
set
|
||
|
{
|
||
|
selectedCellCode = value;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// �����
|
||
|
/// </summary>
|
||
|
public int CellID
|
||
|
{
|
||
|
get { return cellID; }
|
||
|
set { cellID = value; ShowCellInformation(); }
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��������
|
||
|
/// </summary>
|
||
|
public string TaskType
|
||
|
{
|
||
|
set { taskType = Convert.ToInt32(value); }
|
||
|
}
|
||
|
|
||
|
private bool allowWareHouseChanged = true;
|
||
|
|
||
|
/// <summary>
|
||
|
/// �ֿ��Ƿ���ѡ
|
||
|
/// </summary>
|
||
|
public bool AllowWareHouseChanged
|
||
|
{
|
||
|
set { allowWareHouseChanged = value; cmbWareHouse.Enabled = allowWareHouseChanged; }
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ���캯��
|
||
|
|
||
|
public UCellPanel()
|
||
|
{
|
||
|
InitializeComponent();
|
||
|
|
||
|
//������ʽ
|
||
|
panelCell.AutoScroll = true;
|
||
|
this.SetStyle(ControlStyles.UserPaint | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true);
|
||
|
this.cmbLine.SelectionChangeCommitted += new EventHandler(cmbLine_SelectionChangeCommitted);
|
||
|
|
||
|
this.fontCoordinate = new Font("Tohoma", 9, FontStyle.Bold);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���캯��
|
||
|
/// </summary>
|
||
|
/// <param name="parent">������</param>
|
||
|
/// <param name="control">�����ؼ�</param>
|
||
|
/// <param name="type">������������ManageType</param>
|
||
|
/// <param name="where">ɸѡ����</param>
|
||
|
public UCellPanel(Form parent, Control control, Control ctrlShow, string where)
|
||
|
: this()
|
||
|
{
|
||
|
this.parentForm = parent;
|
||
|
controlCellCode = control;
|
||
|
controlShow = ctrlShow;
|
||
|
//taskType = type;
|
||
|
|
||
|
//T_WAREHOUSE
|
||
|
DataTable tableWareHouse = dbo.ExceSQL("SELECT F_WarehouseIndex,F_Description FROM T_WAREHOUSE").Tables[0];
|
||
|
cmbWareHouse.DisplayMember = "F_Description";
|
||
|
cmbWareHouse.ValueMember = "F_WarehouseIndex";
|
||
|
|
||
|
cmbWareHouse.DataSource = tableWareHouse.DefaultView;
|
||
|
|
||
|
//��ʼ������
|
||
|
if (cmbWareHouse.SelectedValue != null)
|
||
|
{
|
||
|
WareHouse = cmbWareHouse.SelectedValue.ToString();
|
||
|
SelectedZ = 1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ��ʼ������
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��ʼ������
|
||
|
/// </summary>
|
||
|
private void InitDataTable()
|
||
|
{
|
||
|
string strstack = "";
|
||
|
if (StackDevice != string.Empty)
|
||
|
{
|
||
|
strstack = " and FStack=" + StackDevice + " ";
|
||
|
}
|
||
|
string strlaneway = "";
|
||
|
if (laneway != string.Empty)
|
||
|
{
|
||
|
strlaneway = " and FLaneway=" + laneway + " ";
|
||
|
}
|
||
|
//st_Cell ����ֵ
|
||
|
tableLines = dbo.ExceSQL("SELECT DISTINCT F_Z FROM ST_CELL WHERE FWAREHOUSE = '" + this.wareHouse + "' " + strstack + strlaneway + " ORDER BY F_Z").Tables[0];
|
||
|
cmbLine.DisplayMember = "F_Z";
|
||
|
cmbLine.DataSource = this.tableLines;
|
||
|
|
||
|
//ST_Cell
|
||
|
tableCellInfoList = dbo.ExceSQL("SELECT * FROM ST_CELL WHERE ST_CELL.FWAREHOUSE = '" + this.wareHouse + "' AND F_Z = '" + selectedZ + "' ORDER BY F_X,F_Y DESC").Tables[0];
|
||
|
int count = tableCellInfoList.Rows.Count;
|
||
|
|
||
|
//��ʼ������ֵ
|
||
|
InitMaxSet();
|
||
|
|
||
|
//ѡ�л�λΪ��
|
||
|
selectedRec = Rectangle.Empty;
|
||
|
}
|
||
|
|
||
|
//��ȡ�������У������������ù�����
|
||
|
private void InitMaxSet()
|
||
|
{
|
||
|
DataView dv = dbo.ExceSQL("SELECT MAX(F_X) FROM ST_CELL WHERE FWAREHOUSE = '" + wareHouse + "' and F_Z=" + selectedZ).Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
intXMax = Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
dv = dbo.ExceSQL("SELECT MAX(F_Y) FROM ST_CELL WHERE FWAREHOUSE = '" + wareHouse + "'").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
intYMax = Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
dv = dbo.ExceSQL("SELECT MIN(F_X) FROM ST_CELL WHERE FWAREHOUSE = '" + wareHouse + "'").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
intXMin = Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
dv = dbo.ExceSQL("SELECT MIN(F_Y) FROM ST_CELL WHERE FWAREHOUSE = '" + wareHouse + "' ").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
intYMin = Convert.ToInt32(dv[0][0]);
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
//����������
|
||
|
panelCell.AutoScrollMinSize = new Size((Convert.ToInt32(bigWidth) + 2 * tickClearance) * (intXMax - intXMin + 1) + tickLeftBounds + 2 * tickClearance + tickFontSpac + tickScroll, (Convert.ToInt32(bigHeight) + 2 * tickClearance) * (intYMax - intYMin + 1) + 3 * tickTopBounds);
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ComboBox SeletedValueChanged�ı���
|
||
|
|
||
|
/// <summary>
|
||
|
/// ѡ���ֿ�
|
||
|
/// </summary>
|
||
|
private void cmbWareHouse_SelectedIndexChanged(object sender, EventArgs e)
|
||
|
{
|
||
|
if (cmbWareHouse.SelectedValue != null)
|
||
|
{
|
||
|
wareHouse = cmbWareHouse.SelectedValue.ToString();
|
||
|
DataView dv = dbo.ExceSQL("SELECT F_Description FROM T_WAREHOUSE WHERE F_WarehouseIndex = '" + wareHouse + "'").Tables[0].DefaultView;
|
||
|
if (dv.Count > 0)
|
||
|
{
|
||
|
wareHouseDescription = dv[0]["F_Description"].ToString();
|
||
|
}
|
||
|
}
|
||
|
SelectedZ = 1;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ComboBox SeletedValueChanged�ı���
|
||
|
/// </summary>
|
||
|
private void cmbLine_SelectionChangeCommitted(object sender, EventArgs e)
|
||
|
{
|
||
|
SetBeginData();
|
||
|
SelectedZ = Convert.ToInt32(this.cmbLine.Text);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// �ָ���ʼ������
|
||
|
/// </summary>
|
||
|
private void SetBeginData()
|
||
|
{
|
||
|
//��ʼ����ʾ
|
||
|
panelCell.AutoScrollPosition = new Point(0, 0);
|
||
|
|
||
|
cellID = -1;
|
||
|
selectedCellCode = string.Empty;
|
||
|
selectedRec = Rectangle.Empty;
|
||
|
drawedRec = Rectangle.Empty;
|
||
|
|
||
|
lblCellCode.Text = string.Empty;
|
||
|
lblFUCONVEYOR.Text = string.Empty;
|
||
|
lblFUCODE.Text = string.Empty;
|
||
|
txtCellCode.Clear();
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ���ƻ�λ
|
||
|
|
||
|
/// <summary>
|
||
|
/// ���ƻ�λ
|
||
|
/// </summary>
|
||
|
private void panelCell_Paint(object sender, PaintEventArgs e)
|
||
|
{
|
||
|
if (this.DesignMode)
|
||
|
return;
|
||
|
|
||
|
Graphics g = e.Graphics;
|
||
|
//g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
|
||
|
|
||
|
//���ù�����
|
||
|
g.TranslateTransform(panelCell.AutoScrollPosition.X, panelCell.AutoScrollPosition.Y);
|
||
|
|
||
|
int minBottom = 0, maxRight = 0; //������Ե��¼
|
||
|
int nextPosition = tickTopBounds; //��һ����ͼ����������λ��
|
||
|
int currentPosition = 0; //��ǰλ��
|
||
|
Rectangle cellPaint = Rectangle.Empty; //���Ƶ���������
|
||
|
Point p1, p2; //�����������ĵ�
|
||
|
Dictionary<int, int> paintArea = new Dictionary<int, int>(); //��ͼ������������λ��
|
||
|
|
||
|
int x = 0, y = 0; //���ƻ�������
|
||
|
int width = 0, height = 0; //���ƻ����ij���
|
||
|
|
||
|
//�洢��������
|
||
|
int areaWith = 0; //���������Ŀ���
|
||
|
int areaHeight = 0; //���������ĸ߶�
|
||
|
|
||
|
string code; //�����
|
||
|
int i = 0, j = 0, k = 0; //����
|
||
|
//char side = Char.MinValue; //˫��λ��
|
||
|
|
||
|
//���ձ����ļ�¼
|
||
|
listCellCode.Clear();
|
||
|
listRecCell.Clear();
|
||
|
listCellID.Clear();
|
||
|
|
||
|
//����ͼ��
|
||
|
foreach (DataRow rowCell in tableCellInfoList.Rows)
|
||
|
{
|
||
|
//�����
|
||
|
code = rowCell["FCELLCODE"].ToString().TrimEnd();
|
||
|
i = Convert.ToInt32(code.Split('-')[1]);
|
||
|
j = Convert.ToInt32(code.Split('-')[2]);
|
||
|
|
||
|
//���ݻ����������������ߴ�
|
||
|
|
||
|
areaWith = bigWidth + 2 * tickClearance;
|
||
|
areaHeight = bigHeight + 2 * tickClearance;
|
||
|
|
||
|
|
||
|
#region -------��������
|
||
|
|
||
|
if (k == 0 || (k > 0 && code.Split('-').Length == 3) || (k > 0 && (code.Split('-').Length == 4) && listCellCode[k - 1].Substring(0, listCellCode[k - 1].Length - 2) != code.Substring(0, code.Length - 2)))
|
||
|
{
|
||
|
//���㵱ǰλ�ú���һλ��
|
||
|
if (paintArea.ContainsKey(j))
|
||
|
{
|
||
|
currentPosition = paintArea[j];
|
||
|
nextPosition = currentPosition + areaHeight;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
currentPosition = nextPosition;
|
||
|
nextPosition = currentPosition + areaHeight;
|
||
|
//�洢ֵ��
|
||
|
paintArea[j] = currentPosition;
|
||
|
}
|
||
|
|
||
|
|
||
|
//��ǰ��������
|
||
|
x = tickLeftBounds + areaWith * (i - intXMin);
|
||
|
y = currentPosition;
|
||
|
|
||
|
//����������ɫ
|
||
|
g.FillRectangle(new SolidBrush(Color.FromArgb(-8355585)), x, y, areaWith, areaHeight);
|
||
|
|
||
|
//��������
|
||
|
//width = Convert.ToInt32(rowCell["FWIDTH"].ToString());
|
||
|
//height = (Convert.ToInt32(rowCell["FCELLMODEL"]) == 2) ? Convert.ToInt32(rowCell["FLENGTH"].ToString()) + 2 * tickClearance : Convert.ToInt32(rowCell["FLENGTH"].ToString());
|
||
|
width = bigWidth;
|
||
|
height = bigHeight;
|
||
|
|
||
|
//�����ͼ�¼������ʼ����
|
||
|
x += tickClearance;
|
||
|
y += tickClearance;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ----�жϻ�λ����--����λ����˫����λ
|
||
|
|
||
|
//�洢���ƻ�λ���κͻ�λ����
|
||
|
listRecCell.Insert(k, new Rectangle(x, y, width, height));
|
||
|
listCellCode.Insert(k, code);
|
||
|
listCellID.Insert(k, Convert.ToInt32(rowCell["FID"]));
|
||
|
|
||
|
//����������ɫ
|
||
|
g.FillRectangle(new SolidBrush(Color.Black), x, y, width + 1, height + 1);
|
||
|
//�洢״̬��ɫ
|
||
|
//g.FillRectangle(new SolidBrush(Color.FromArgb(Convert.ToInt32(-12550016))), listRecCell[k]);
|
||
|
//TODO �洢״̬��ɫ
|
||
|
if (rowCell["FCELLSTATUS"].ToString().TrimEnd() == "1")//20110101
|
||
|
{
|
||
|
g.FillRectangle(new SolidBrush(Color.Navy), listRecCell[k]);
|
||
|
}
|
||
|
else if (rowCell["FCELLSTATUS"].ToString().TrimEnd() == "0")//20110101
|
||
|
{
|
||
|
g.FillRectangle(new SolidBrush(Color.FromArgb(Convert.ToInt32(-12550016))), listRecCell[k]);
|
||
|
|
||
|
}
|
||
|
else//-1����
|
||
|
{
|
||
|
g.FillRectangle(new SolidBrush(Color.Gray), listRecCell[k]);
|
||
|
}
|
||
|
//����״̬��ʾ
|
||
|
g.DrawString("", fontCoordinate, new SolidBrush(Color.Black), x + width / 2 - 5, y + height / 2 - fontCoordinate.Height / 2);
|
||
|
|
||
|
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
//����������Ե
|
||
|
if (intXMax == i && maxRight == 0)
|
||
|
maxRight = x + areaWith - tickLeftBounds - tickClearance;
|
||
|
if (intYMin == j && minBottom == 0)
|
||
|
minBottom = nextPosition - tickTopBounds;
|
||
|
|
||
|
//��������
|
||
|
k++;
|
||
|
|
||
|
//��X���� ������Ҫ��������������ʾ�̶�
|
||
|
if (((i + 1) % 5 == 0 && j == intYMin) || (i == intXMax - 1 && i > 5 && j == intYMin))
|
||
|
g.DrawString((i + 1).ToString(), this.fontCoordinate, Brushes.Black, x + width / 2 - this.fontCoordinate.Height / 2 + width + 3, nextPosition + tickClearance + tickFontSpac);
|
||
|
//Y������
|
||
|
if ((j % 5 == 0 && i == intXMin) || (j == intYMax && j > 5 && i == intXMin))
|
||
|
g.DrawString(j.ToString(), this.fontCoordinate, Brushes.Black, tickLeftBounds - tickFontSpac - tickClearance - 3 * this.fontCoordinate.Height / 2, y + height / 2 - this.fontCoordinate.Height / 2);
|
||
|
}
|
||
|
|
||
|
#region ------������������ԭ��
|
||
|
|
||
|
//���ƻ�ͼ�߿�
|
||
|
cellPaint = new Rectangle(tickLeftBounds, tickTopBounds, maxRight, minBottom);
|
||
|
g.DrawRectangle(new Pen(paintBorderColor, 2), cellPaint);
|
||
|
|
||
|
//����X������
|
||
|
p1 = new Point(tickLeftBounds - tickFontSpac, cellPaint.Bottom + tickFontSpac);
|
||
|
p2 = new Point(cellPaint.Right + tickClearance + tickFontSpac, cellPaint.Bottom + tickFontSpac);
|
||
|
g.DrawLine(new Pen(Color.Black, 2), p1, p2);
|
||
|
//���Ƽ�ͷ
|
||
|
g.DrawLine(new Pen(Color.Black, 1), p2, new Point(p2.X - tickClearance, p2.Y + tickClearance));
|
||
|
g.DrawLine(new Pen(Color.Black, 1), p2, new Point(p2.X - tickClearance, p2.Y - tickClearance));
|
||
|
|
||
|
//����Y������
|
||
|
p2 = new Point(tickLeftBounds - tickFontSpac, tickTopBounds - tickFontSpac);
|
||
|
g.DrawLine(new Pen(Color.Black, 2), p1, p2);
|
||
|
//���Ƽ�ͷ
|
||
|
g.DrawLine(new Pen(Color.Black, 1), p2, new Point(p2.X - tickClearance, p2.Y + tickClearance));
|
||
|
g.DrawLine(new Pen(Color.Black, 1), p2, new Point(p2.X + tickClearance, p2.Y + tickClearance));
|
||
|
|
||
|
//����ԭ��
|
||
|
p2 = new Point(tickLeftBounds - tickFontSpac - tickClearance - 3 * this.fontCoordinate.Height / 2, cellPaint.Bottom + tickFontSpac + tickClearance);
|
||
|
g.DrawString("O", new Font("Tohoma", 9, FontStyle.Bold | FontStyle.Italic), Brushes.Black, p2);
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
//����ѡ����λ�Ļ��ƾ��δ�С
|
||
|
if (cellID != -1)
|
||
|
{
|
||
|
int index = listCellID.IndexOf(cellID);
|
||
|
if (index != -1)
|
||
|
selectedRec = listRecCell[index];
|
||
|
}
|
||
|
|
||
|
//ͻ����ʾѡ�еĻ�λ
|
||
|
DrawSelectedRectangel();
|
||
|
|
||
|
//�ͷ�
|
||
|
g.Dispose();
|
||
|
paintArea.Clear();
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region Mouse Down Event
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��������ʱ��ʾ��λ��Ϣ
|
||
|
/// </summary>
|
||
|
private void panelCell_MouseClick(object sender, MouseEventArgs e)
|
||
|
{
|
||
|
foreach (Rectangle recCell in listRecCell)
|
||
|
{
|
||
|
if (recCell.Contains(e.X + Math.Abs(panelCell.AutoScrollPosition.X), e.Y + Math.Abs(panelCell.AutoScrollPosition.Y)))
|
||
|
{
|
||
|
//������ʽ
|
||
|
if (recCell != drawedRec)
|
||
|
{
|
||
|
//���û�λ����
|
||
|
int index = listRecCell.IndexOf(recCell);
|
||
|
selectedCellCode = listCellCode[index];
|
||
|
cellID = listCellID[index];
|
||
|
selectedRec = listRecCell[index];
|
||
|
|
||
|
//��ʾ��λ��Ϣ
|
||
|
ShowCellInformation();
|
||
|
|
||
|
//������ʽ
|
||
|
DrawSelectedRectangel();
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��ʾ��λ��Ϣ
|
||
|
/// </summary>
|
||
|
private void ShowCellInformation()
|
||
|
{
|
||
|
//�����
|
||
|
DataRow[] rows = tableCellInfoList.Select("FID = '" + cellID + "'");
|
||
|
if (rows.Length > 0)
|
||
|
{
|
||
|
//ѡ���Ļ�λ�ĵ�ǰDataRow
|
||
|
DataRow row = rows[0];
|
||
|
|
||
|
//״̬����
|
||
|
selectedCellStatus = Convert.ToInt32(row["FCELLSTATUS"]);
|
||
|
selectedRunStatus = Convert.ToInt32(row["FRUNSTATUS"]);
|
||
|
|
||
|
//��ʾ��Ϣ
|
||
|
this.lblCellCode.Text = row["FCELLCODE"].ToString();
|
||
|
lblFUCONVEYOR.Text = row["FUCONVEYOR"].ToString();
|
||
|
lblFUCODE.Text = row["FPALLETBARCODE"].ToString();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����ѡ���Ļ�λ��ʽ
|
||
|
/// </summary>
|
||
|
private void DrawSelectedRectangel()
|
||
|
{
|
||
|
//�ж��Ƿ��ظ�λ��
|
||
|
if (selectedRec == Rectangle.Empty || cellID == -1)
|
||
|
return;
|
||
|
|
||
|
//ȡ���ɵ�ѡ����ʽ
|
||
|
if (selectedRec != drawedRec && drawedRec != Rectangle.Empty)
|
||
|
panelCell.Invalidate(new Rectangle(drawedRec.X - Math.Abs(panelCell.AutoScrollPosition.X) - 1, drawedRec.Y - Math.Abs(panelCell.AutoScrollPosition.Y) - 1, drawedRec.Width + 2, drawedRec.Height + 2));
|
||
|
|
||
|
using (Graphics g = panelCell.CreateGraphics())
|
||
|
{
|
||
|
Rectangle recTrans = new Rectangle(selectedRec.X - Math.Abs(panelCell.AutoScrollPosition.X), selectedRec.Y - Math.Abs(panelCell.AutoScrollPosition.Y), selectedRec.Width, selectedRec.Height);
|
||
|
g.DrawRectangle(new Pen(Color.Red, 2), recTrans);
|
||
|
g.FillRectangle(brushSelectedRec, recTrans);
|
||
|
|
||
|
//���¼�¼���ƵĻ�λ
|
||
|
drawedRec = selectedRec;
|
||
|
|
||
|
//�ͷ�
|
||
|
g.Dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ����˫��ʱ�����ݻ�λ
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����˫��ʱ�����ݻ�λ
|
||
|
/// </summary>
|
||
|
private void panelCell_MouseDoubleClick(object sender, MouseEventArgs e)
|
||
|
{
|
||
|
if (e.Button != MouseButtons.Left)
|
||
|
return;
|
||
|
|
||
|
if (parentForm == null || controlCellCode == null)
|
||
|
return;
|
||
|
|
||
|
//����ѡ����λ
|
||
|
cellID = -1;
|
||
|
selectedCellCode = string.Empty;
|
||
|
selectedRec = Rectangle.Empty;
|
||
|
foreach (Rectangle recCell in listRecCell)
|
||
|
{
|
||
|
if (recCell.Contains(e.X + Math.Abs(panelCell.AutoScrollPosition.X), e.Y + Math.Abs(panelCell.AutoScrollPosition.Y)))
|
||
|
{
|
||
|
//���û�λ����
|
||
|
int index = listRecCell.IndexOf(recCell);
|
||
|
selectedCellCode = listCellCode[index];
|
||
|
cellID = listCellID[index];
|
||
|
selectedRec = listRecCell[index];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (cellID == -1)
|
||
|
return;
|
||
|
|
||
|
|
||
|
|
||
|
//���ݻ�λ����ֵ
|
||
|
SetCellCode();
|
||
|
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// Ϊ�ؼ����ݻ�λ����
|
||
|
/// </summary>
|
||
|
private void SetCellCode()
|
||
|
{
|
||
|
if (controlCellCode.GetType() == typeof(TextBox))
|
||
|
{
|
||
|
TextBox textBox = controlCellCode as TextBox;
|
||
|
textBox.Text = selectedCellCode;
|
||
|
}
|
||
|
else if (controlCellCode.GetType() == typeof(ComboBox))
|
||
|
{
|
||
|
ComboBox comboBox = controlCellCode as ComboBox;
|
||
|
comboBox.Text = selectedCellCode;
|
||
|
}
|
||
|
//���ؿؼ�
|
||
|
if (controlShow != null)
|
||
|
{
|
||
|
if (controlShow.GetType() == typeof(SplitContainer))
|
||
|
{
|
||
|
SplitContainer splitContainer = controlShow as SplitContainer;
|
||
|
splitContainer.Panel1Collapsed = true;
|
||
|
}
|
||
|
}
|
||
|
//this.Hide();
|
||
|
//this.Parent.Visible = false;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ����ˢ��
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void btnFind_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (txtCellCode.Text == string.Empty)
|
||
|
return;
|
||
|
|
||
|
int index = listCellCode.IndexOf(txtCellCode.Text);
|
||
|
if (index == -1)
|
||
|
return;
|
||
|
|
||
|
//��¼��λ��Ϣ
|
||
|
selectedCellCode = txtCellCode.Text.TrimEnd();
|
||
|
cellID = listCellID[index];
|
||
|
|
||
|
//����ָ����λ
|
||
|
FindCell();
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ����ָ����λ
|
||
|
/// </summary>
|
||
|
private void FindCell()
|
||
|
{
|
||
|
if (cellID == -1)
|
||
|
return;
|
||
|
|
||
|
int index = listCellID.IndexOf(cellID);
|
||
|
if (index == -1)
|
||
|
return;
|
||
|
|
||
|
Rectangle recFind = listRecCell[index];
|
||
|
if (recFind != drawedRec)
|
||
|
{
|
||
|
selectedRec = recFind;
|
||
|
|
||
|
//��ʾ��λ��Ϣ
|
||
|
ShowCellInformation();
|
||
|
//����ѡ����λ����ʽ
|
||
|
DrawSelectedRectangel();
|
||
|
}
|
||
|
|
||
|
//��������ֵ
|
||
|
int difX = (selectedRec.X - Math.Abs(panelCell.AutoScrollPosition.X)) - panelCell.AutoScrollPosition.X - panelCell.Width / 2;
|
||
|
int difY = (selectedRec.Y - Math.Abs(panelCell.AutoScrollPosition.Y)) - panelCell.AutoScrollPosition.Y - panelCell.Height / 2;
|
||
|
|
||
|
//���ù�������
|
||
|
panelCell.AutoScrollPosition = new Point(difX, difY);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ��Ӧ�س���,��������
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void txtCellCode_KeyDown(object sender, KeyEventArgs e)
|
||
|
{
|
||
|
if (e.KeyCode == Keys.Enter)
|
||
|
{
|
||
|
btnFind_Click(null, EventArgs.Empty);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// ˢ�°�ť
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void btnUpdate_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
if (cmbLine.Text == string.Empty)
|
||
|
return;
|
||
|
|
||
|
this.SelectedZ = int.Parse(cmbLine.Text);
|
||
|
|
||
|
//����ָ����λ
|
||
|
int index = listCellID.IndexOf(cellID);
|
||
|
if (index == -1)
|
||
|
return;
|
||
|
|
||
|
//��¼��λ��Ϣ
|
||
|
selectedCellCode = listCellCode[index];
|
||
|
FindCell();
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region ȡ��ѡ�����ر�
|
||
|
/// <summary>
|
||
|
/// �رջ����ظ��ؼ�
|
||
|
/// </summary>
|
||
|
/// <param name="sender"></param>
|
||
|
/// <param name="e"></param>
|
||
|
private void btnHide_Click(object sender, EventArgs e)
|
||
|
{
|
||
|
this.Hide();
|
||
|
this.Parent.Visible = false;
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
}
|
||
|
}
|