private SystemConfigModel GetValue(INIDocument doc) { SystemConfigModel config = new SystemConfigModel(); doc.Load(); Type clazz = config.GetType(); foreach (INISection section in doc.Sections) { foreach (INIKey key in section.Keys) { PropertyInfo pi = clazz.GetProperty(key.Name); object value = key.Value; if (pi.PropertyType == typeof(int)) { value = Convert.ToInt32(value); } if (pi != null && !pi.PropertyType.IsGenericType) { pi.SetValue(config, value, null); } } } return(config); }
public VerifiedMail() { if (config == null) { config = new OpporunMailConfig(); INIDocument doc = new INIDocument(path); doc.Load(); Type clazz = config.GetType(); foreach (INISection section in doc.Sections) { foreach (INIKey key in section.Keys) { PropertyInfo pi = clazz.GetProperty(key.Name); object value = key.Value; if (pi.PropertyType == typeof(int)) { value = Convert.ToInt32(value); } if (pi != null && !pi.PropertyType.IsGenericType) { pi.SetValue(config, value, null); } } } } _mailQueue = new Queue <OpporunMail>(); sendThread = new Thread(new ThreadStart(MailSending)); sendThread.Start(); }
private static SystemConfigModel GetConfig() { SystemConfigModel result = new SystemConfigModel(); INIDocument doc = new INIDocument(path); doc.Load(); result = new SystemConfigLoader().GetValue(doc); return(result); }
private static GatewayConfig GetConfig() { GatewayConfig result = new GatewayConfig(); INIDocument doc = new INIDocument(path); doc.Load(); result = new SystemConfigTool().GetValue(doc); return(result); }
public bool Dispose() { try { INIDocument d = new INIDocument(); foreach (Macro m in Macros) { d.SetValue(m.Filename, "Name", m.Name); d.SetValue(m.Filename, "Description", m.Description); } d.Save(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\Notepad X\\Macros\\Macros.ini"); } catch (Exception ex) { MessageBox.Show("Error saving Macro listl: \n" + ex.ToString()); return false; } return true; }
public bool Initialize() { //NotepadX.MainForm.Instance.AddMenuItem(item, path, index); try { viewMacrosItem = new ToolStripMenuItem("View Macros"); viewMacrosItem.Click += delegate(object sender, EventArgs e) { new ViewMacrosForm().ShowDialog(); }; NotepadX.MainForm.Instance.AddMenuItem(viewMacrosItem, "macros", 99); NotepadX.MainForm.Instance.AddMenuItem(new ToolStripMenuItem() { Text = "---------", Enabled = false, Visible = true }, "macros", 1); // add all in Macros folder as menu items if (!Directory.Exists(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\Notepad X\\Macros")) Directory.CreateDirectory(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\Notepad X\\Macros"); // load or create INI file if (!File.Exists(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\Notepad X\\Macros\\Macros.ini")) { using (StreamWriter sw = new StreamWriter(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\Notepad X\\Macros\\Macros.ini")) { sw.WriteLine("[" + System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\Notepad X\\Macros\\SaveAndExitMacro.nxm]"); sw.WriteLine("Name=Save and Exit"); sw.WriteLine("Description=Saves and exits Notepad X"); sw.Close(); } } INIDocument doc = new INIDocument(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + "\\Notepad X\\Macros\\Macros.ini"); foreach (string sname in doc.SectionNames) { // get Name (and Description?) string name = doc[sname]["Name"]; ToolStripMenuItem i = new ToolStripMenuItem(name); i.Tag = sname; // filename i.Click += delegate { NotepadX.MainForm.Instance.RunMacro(File.ReadAllText(sname)); MessageBox.Show("ran macro: " + sname); }; if (!string.IsNullOrEmpty(i.Text)) NotepadX.MainForm.Instance.AddMenuItem(i, "macros", 3); Macros.Add(new Macro(sname, doc[sname]["Description"], doc[sname]["Name"])); } // weird glitch, but it must go. Macros.RemoveAt(0); } catch (Exception ex) { MessageBox.Show("Error starting macro expansions: " + ex.ToString()); } return true; }