static void Main(string[] args) { try { string configfile = @".\Config1.txt"; if (args.Length >= 1) { configfile = args[0]; } if (Properties.Settings.Default.autoStart) { ConfigurationHandler cfh = new ConfigurationHandler(new FileHandler(configfile)); FileHandler fh = new FileHandler(cfh.ReturnConfig("path")); CNCHandler ch = new CNCHandler(fh.Read()); fh.WriteCNC(ch.ChangeSub(cfh.ReturnConfig("oldhead"), cfh.ReturnConfig("newhead"), cfh.ReturnConfig("oldsub"), cfh.ReturnConfig("newsub"), cfh.ReturnConfig("subref"), cfh.ReturnConfig("subcall"), cfh.ReturnConfig("increment"))); } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FormMain(configfile)); } } catch (Exception) { } }
public void btnStart_Click(object sender, EventArgs e) { try { fh = new FileHandler(cfh.ReturnConfig("path")); ch = new CNCHandler(fh.Read()); fh.WriteCNC(ch.ChangeSub(cfh.ReturnConfig("oldhead"), cfh.ReturnConfig("newhead"), txtOldSub.Text, txtNewSub.Text, txtSubRef.Text, cfh.ReturnConfig("subcall"), cfh.ReturnConfig("increment"))); if (txtFile.Enabled) { cfh.ChangeConfig("path", txtFile.Text); } if (txtOldSub.Enabled) { cfh.ChangeConfig("oldsub", txtOldSub.Text); } if (txtNewSub.Enabled) { cfh.ChangeConfig("newsub", txtNewSub.Text); } if (txtSubRef.Enabled) { cfh.ChangeConfig("subref", txtSubRef.Text); } cfh.SaveChanges(); Application.Exit(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }