public void SetMacro(string NameOrigin, string Name, JToken data)
 {
     if (NameOrigin != Name && NameOrigin != null)
     {
         JObject jo = MacroList["sections"][tabControler.SelectedIndex]["macros"].Value <JObject>();
         if (jo.ContainsKey(NameOrigin) == true)
         {
             foreach (Control ct in tabControler.TabPages[tabControler.SelectedIndex].Controls[0].Controls)
             {
                 string[] ta = ((string)ct.Tag).Split('/');
                 if (ta[1] == NameOrigin)
                 {
                     foreach (Control li in ct.Controls)
                     {
                         if (li.Name.StartsWith("Btn2_"))
                         {
                             Btn2_Click(li, null);
                         }
                     }
                 }
             }
         }
     }
     MacroList["sections"][tabControler.SelectedIndex]["macros"][Name] = data;
     if (NameOrigin != null)
     {
         foreach (Control ct in tabControler.TabPages[tabControler.SelectedIndex].Controls[0].Controls)
         {
             string[] ta = ((string)ct.Tag).Split('/');
             if (ta[1] == NameOrigin)
             {
                 TableLayoutPanel pt = (TableLayoutPanel)ct;
                 pt.Tag = ta[0] + "/" + Name;
                 foreach (Control li in pt.Controls)
                 {
                     if (li.Name.StartsWith("Lab_"))
                     {
                         li.Tag = ta[0] + "/" + Name; ((Label)li).Text = Name;
                     }
                     if (li.Name.StartsWith("Lab2_"))
                     {
                         li.Tag = ta[0] + "/" + Name;
                         string desc = data["description"].Value <string>();
                         if (desc == "")
                         {
                             ((Label)li).Text = "No Description"; ((Label)li).Font = new Font("Arial", 8f, FontStyle.Italic);
                         }
                         else
                         {
                             ((Label)li).Text = desc; ((Label)li).Font = new Font("Arial", 8f, FontStyle.Regular);
                         }
                     }
                     if (li.Name.StartsWith("Lab3_"))
                     {
                         li.Tag = ta[0] + "/" + Name; ((Label)li).Text = MacroEditor.StringifyAllActions(data);
                     }
                 }
             }
         }
     }
     else
     {
         CreateLine((TableLayoutPanel)tabControler.TabPages[tabControler.SelectedIndex].Controls[0], MacroList["sections"][tabControler.SelectedIndex]["macros"][Name], Name);
     }
 }
        public void CreateLine(TableLayoutPanel pan, JToken data, string Name)
        {
            string  section = pan.Parent.Text;
            Padding p       = new Padding();

            p.All = 0;
            Padding p2 = new Padding();

            p2.All = 4;
            TableLayoutPanel tab1 = new TableLayoutPanel();

            tab1.SuspendLayout();
            tab1.Tag              = section + "/" + Name;
            tab1.Name             = Name;
            tab1.BackColor        = Color.White;
            tab1.ForeColor        = Color.Black;
            tab1.Size             = new Size(pan.Size.Width - 18, 30);
            tab1.ColumnCount      = 3;
            tab1.RowCount         = 1;
            tab1.CellBorderStyle  = TableLayoutPanelCellBorderStyle.Single;
            tab1.ForeColor        = Color.Black;
            tab1.Padding          = p;
            tab1.Margin           = p;
            tab1.Dock             = DockStyle.Top;
            tab1.CausesValidation = true;
            tab1.ColumnStyles.Clear();
            tab1.Click       += Tab1_Click;
            tab1.DoubleClick += Tab1_DoubleClick;

            if (parent == null && section.StartsWith("_") == true)
            {
                tab1.ColumnCount = 6;
                CheckBox box = new CheckBox();
                box.Name      = "Check_" + Name;
                box.Dock      = DockStyle.Fill;
                box.Margin    = p;
                box.Padding   = p2;
                box.TextAlign = ContentAlignment.MiddleCenter;
                box.Click    += Box_Click;
                tab1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
                tab1.Controls.Add(box, 0, 0);
            }

            Label lab = new Label();

            lab.Text         = Name;
            lab.Name         = "Lab_" + Name;
            lab.Dock         = DockStyle.Fill;
            lab.Margin       = p;
            lab.Padding      = p;
            lab.TextAlign    = ContentAlignment.MiddleCenter;
            lab.Click       += Lab_Click;
            lab.DoubleClick += Lab_DoubleClick;
            tab1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100F));
            tab1.Controls.Add(lab, (parent == null && section.StartsWith("_") == true)?1:0, 0);

            Label lab2 = new Label();

            lab2.Name = "Lab2_" + Name;
            string desc = "";

            try { desc = data["description"].Value <string>(); } catch (Exception error) { }
            if (desc != "")
            {
                lab2.Text = desc;
            }
            else
            {
                lab2.Text = "No Description";
                lab2.Font = new Font("Arial", 8f, FontStyle.Italic);
            }

            lab2.Dock         = DockStyle.Fill;
            lab2.Margin       = p;
            lab2.Padding      = p;
            lab2.TextAlign    = ContentAlignment.MiddleCenter;
            lab2.Click       += Lab_Click;
            lab2.DoubleClick += Lab_DoubleClick;
            tab1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 200F));
            tab1.Controls.Add(lab2, (parent == null && section.StartsWith("_") == true)?2:1, 0);

            Label lab3 = new Label();

            lab3.Name         = "Lab3_" + Name;
            lab3.Text         = MacroEditor.StringifyAllActions(data);
            lab3.Dock         = DockStyle.Fill;
            lab3.Margin       = p;
            lab3.Padding      = p;
            lab3.TextAlign    = ContentAlignment.MiddleCenter;
            lab3.Click       += Lab_Click;
            lab3.DoubleClick += Lab_DoubleClick;
            tab1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
            tab1.Controls.Add(lab3, (parent == null && section.StartsWith("_") == true)?3:2, 0);

            if (parent == null && section.StartsWith("_") == true)
            {
                Button btn = new Button();
                btn.Text      = "";
                btn.Font      = new Font("Segoe MDL2 Assets", 9f);
                btn.Margin    = p;
                btn.Padding   = p;
                btn.BackColor = Color.Silver;
                btn.Dock      = DockStyle.Fill;
                btn.Click    += Btn_Click;
                tab1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 50F));
                tab1.Controls.Add(btn, 4, 0);

                Button btn2 = new Button();
                btn2.Name      = "Btn2_" + Name;
                btn2.Text      = "X";
                btn2.Margin    = p;
                btn2.Padding   = p;
                btn2.BackColor = Color.Silver;
                btn2.Dock      = DockStyle.Fill;
                btn2.Click    += Btn2_Click;
                tab1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 50F));
                tab1.Controls.Add(btn2, 5, 0);
            }
            pan.RowCount += 1;
            pan.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            pan.Controls.Add(tab1);
            tab1.ResumeLayout(true);
            pan.ResumeLayout(true);
        }