private void AddMacro_Click(object sender, EventArgs e)
        {
            MacroConfiguration macro = new MacroConfiguration(this);

            panel_macro.Controls.Add(macro);
            macro.BringToFront();
            macro.Dock = DockStyle.Top;
            macroConfigurations.Add(macro);
        }
        public void DeleteMacro(MacroConfiguration m)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to delete this macro?", "Alert", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                macroConfigurations.Remove(m);
                panel_macro.Controls.Remove(m);
            }
        }
 public bool IsNameUnique(string name, MacroConfiguration macroconf)
 {
     foreach (MacroConfiguration mconf in macroConfigurations)
     {
         if (mconf.MacroName.Text == name && macroconf != mconf)
         {
             return(false);
         }
     }
     return(true);
 }
        public Configurations()
        {
            macros = new List <Macro>();
            macroConfigurations = new List <MacroConfiguration>();
            //Configuration of the server

            //ip = Dns.GetHostEntry(serverIP).AddressList[0];
            //server = new TcpListener(ip, port);
            //client = default(TcpClient);

            //try
            //{
            //    server.Start();
            //    Debug.WriteLine("Server started...");
            //}
            //catch (Exception e)
            //{
            //    Debug.WriteLine(e.ToString());
            //}

            //backgroundWorker1.RunWorkerAsync();

            if (File.Exists(savePath))
            {
                macro_json = File.ReadAllText(savePath);
                macros     = JsonConvert.DeserializeObject <List <Macro> >(macro_json);
            }

            InitializeComponent();

            if (macros != null)
            {
                foreach (Macro macro in macros)
                {
                    MacroConfiguration macroconfig = new MacroConfiguration(this);
                    macroconfig.MacroName.Text            = macro.Name;
                    macroconfig.MacroExecutable.Text      = macro.Excecutable;
                    macroconfig.MacroTrigger.SelectedItem = macro.Trigger;
                    macroConfigurations.Add(macroconfig);
                    panel_macro.Controls.Add(macroconfig);
                    macroconfig.BringToFront();
                    macroconfig.Dock = DockStyle.Top;
                }
            }
        }