| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 | 
							- 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 UserControl1 : UserControl
 
-     {
 
-         bool Run = false;
 
-         short StartIndex = 0;
 
-         short EndIndex = 0;
 
-         IMCS.Logic.WeiLiHandle weiLi;
 
-         public System.ComponentModel.BindingList<WeiLiTaskDefaultList> CurrentTask = new BindingList<WeiLiTaskDefaultList>();
 
-         public UserControl1()
 
-         {
 
-             InitializeComponent();
 
-             this.Load += UserControl1_Load;
 
-         }
 
-         bool isRun = false;
 
-         private void UserControl1_Load(object sender, EventArgs e)
 
-         {
 
-            //weiLi = new Logic.WeiLiHandle();
 
-             //weiLi.DeviceInit();
 
-             //weiLi.DeviceStart();
 
-            // weiLi.Msg += WeiLi_Msg;
 
-            // CurrentTask = DeviceConfig.Instance.WeiLiTask;
 
-             //foreach (control cc in this.tablelayoutpanel1.controls)
 
-             //{
 
-             //    if (cc is label)
 
-             //    {
 
-             //        label lb = (label)cc;
 
-             //        if (!lb.text.equals("控制机柜"))
 
-             //        {
 
-             //            lb.allowdrop = true;
 
-             //            lb.mousedown += new mouseeventhandler(lb_mousedown1);
 
-             //            lb.dragenter += new drageventhandler(label_dragenter);
 
-             //            lb.dragdrop += new drageventhandler(label_dragdrop);
 
-             //            lb.backcolor = system.drawing.color.aliceblue;
 
-             //            lb.textalign = system.drawing.contentalignment.middlecenter;
 
-             //            lb.autosize = false;
 
-             //            lb.width = 60;
 
-             //            lb.height = 60;
 
-             //        }
 
-             //    }
 
-             //}
 
-             //task.factory.startnew(async () =>
 
-             //{
 
-             //    while (true && !isrun)
 
-             //    {
 
-             //        await task.delay(100);
 
-             //        if (currenttask.where(m => !m.task_gameover).count() > 0)
 
-             //        {
 
-             //            currenttask.where(m => !m.task_gameover).firstordefault().firstordefaultyg((t) =>
 
-             //            {
 
-             //                if (!t.task_send)
 
-             //                {
 
-             //                    write_plc((short)t.task_index, t.task_startindex, t.task_endindex, t.task_operation);
 
-             //                    t.task_send = true;
 
-             //                }
 
-             //            });
 
-             //        }
 
-             //    }
 
-             //});
 
-         }
 
-         private void WeiLi_Msg(string obje1, string obje2, string obje3)
 
-         {
 
-             System.Console.WriteLine($"{obje1}-->>{obje2}-->{obje3}");
 
-             if (obje3.Length - obje3.Replace(",", "").Length != 1)
 
-             {
 
-                 MessageBox.Show("接受到的值解析出现问题");
 
-                 return;
 
-             }
 
-             string[] vs = obje3.Split(new string[] { "," }, StringSplitOptions.None);
 
-             short state = vs[1].ObjectToShort();
 
-             CurrentTask.Where(m => m.Task_Index.Equals(vs[0].StringToInt())).FirstOrDefault().FirstOrDefaultYG((t) =>
 
-             {
 
-                 if (t.Task_Type.Equals(TaskType.取) && state == 3)
 
-                 {
 
-                     t.Task_GameOver = true;
 
-                 }
 
-                 else if (t.Task_Type.Equals(TaskType.放) && state == 6)
 
-                 {
 
-                     t.Task_GameOver = true;
 
-                 }
 
-                 else if (t.Task_Type.Equals(TaskType.移动) && state == 8)
 
-                 {
 
-                     t.Task_GameOver = true;
 
-                 }
 
-                 t.Task_RunState = state;
 
-             });
 
-         }
 
-         private void Lb_MouseDown1(object sender, MouseEventArgs e)
 
-         {
 
-             Label startlable = sender as Label;
 
-             if ((e.Button == System.Windows.Forms.MouseButtons.Left))
 
-             {
 
-                 startlable.DoDragDrop(startlable, DragDropEffects.Copy | DragDropEffects.Move);
 
-                 //形成拖拽效果,移动+拷贝的组合效果     
 
-             }
 
-         }
 
-         private void Label_DragEnter(object sender, DragEventArgs e)
 
-         {
 
-             e.Effect = DragDropEffects.Copy;
 
-         }
 
-         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.放 });
 
-                 }
 
-             }
 
-         }
 
-     }
 
- }
 
 
  |