using iWareSda_QQJF.RgvModel;
|
using iWareSda_QQJF.SRM.SrmModel;
|
using iWareSda_QQJF.SrmTranModel;
|
using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Linq;
|
using System.Text;
|
using System.Threading;
|
using System.Threading.Tasks;
|
using System.Windows.Forms;
|
|
namespace iWareSda_QQJF._2DShow
|
{
|
public partial class _2Dshow : Form
|
{
|
double ProportionX = 1;//窗口改变比例
|
double ProportionY = 1;//窗口改变比例
|
double SrmChange = 0.01188;//srm坐标变换比例
|
double RgvChange = 0.00752;//tran坐标变换比例
|
bool sizeChange = false;//窗口变换大小
|
|
List<long> srmLocalList = new List<long>();
|
List<long> rgvLocalList = new List<long>();
|
|
//默认数据
|
int SrmdefaultY1 = 0;
|
int SrmdefaultY2 = 0;
|
int SrmdefaultY3 = 0;
|
int SrmdefaultY4 = 0;
|
int SrmdefaultY5 = 0;
|
int SrmdefaultY6 = 0;
|
int SrmdefaultY7 = 0;
|
int SrmdefaultY8 = 0;
|
int SrmdefaultY9 = 0;
|
|
int RgvdefaultX1 = 0;
|
int RgvdefaultX2 = 0;
|
int RgvdefaultX3 = 0;
|
int RgvdefaultX4 = 0;
|
|
int SrmDefaultSizeX = 0;
|
int SrmDefaultSizeY = 0;
|
int RgvDefaultSizeX = 0;
|
int RgvDefaultSizeY = 0;
|
|
PictureBox pSrm1 = new PictureBox();
|
PictureBox pSrm2 = new PictureBox();
|
PictureBox pSrm3 = new PictureBox();
|
PictureBox pSrm4 = new PictureBox();
|
PictureBox pSrm5 = new PictureBox();
|
PictureBox pSrm6 = new PictureBox();
|
PictureBox pSrm7 = new PictureBox();
|
PictureBox pSrm8 = new PictureBox();
|
PictureBox pSrm9 = new PictureBox();
|
|
PictureBox pRgv1 = new PictureBox();
|
PictureBox pRgv2 = new PictureBox();
|
PictureBox pRgv3 = new PictureBox();
|
PictureBox pRgv4 = new PictureBox();
|
|
List<PictureBox> pBSrmList = new List<PictureBox>();
|
List<PictureBox> pBRgvList = new List<PictureBox>();
|
List<PictureBox> pBSrmItemList = new List<PictureBox>();
|
List<PictureBox> pBRgvItemList = new List<PictureBox>();
|
|
Thread threadRe1;
|
Thread threadRe2;
|
Thread threadRe3;
|
Thread threadRe4;
|
Thread threadRe5;
|
Thread threadRe6;
|
Thread threadRe7;
|
Thread threadRe8;
|
Thread threadRe9;
|
|
Thread threadReRgv1;
|
Thread threadReRgv2;
|
Thread threadReRgv3;
|
Thread threadReRgv4;
|
|
Thread threadChangeSize;
|
|
public _2Dshow()
|
{
|
InitializeComponent();
|
|
//this.SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
// ControlStyles.ResizeRedraw |
|
// ControlStyles.AllPaintingInWmPaint, true);
|
//SetStyle(ControlStyles.UserPaint, true);
|
//SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背景.
|
//SetStyle(ControlStyles.DoubleBuffer, true); // 双缓冲
|
//初始化队列
|
pBSrmList.Add(pBSrm1);
|
pBSrmList.Add(pBSrm2);
|
pBSrmList.Add(pBSrm3);
|
pBSrmList.Add(pBSrm4);
|
pBSrmList.Add(pBSrm5);
|
pBSrmList.Add(pBSrm6);
|
pBSrmList.Add(pBSrm7);
|
pBSrmList.Add(pBSrm8);
|
pBSrmList.Add(pBSrm9);
|
|
pBRgvList.Add(pBRgv1);
|
pBRgvList.Add(pBRgv2);
|
pBRgvList.Add(pBRgv3);
|
pBRgvList.Add(pBRgv4);
|
|
srmLocalList.Add(69258);
|
srmLocalList.Add(69258);
|
srmLocalList.Add(68805);
|
srmLocalList.Add(71355);
|
srmLocalList.Add(71388);
|
srmLocalList.Add(71388);
|
srmLocalList.Add(71579);
|
srmLocalList.Add(71591);
|
srmLocalList.Add(71694);
|
|
rgvLocalList.Add(84523);
|
rgvLocalList.Add(88123);
|
rgvLocalList.Add(82123);
|
rgvLocalList.Add(86323);
|
//初始化货物
|
SetSrmItem(pSrm1);
|
SetSrmItem(pSrm2);
|
SetSrmItem(pSrm3);
|
SetSrmItem(pSrm4);
|
SetSrmItem(pSrm5);
|
SetSrmItem(pSrm6);
|
SetSrmItem(pSrm7);
|
SetSrmItem(pSrm8);
|
SetSrmItem(pSrm9);
|
|
SetRgvItem(pRgv1);
|
SetRgvItem(pRgv2);
|
SetRgvItem(pRgv3);
|
SetRgvItem(pRgv4);
|
|
pBSrmItemList.Add(pSrm1);
|
pBSrmItemList.Add(pSrm2);
|
pBSrmItemList.Add(pSrm3);
|
pBSrmItemList.Add(pSrm4);
|
pBSrmItemList.Add(pSrm5);
|
pBSrmItemList.Add(pSrm6);
|
pBSrmItemList.Add(pSrm7);
|
pBSrmItemList.Add(pSrm8);
|
pBSrmItemList.Add(pSrm9);
|
|
pBRgvItemList.Add(pRgv1);
|
pBRgvItemList.Add(pRgv2);
|
pBRgvItemList.Add(pRgv3);
|
pBRgvItemList.Add(pRgv4);
|
|
//计算比例
|
ProportionX = (double)panel1.Size.Width / 1030.0 ;
|
ProportionY = (double)panel1.Size.Height / 677.0;
|
//记录默认值
|
SrmdefaultY1 = pBSrm1.Location.Y;
|
SrmdefaultY2 = pBSrm2.Location.Y;
|
SrmdefaultY3 = pBSrm3.Location.Y;
|
SrmdefaultY4 = pBSrm4.Location.Y;
|
SrmdefaultY5 = pBSrm5.Location.Y;
|
SrmdefaultY6 = pBSrm6.Location.Y;
|
SrmdefaultY7 = pBSrm7.Location.Y;
|
SrmdefaultY8 = pBSrm8.Location.Y;
|
SrmdefaultY9 = pBSrm9.Location.Y;
|
|
RgvdefaultX1 = pBRgv1.Location.X;
|
RgvdefaultX2 = pBRgv2.Location.X;
|
RgvdefaultX3 = pBRgv3.Location.X;
|
RgvdefaultX4 = pBRgv4.Location.X;
|
|
SrmDefaultSizeX = pBSrm1.Size.Width;
|
SrmDefaultSizeY = pBSrm1.Size.Height;
|
RgvDefaultSizeX = pBRgv1.Size.Width;
|
RgvDefaultSizeY = pBRgv1.Size.Height;
|
//父定义
|
pBSrm1.Parent = picLayer;
|
pBSrm2.Parent = picLayer;
|
pBSrm3.Parent = picLayer;
|
pBSrm4.Parent = picLayer;
|
pBSrm5.Parent = picLayer;
|
pBSrm6.Parent = picLayer;
|
pBSrm7.Parent = picLayer;
|
pBSrm8.Parent = picLayer;
|
pBSrm9.Parent = picLayer;
|
|
pBRgv1.Parent = picLayer;
|
pBRgv2.Parent = picLayer;
|
pBRgv3.Parent = picLayer;
|
pBRgv4.Parent = picLayer;
|
|
pSrm1.Parent = pBSrm1;
|
pSrm2.Parent = pBSrm2;
|
pSrm3.Parent = pBSrm3;
|
pSrm4.Parent = pBSrm4;
|
pSrm5.Parent = pBSrm5;
|
pSrm6.Parent = pBSrm6;
|
pSrm7.Parent = pBSrm7;
|
pSrm8.Parent = pBSrm8;
|
pSrm9.Parent = pBSrm9;
|
|
pRgv1.Parent = pBRgv1;
|
pRgv2.Parent = pBRgv2;
|
pRgv3.Parent = pBRgv3;
|
pRgv4.Parent = pBRgv4;
|
|
|
threadRe1 = new Thread(new ParameterizedThreadStart(RenewSrm));
|
threadRe2 = new Thread(new ParameterizedThreadStart(RenewSrm));
|
threadRe3 = new Thread(new ParameterizedThreadStart(RenewSrm));
|
threadRe4 = new Thread(new ParameterizedThreadStart(RenewSrm));
|
threadRe5 = new Thread(new ParameterizedThreadStart(RenewSrm));
|
threadRe6 = new Thread(new ParameterizedThreadStart(RenewSrm));
|
threadRe7 = new Thread(new ParameterizedThreadStart(RenewSrm));
|
threadRe8 = new Thread(new ParameterizedThreadStart(RenewSrm));
|
threadRe9 = new Thread(new ParameterizedThreadStart(RenewSrm));
|
|
threadRe1.Start(0);
|
threadRe2.Start(1);
|
threadRe3.Start(2);
|
threadRe4.Start(3);
|
threadRe5.Start(4);
|
threadRe6.Start(5);
|
threadRe7.Start(6);
|
threadRe8.Start(7);
|
threadRe9.Start(8);
|
|
threadReRgv1 = new Thread(new ParameterizedThreadStart(RenewRgv));
|
threadReRgv2 = new Thread(new ParameterizedThreadStart(RenewRgv));
|
threadReRgv3 = new Thread(new ParameterizedThreadStart(RenewRgv));
|
threadReRgv4 = new Thread(new ParameterizedThreadStart(RenewRgv));
|
|
threadReRgv1.Start(0);
|
threadReRgv2.Start(1);
|
threadReRgv3.Start(2);
|
threadReRgv4.Start(3);
|
|
threadChangeSize = new Thread(ChangeFormSize);
|
threadChangeSize.Start();
|
}
|
|
private void SetRgvItem(PictureBox pic)
|
{
|
pic.BackColor = Color.Blue;
|
pic.Size = new System.Drawing.Size((int)(14 * ProportionX), (int)(16 * ProportionY));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pic, "Left", (int)(15 * ProportionX));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pic, "Top", (int)(1 * ProportionY));
|
}
|
|
private void SetSrmItem(PictureBox pic)
|
{
|
pic.BackColor = Color.Blue;
|
pic.Size = new System.Drawing.Size((int)(14 * ProportionX), (int)(16 * ProportionY));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pic, "Left", (int)(27 * ProportionX));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pic, "Top", (int)(1 * ProportionY));
|
}
|
|
/// <summary>
|
/// 刷新Srm
|
/// </summary>
|
public void RenewSrm(object device)
|
{
|
while (true)
|
{
|
Thread.Sleep(300);
|
ChangeSrm(Convert.ToInt32(device));
|
}
|
}
|
|
/// <summary>
|
/// 刷新Rgv
|
/// </summary>
|
public void RenewRgv(object device)
|
{
|
while (true)
|
{
|
Thread.Sleep(300);
|
ChangeRgv(Convert.ToInt32(device));
|
}
|
}
|
|
/// <summary>
|
/// 避免闪烁
|
/// </summary>
|
protected override CreateParams CreateParams
|
{
|
get
|
{
|
CreateParams paras = base.CreateParams;
|
paras.ExStyle |= 0x02000000;
|
return paras;
|
}
|
}
|
|
public void ChangeSrm(int srm)
|
{
|
//动态坐标
|
long srmX = Srm_CacheEntity.Srms[srm].Rposxmm;
|
int value = (int)(ProportionX * SrmChange * (srmLocalList[srm] - srmX));
|
if (pBSrmList[srm].Left != value)
|
{
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBSrmList[srm], "Left", value);
|
}
|
//显示载货
|
bool vis = IntToBool(Srm_CacheEntity.Srms[srm].RliftFull);
|
if (pBSrmItemList[srm].Visible != vis)
|
{
|
pBSrmItemList[srm].Visible = vis;
|
}
|
}
|
|
public void ChangeRgv(int rgv)
|
{
|
long rgvY = Rgv_CacheEntity.Rgvs[rgv].posation;
|
int value = (int)(ProportionY * RgvChange * (rgvLocalList[rgv] - rgvY));
|
if (pBRgvList[rgv].Top != value)
|
{
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBRgvList[rgv], "Top", value);
|
}
|
bool vis = IntToBool(Rgv_CacheEntity.Rgvs[rgv].loaded);
|
if (pBRgvItemList[rgv].Visible != vis)
|
{
|
pBRgvItemList[rgv].Visible = vis;
|
}
|
}
|
/// <summary>
|
/// int转bool
|
/// </summary>
|
/// <param name="value"></param>
|
/// <returns></returns>
|
public bool IntToBool(int value)
|
{
|
if (value == 1)
|
{
|
return true;
|
}
|
return false;
|
}
|
|
public void ChangeFormSize()
|
{
|
while (true)
|
{
|
Thread.Sleep(100);
|
if (sizeChange)
|
{
|
sizeChange = false;
|
ChangeSize();
|
}
|
}
|
}
|
|
/// <summary>
|
/// 自适应
|
/// </summary>
|
public void ChangeSize()
|
{
|
//计算比例
|
ProportionX = (double)panel1.Size.Width / 1030.0;
|
ProportionY = (double)panel1.Size.Height / 677.0;
|
//静止坐标
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBSrm1, "Top", (int)(ProportionY * SrmdefaultY1));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBSrm2, "Top", (int)(ProportionY * SrmdefaultY2));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBSrm3, "Top", (int)(ProportionY * SrmdefaultY3));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBSrm4, "Top", (int)(ProportionY * SrmdefaultY4));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBSrm5, "Top", (int)(ProportionY * SrmdefaultY5));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBSrm6, "Top", (int)(ProportionY * SrmdefaultY6));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBSrm7, "Top", (int)(ProportionY * SrmdefaultY7));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBSrm8, "Top", (int)(ProportionY * SrmdefaultY8));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBSrm9, "Top", (int)(ProportionY * SrmdefaultY9));
|
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBRgv1, "Left", (int)(ProportionX * (RgvdefaultX1)));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBRgv2, "Left", (int)(ProportionX * (RgvdefaultX2)));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBRgv3, "Left", (int)(ProportionX * (RgvdefaultX3)));
|
WZ.Useful.Commons.ControlHelper.SetControlProperty(pBRgv4, "Left", (int)(ProportionX * (RgvdefaultX4)));
|
//图片大小
|
pBSrm1.Size = new System.Drawing.Size((int)(SrmDefaultSizeX * ProportionX), (int)(SrmDefaultSizeY * ProportionY));
|
pBSrm2.Size = new System.Drawing.Size((int)(SrmDefaultSizeX * ProportionX), (int)(SrmDefaultSizeY * ProportionY));
|
pBSrm3.Size = new System.Drawing.Size((int)(SrmDefaultSizeX * ProportionX), (int)(SrmDefaultSizeY * ProportionY));
|
pBSrm4.Size = new System.Drawing.Size((int)(SrmDefaultSizeX * ProportionX), (int)(SrmDefaultSizeY * ProportionY));
|
pBSrm5.Size = new System.Drawing.Size((int)(SrmDefaultSizeX * ProportionX), (int)(SrmDefaultSizeY * ProportionY));
|
pBSrm6.Size = new System.Drawing.Size((int)(SrmDefaultSizeX * ProportionX), (int)(SrmDefaultSizeY * ProportionY));
|
pBSrm7.Size = new System.Drawing.Size((int)(SrmDefaultSizeX * ProportionX), (int)(SrmDefaultSizeY * ProportionY));
|
pBSrm8.Size = new System.Drawing.Size((int)(SrmDefaultSizeX * ProportionX), (int)(SrmDefaultSizeY * ProportionY));
|
pBSrm9.Size = new System.Drawing.Size((int)(SrmDefaultSizeX * ProportionX), (int)(SrmDefaultSizeY * ProportionY));
|
|
pBRgv1.Size = new System.Drawing.Size((int)(RgvDefaultSizeX * ProportionX), (int)(RgvDefaultSizeY * ProportionY));
|
pBRgv2.Size = new System.Drawing.Size((int)(RgvDefaultSizeX * ProportionX), (int)(RgvDefaultSizeY * ProportionY));
|
pBRgv3.Size = new System.Drawing.Size((int)(RgvDefaultSizeX * ProportionX), (int)(RgvDefaultSizeY * ProportionY));
|
pBRgv4.Size = new System.Drawing.Size((int)(RgvDefaultSizeX * ProportionX), (int)(RgvDefaultSizeY * ProportionY));
|
|
SetSrmItem(pSrm1);
|
SetSrmItem(pSrm2);
|
SetSrmItem(pSrm3);
|
SetSrmItem(pSrm4);
|
SetSrmItem(pSrm5);
|
SetSrmItem(pSrm6);
|
SetSrmItem(pSrm7);
|
SetSrmItem(pSrm8);
|
SetSrmItem(pSrm9);
|
|
SetRgvItem(pRgv1);
|
SetRgvItem(pRgv2);
|
SetRgvItem(pRgv3);
|
SetRgvItem(pRgv4);
|
}
|
|
private void _2Dshow_SizeChanged(object sender, EventArgs e)
|
{
|
sizeChange=true;
|
}
|
|
private void _2Dshow_FormClosed(object sender, FormClosedEventArgs e)
|
{
|
threadRe1.Abort();
|
threadRe2.Abort();
|
threadRe3.Abort();
|
threadRe4.Abort();
|
threadRe5.Abort();
|
threadRe6.Abort();
|
threadRe7.Abort();
|
threadRe8.Abort();
|
threadRe9.Abort();
|
|
threadReRgv1.Abort();
|
threadReRgv2.Abort();
|
threadReRgv3.Abort();
|
threadReRgv4.Abort();
|
|
threadChangeSize.Abort();
|
}
|
|
private void panel1_Paint(object sender, PaintEventArgs e)
|
{
|
|
}
|
}
|
}
|