123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace IntelligentControlForsx.Code
- {
- public class PanelMessage
- {
- readonly static ConcurrentDictionary<string, TableLayoutPanel> Panels = new ConcurrentDictionary<string, TableLayoutPanel>();
- static Thread T;
- public static void AddPanel(TableLayoutPanel panels)
- {
- Panels.TryAdd(panels.Name, panels);
- }
- public static void DeletePanel(TableLayoutPanel panels)
- {
- Panels.TryRemove(panels.Name, out panels);
- }
- public static void SetBackColorTest()
- {
- T = new Thread(SetPanelText);
- T.IsBackground = true;
- T.Start();
- }
- public static void SetPanelText()
- {
- while (true)
- {
- Console.WriteLine(Panels.Count);
- foreach (TableLayoutPanel l in Panels.Values)
- {
- if (l.Tag == null)
- {
- Console.WriteLine("1");
- }
- if (CommunalTarget.UdpDoubleMemory.ContainsKey(((MyKeyValue<string, int>)l.Tag).Key))
- {
- Action action1 = () =>
- {
- GetBackColor(l, (int)CommunalTarget.UdpDoubleMemory[((MyKeyValue<string, int>)l.Tag).Key]);
- ((MyKeyValue<string, int>)l.Tag).Value = (int)CommunalTarget.UdpDoubleMemory[((MyKeyValue<string, int>)l.Tag).Key];
- };
- if (l.IsHandleCreated)
- {
- try
- {
- l.Invoke(action1);
- }
- catch (Exception e)
- {
- Console.WriteLine(e.Message);
- break;
- }
- }
- }
- }
- Thread.Sleep(1000);
- }
- }
- private static void GetBackColor(TableLayoutPanel panel,int Color)
- {
- switch (Color)
- {
- case 0:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(36)))), ((int)(((byte)(161)))), ((int)(((byte)(58)))));
- break;
- }
- case 1:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(36)))), ((int)(((byte)(161)))), ((int)(((byte)(58)))));
- break;
- }
- case 2:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(165)))), ((int)(((byte)(219)))));
- break;
- }
- case 3:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(165)))), ((int)(((byte)(219)))));
- break;
- }
- case 4:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(177)))), ((int)(((byte)(14)))), ((int)(((byte)(126)))));
- break;
- }
- case 5:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(177)))), ((int)(((byte)(14)))), ((int)(((byte)(126)))));
- break;
- }
- case 6:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(203)))), ((int)(((byte)(32)))), ((int)(((byte)(32)))));
- break;
- }
- case 7:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(203)))), ((int)(((byte)(32)))), ((int)(((byte)(32)))));
- break;
- }
- case 8:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(120)))), ((int)(((byte)(0)))));
- break;
- }
- case 9:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(120)))), ((int)(((byte)(0)))));
- break;
- }
- case 10:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
- break;
- }
- case 11:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
- break;
- }
- case 12:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(146)))), ((int)(((byte)(156)))), ((int)(((byte)(163)))));
- break;
- }
- default:
- {
- panel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(0)))), ((int)(((byte)(64)))));
- break;
- }
- }
- }
- }
- }
|