示例#1
0
 public void UpdateAction(JToken action, TableLayoutPanel pan)
 {
     pan.Tag = action;
     ((Label)pan.Controls[0]).Text = MacroEditor.StringifyAction(action);
     UpdateActionsListByTabCells();
     Debug.WriteLine(JsonConvert.SerializeObject(Data["actions"]));
 }
示例#2
0
 private void BTN_ADD_MACRO_Click(object sender, EventArgs e)
 {
     if (tabControler.TabPages[tabControler.SelectedIndex].Text.StartsWith("_") == true)
     {
         MacroEditor mac = new MacroEditor(this, null);
         mac.ShowDialog();
         mac.Dispose();
     }
 }
示例#3
0
        private void Btn_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            Tab1_Click(btn.Parent, null);
            MacroEditor mac = new MacroEditor(this, (TableLayoutPanel)btn.Parent);

            mac.ShowDialog();
            mac.Dispose();
        }
示例#4
0
 public ActionEditor(MacroEditor macroEditor, TableLayoutPanel panel = null)
 {
     this.macroEditor = macroEditor;
     this.panel       = panel;
     InitializeComponent();
     if (panel != null)
     {
         //tab1.Tag
         JToken action = (JToken)panel.Tag;
         string type   = action["type"].Value <string>();
         if (type == "KeyBoardInput")
         {
             tabControler.SelectedIndex = 0;
             try { TAB1_KEY_BOX.Text = action["key"].Value <string>(); } catch (Exception error) { }
             try { TAB1_CTRL_CHBOX.Checked = action["ctrl"].Value <bool>(); } catch (Exception error) { }
             try { TAB1_ALT_CHBOX.Checked = action["alt"].Value <bool>(); } catch (Exception error) { }
             try { TAB1_MAJ_CHBOX.Checked = action["maj"].Value <bool>(); } catch (Exception error) { }
             try { TAB1_WIN_CHBOX.Checked = action["win"].Value <bool>(); } catch (Exception error) { }
         }
         if (type == "MuteSound" || type == "VolUp" || type == "VolDown")
         {
             tabControler.SelectedIndex = 1;
             if (type == "MuteSound")
             {
                 TAB2_MUTE_RBOX.Checked = true;
             }
             if (type == "VolUp")
             {
                 TAB2_VOLUP_RBOX.Checked = true;
                 try { TAB2_VOLUP_NBOX.Value = action["step"].Value <decimal>(); } catch (Exception error) { }
             }
             if (type == "VolDown")
             {
                 TAB2_VOLDOWN_RBOX.Checked = true;
                 try { TAB2_VOLDOWN_NBOX.Value = action["step"].Value <decimal>(); } catch (Exception error) { }
             }
         }
         if (type == "Execute")
         {
             tabControler.SelectedIndex = 2;
             try { TAB3_APP_BOX.Text = action["executable"].Value <string>(); } catch (Exception error) { }
             try { TAB3_OPT_BOX.Text = action["params"].Value <string>(); } catch (Exception error) { }
         }
         if (type == "Sleep")
         {
             tabControler.SelectedIndex = 3;
             try { TAB4_NBOX.Value = action["delay"].Value <decimal>(); } catch (Exception error) { }
         }
     }
 }
示例#5
0
        private void AddUiActionLine(JToken action, int noline)
        {
            Padding p = new Padding();

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

            p2.All = 4;

            //Debug.WriteLine(JsonConvert.SerializeObject(action));
            string strAction = MacroEditor.StringifyAction(action);

            TableLayoutPanel tab1 = new TableLayoutPanel();

            tab1.SuspendLayout();
            tab1.Name            = "LINE";
            tab1.Tag             = action;
            tab1.BackColor       = Color.White;
            tab1.ForeColor       = Color.Black;
            tab1.Size            = new Size(STB4.Size.Width - 18, 30);
            tab1.ColumnCount     = 4;
            tab1.RowCount        = 1;
            tab1.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
            tab1.ForeColor       = Color.Black;
            tab1.Padding         = p;
            tab1.Margin          = p;
            tab1.Dock            = DockStyle.Top;
            tab1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
            tab1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            tab1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 50F));
            tab1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 50F));

            Label lab = new Label();

            lab.Text      = strAction;
            lab.Dock      = DockStyle.Fill;
            lab.Margin    = p;
            lab.Padding   = p;
            lab.TextAlign = ContentAlignment.MiddleCenter;
            tab1.Controls.Add(lab, 0, 0);

            TableLayoutPanel tab2 = new TableLayoutPanel();

            tab2.SuspendLayout();
            tab2.BackColor       = Color.White;
            tab2.ForeColor       = Color.Black;
            tab2.Size            = new Size(30, 30);
            tab2.ColumnCount     = 1;
            tab2.RowCount        = 2;
            tab2.CellBorderStyle = TableLayoutPanelCellBorderStyle.None;
            tab2.ForeColor       = Color.Black;
            tab2.Padding         = p;
            tab2.Margin          = p;
            tab2.Dock            = DockStyle.Fill;
            tab2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 15F));
            tab2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 15F));

            Button up = new Button();

            up.Text      = "";
            up.Font      = new Font("Segoe MDL2 Assets", 6f);
            up.Margin    = p;
            up.Padding   = p;
            up.Size      = new Size(30, 15);
            up.BackColor = Color.Silver;
            up.Dock      = DockStyle.Fill;
            up.Click    += Up_Click;
            tab2.Controls.Add(up, 0, 0);

            Button down = new Button();

            down.Text      = "";
            down.Font      = new Font("Segoe MDL2 Assets", 6f);
            down.Margin    = p;
            down.Padding   = p;
            down.Size      = new Size(30, 15);
            down.BackColor = Color.Silver;
            down.Dock      = DockStyle.Fill;
            down.Click    += Down_Click;
            tab2.Controls.Add(down, 0, 1);

            tab2.CausesValidation = true;
            tab2.ResumeLayout(true);
            tab1.Controls.Add(tab2, 1, 0);

            Button btn = new Button();

            btn.Text      = "";
            btn.Font      = new Font("Segoe MDL2 Assets", 9f);
            btn.Margin    = p;
            btn.Padding   = p;
            btn.Size      = new Size(50, 30);
            btn.BackColor = Color.Silver;
            btn.Dock      = DockStyle.Fill;
            btn.Click    += Btn_Click;
            tab1.Controls.Add(btn, 2, 0);

            Button btn2 = new Button();

            btn2.Text      = "X";
            btn2.Margin    = p;
            btn2.Padding   = p;
            btn2.Size      = new Size(50, 30);
            btn2.BackColor = Color.Silver;
            btn2.Dock      = DockStyle.Fill;
            btn2.Click    += Btn2_Click;
            tab1.Controls.Add(btn2, 3, 0);

            tab1.CausesValidation = true;
            tab1.ResumeLayout(true);

            STB4.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 30F));
            STB4.Controls.Add(tab1, 0, noline);
            STB4.ResumeLayout(true);
        }
示例#6
0
 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);
     }
 }
示例#7
0
        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);
        }