private void TabControler_SelectedIndexChanged(object sender, EventArgs e) { UnselectAll(PreviousSelectedTab); PreviousSelectedTab = tabControler.SelectedIndex; if (parent != null) { BTN_ADD_SECTION.Hide(); BTN_ADD_MACRO.Hide(); BTN_DEL_MACRO.Hide(); } else { BTN_ADD_SECTION.Show(); if (tabControler.TabPages[tabControler.SelectedIndex].Text.StartsWith("_") == true) { BTN_ADD_MACRO.Show(); BTN_DEL_MACRO.Show(); } else { BTN_ADD_MACRO.Hide(); BTN_DEL_MACRO.Hide(); } } }
public MacrosManager(Form1 parent = null) { FilePath = Program.configDirectory + "\\macros.json"; this.parent = parent; InitializeComponent(); if (parent != null) { BTN_ADD_SECTION.Hide(); BTN_ADD_MACRO.Hide(); BTN_DEL_MACRO.Hide(); } else { BTN_ADD_MACRO.Hide(); BTN_DEL_MACRO.Hide(); BTN_VALID_SELECTION.Text = "Enregistrer Tout"; } BTN_ADD_SECTION.Click += BTN_ADD_SECTION_Click; BTN_ADD_MACRO.Click += BTN_ADD_MACRO_Click; BTN_DEL_MACRO.Click += BTN_DEL_MACRO_Click; BTN_VALID_SELECTION.Click += BTN_VALID_SELECTION_Click; string macrofile = System.IO.File.ReadAllText(FilePath); MacroList = JObject.Parse(macrofile); tabControler.TabPages.Clear(); tabControler.SelectedIndexChanged += TabControler_SelectedIndexChanged; TableLayoutPanel pan = null; foreach (JToken section in MacroList["sections"].ToList <JToken>()) { pan = NewTab(section["name"].Value <string>()); IList <string> keys = section["macros"].Value <JObject>().Properties().Select(p => p.Name).ToList(); foreach (string key in keys) { CreateLine(pan, section["macros"][key], key); } } }