| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 | using IMCS.Config;using IMCS.DefaultList;using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using YG;namespace IMCS.UControl{    public partial class UserControl5 : UserControl    {        public System.ComponentModel.BindingList<WeiLiTaskDefaultList> CurrentTask = new BindingList<WeiLiTaskDefaultList>();        bool Run = false;        short StartIndex = 0;        short EndIndex = 0;        IMCS.Logic.WeiLiHandle weiLi;        public UserControl5()        {            InitializeComponent();            this.Load += (s, e) =>            {                Init();                Label_SetColor(new int[] { 1, 4, 5, 20, 9 });                //this.uctrl_Boot.Click += (t, k) => { };                //this.uctl_agvh.Click += (t, k) => { };                //this.uctl_agvl.Click += (t, k) => { };                //this.uctl_clean.Click += (t, k) => { };                //this.uctl_machine.Click += (t, k) => { };                //this.uctl_print.Click += (t, k) => { };                //this.uctrl_Boot.MouseDown += new MouseEventHandler(Uctrl_Boot_MouseDown);                //this.uctrl_Boot.DragEnter += new DragEventHandler(Uctrl_Boot_DragEnter);                //this.uctrl_Boot.DragDrop += new DragEventHandler(Uctrl_Boot_DragDrop);                //this.uctl_agvh.MouseDown += new MouseEventHandler(Uctrl_Boot_MouseDown);                //this.uctl_agvh.DragEnter += new DragEventHandler(Uctrl_Boot_DragEnter);                //this.uctl_agvh.DragDrop += new DragEventHandler(Uctrl_Boot_DragDrop); ;                //this.uctl_agvl.MouseDown += new MouseEventHandler(Uctrl_Boot_MouseDown);                //this.uctl_agvl.DragEnter += new DragEventHandler(Uctrl_Boot_DragEnter);                //this.uctl_agvl.DragDrop += new DragEventHandler(Uctrl_Boot_DragDrop);                //this.uctl_clean.MouseDown += new MouseEventHandler(Uctrl_Boot_MouseDown);                //this.uctl_clean.DragEnter += new DragEventHandler(Uctrl_Boot_DragEnter);                //this.uctl_clean.DragDrop += new DragEventHandler(Uctrl_Boot_DragDrop);                //this.uctl_machine.MouseDown += new MouseEventHandler(Uctrl_Boot_MouseDown);                //this.uctl_machine.DragEnter += new DragEventHandler(Uctrl_Boot_DragEnter);                //this.uctl_machine.DragDrop += new DragEventHandler(Uctrl_Boot_DragDrop); ;                //this.uctl_print.MouseDown += new MouseEventHandler(Uctrl_Boot_MouseDown);                //this.uctl_print.DragEnter += new DragEventHandler(Uctrl_Boot_DragEnter);                //this.uctl_print.DragDrop += new DragEventHandler(Uctrl_Boot_DragDrop); ;                //this.uctl_agvh.UserControlMouseDown += new UserControlBase.Delegate_MouseDownTag(Uctl_agvh_UserControlMouseDown);                //this.uctrl_Boot.UserControlMouseDown += new UserControlBase.Delegate_MouseDownTag(Uctl_agvh_UserControlMouseDown);                //this.uctl_print.UserControlMouseDown += new UserControlBase.Delegate_MouseDownTag(Uctl_agvh_UserControlMouseDown);                //this.uctl_clean.UserControlMouseDown += new UserControlBase.Delegate_MouseDownTag(Uctl_agvh_UserControlMouseDown);                //this.uctl_machine.UserControlMouseDown += new UserControlBase.Delegate_MouseDownTag(Uctl_agvh_UserControlMouseDown);                this.SizeChanged += (t, k) =>                {                    this.tableLayoutPanel3.SetRowSpan(this.uctrl_Boot, 5);                    var cc = (this.pan_botton.Width) - this.tableLayoutPanel1.Width;                    if (cc > 500)                    {                        this.tableLayoutPanel1.Width += 300;                        this.pan_botton.Padding = new Padding(0, 0, 100, 0);                    }                    else if (cc < 100)                    {                        this.tableLayoutPanel1.Width -= 300;                        this.pan_botton.Padding = new Padding(0, 0, 0, 0);                    }                };            };        }        private void Uctl_agvh_UserControlMouseDown(int value)        {        }        private void Uctrl_Boot_MouseDown(object sender, MouseEventArgs e)        {            UserControlBase userControl = sender as UserControlBase;            if ((e.Button == System.Windows.Forms.MouseButtons.Left))            {                System.Console.WriteLine($"Uctrl_Boot_MouseDown;=>{userControl.Tag}--->.{userControl.Name}");                userControl.DoDragDrop(userControl, DragDropEffects.Copy | DragDropEffects.Move);                //形成拖拽效果,移动+拷贝的组合效果                 }            else if (e.Button.Equals(MouseButtons.Right))            {                Point pt = new Point();                pt.Offset(e.Location.X, e.Location.Y);                userControl.popupMenu1.ShowPopup(Control.MousePosition);            }        }        private void Uctrl_Boot_DragDrop(object sender, DragEventArgs e)        {            UserControlBase userControl = sender as UserControlBase;            UserControlBase userControl1 = e.Data as UserControlBase;            System.Console.WriteLine($"EndIndex;=>{userControl.UserTag}--->{userControl.Name}");            userControl.DoDragDrop(userControl, DragDropEffects.None);        }        private void Uctrl_Boot_DragEnter(object sender, DragEventArgs e)        {            UserControlBase userControl = sender as UserControlBase;            StartIndex = userControl.UserTag;            e.Effect = DragDropEffects.Copy;            System.Console.WriteLine($"startindex;=>{StartIndex}");        }        private void Write_Plc(short taskid, short start, short end, short operatio)        {            weiLi.DeviceSend("DB200.44", taskid);            weiLi.DeviceSend("DB200.46", start);            weiLi.DeviceSend("DB200.48", end);            weiLi.DeviceSend("DB200.50", operatio);        }        private void Label_DragDrop(object sender, DragEventArgs e)        {            Label lb = (Label)sender;            EndIndex = (short)lb.Tag.ObjectToInt();            var cc = (Label)e.Data.GetData(typeof(Label));            StartIndex = cc.Tag.ObjectToShort();            Run = false;            int currentTaskCount = CurrentTask.Where(m => m.Task_StartIndex.Equals(StartIndex) && m.Task_EndIndex.Equals(EndIndex) && m.Task_GameOver).Count();            if (currentTaskCount > 0)            {                System.Windows.Forms.MessageBox.Show("当前任务列表中存在和拖拽内容相似的任务,当前拖拽不执行");            }            else            {                short item = 0;                if (StartIndex.Equals(124) || StartIndex.Equals(125))                {                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = EndIndex, Task_Operation = 7, Task_Type = TaskType.移动, Task_StartIndex = StartIndex });                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = EndIndex, Task_Operation = 1, Task_StartIndex = StartIndex, Task_Type = TaskType.取 });                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = EndIndex, Task_Operation = 4, Task_StartIndex = StartIndex, Task_Type = TaskType.放 });                }                else if (EndIndex.Equals(124) || EndIndex.Equals(125))                {                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = StartIndex, Task_Operation = 7, Task_Type = TaskType.移动, Task_StartIndex = StartIndex });                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = EndIndex, Task_Operation = 1, Task_StartIndex = StartIndex, Task_Type = TaskType.取 });                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = EndIndex, Task_Operation = 4, Task_StartIndex = StartIndex, Task_Type = TaskType.放 });                }                else                {                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = StartIndex, Task_Operation = 7, Task_Type = TaskType.移动, Task_StartIndex = StartIndex });                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = EndIndex, Task_Operation = 1, Task_StartIndex = StartIndex, Task_Type = TaskType.取 });                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = 124, Task_Operation = 4, Task_StartIndex = StartIndex, Task_Type = TaskType.放 });                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = EndIndex, Task_Operation = 7, Task_Type = TaskType.移动, Task_StartIndex = StartIndex });                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = EndIndex, Task_Operation = 1, Task_StartIndex = 124, Task_Type = TaskType.取 });                    CurrentTask.Add(new WeiLiTaskDefaultList() { Task_Index = CurrentTask.Count + 1, Task_EndIndex = EndIndex, Task_Operation = 4, Task_StartIndex = StartIndex, Task_Type = TaskType.放 });                }            }        }        private void Init()        {            #region AGV接驳位H            uctl_agvh.deviceStateDefaultList.Device_Name = "AGV接驳位-H";            uctl_agvh.deviceStateDefaultList.Device_OnLine = true;            uctl_agvh.deviceStateDefaultList.Device_ConnectionMes = true;            uctl_agvh.deviceStateDefaultList.Device_Runing = DefaultList.EnumDeviceRunState.RunState_Run;            uctl_agvh.deviceStateDefaultList.Device_Pan = DefaultList.EnumPlateNum.Plate_Zero;            #endregion            #region AGV接驳位-L            uctl_agvl.deviceStateDefaultList.Device_Name = "AGV接驳位-L";            uctl_agvl.deviceStateDefaultList.Device_OnLine = true;            uctl_agvl.deviceStateDefaultList.Device_ConnectionMes = true;            uctl_agvl.deviceStateDefaultList.Device_Runing = DefaultList.EnumDeviceRunState.RunState_Run;            uctl_agvl.deviceStateDefaultList.Device_Pan = DefaultList.EnumPlateNum.Plate_One;            #endregion            #region 柔性线清洗机            uctl_clean.deviceStateDefaultList.Device_Name = "柔性线清洗机";            uctl_clean.deviceStateDefaultList.Device_Pan = DefaultList.EnumPlateNum.Plate_Zero;            uctl_clean.deviceStateDefaultList.Device_OnLine = true;            uctl_clean.deviceStateDefaultList.Device_ConnectionMes = true;            uctl_clean.deviceStateDefaultList.Device_Runing = DefaultList.EnumDeviceRunState.RunState_Run;            #endregion            #region SMU50-5            uctl_machine.deviceStateDefaultList.Device_Name = "SMU50-5";            uctl_machine.deviceStateDefaultList.Device_OnLine = true;            uctl_machine.deviceStateDefaultList.Device_ConnectionMes = true;            uctl_machine.deviceStateDefaultList.Device_Runing = DefaultList.EnumDeviceRunState.RunState_Err;            #endregion            #region 柔性线打标机            uctl_print.deviceStateDefaultList.Device_Name = "柔性线打标机";            uctl_print.deviceStateDefaultList.Device_OnLine = true;            uctl_print.deviceStateDefaultList.Device_ConnectionMes = true;            uctl_print.deviceStateDefaultList.Device_Runing = DefaultList.EnumDeviceRunState.RunState_Run;            #endregion            #region 六轴机器人            uctrl_Boot.deviceStateDefaultList.Device_Name = "六轴机器人";            uctrl_Boot.deviceStateDefaultList.Device_OnLine = true;            uctrl_Boot.deviceStateDefaultList.Device_ConnectionMes = true;            uctrl_Boot.deviceStateDefaultList.Device_Runing = DefaultList.EnumDeviceRunState.RunState_Wait;            #endregion        }        private void Label_SetColor(string tagvalue, bool isonine = true)        {            Control[] cls = this.tableLayoutPanel1.Controls.Find($"lb_{tagvalue}", true);            if (cls.Length > 0)            {                if (isonine)                    cls[0].BackColor = System.Drawing.Color.FromArgb(51, 153, 204);                else                    cls[0].BackColor = System.Drawing.Color.FromArgb(242, 242, 242);            }        }        private void Label_SetColor(int[] vs, bool isonline = true)        {            foreach (var s in vs)            {                Label_SetColor(s.ToString(), isonline);            }        }        private void uctl_agvl_UserControlMouseDown(int value)        {            System.Console.WriteLine($"---uctl_agvl_UserControlMouseDown--->{value}");        }        private void uctl_agvl_UserControlDragDropTag(int value)        {        }    }}
 |