/// <summary> /// This method reads the user input properties from a configuration file to the Generator class instance.. /// </summary> /// <param name="path"></param> /// <returns></returns> public static List<GeneratorProperty<double>> Read(string path) { var final = new List<GeneratorProperty<double>>(); try { // Create an XML reader for this file. using (var reader = XmlReader.Create(path)) { while (reader.Read()) { if (reader.Name == "GeneratorProperty") { var value = 0.0; var min = 0.0; var max = 0.0; while (reader.Read()) { if (reader.Name == "Name") { reader.Read(); var name = reader.Value; while (reader.Read()) { if (reader.Name == "Value") { reader.Read(); value = double.Parse(reader.Value); break; } if (reader.Name == "Min") { reader.Read(); min = double.Parse(reader.Value); break; } if (reader.Name == "Max") { reader.Read(); max = double.Parse(reader.Value); break; } } var temp = new GeneratorProperty<double>(name, value, min, max); Debug.WriteLine("Property Name: " + temp.Name + " Value: " + temp.Value + " Min: " + temp.Min + " Max: " + temp.Max); final.Add(temp); break; } } } } } } catch (Exception ex) { MessageBox.Show("Error while reading configuration file: " + ex.Message); } Debug.WriteLine("Properties read from XML: " + final.Count); return final; }
set => SetValue(GeneratorProperty, value);
/// <summary> /// This method acts as a wrapper to easy assign GeneratorProperty values to a NumericUpDown control /// </summary> /// <param name="num"></param> /// <param name="prop"></param> private static void SetUserInputControl(NumericUpDown num, GeneratorProperty<double> prop) { num.Minimum = (decimal) prop.Min; num.Maximum = (decimal) prop.Max; num.Value = (decimal) prop.Value; }