private void AddRule() { if ((cbSource.SelectedIndex > 0) && (cbTarget.SelectedIndex > 0)) { IsDirty = true; ConversionClass cc = new ConversionClass(); cc.SourceFormat = ((FileFormatClass)cbSource.SelectedItem).Format; cc.TargetFormat = ((FileFormatClass)cbTarget.SelectedItem).Format; cbSource.SelectedIndex = -1; cbTarget.SelectedIndex = -1; ocConversions.Add(cc); } }
public static BindingList <ConversionClass> ConversionRules() { BindingList <ConversionClass> ocConversionRules = new BindingList <ConversionClass>(); // Execute the query using the LINQ to XML var rules = from c in XElement.Load(XMLBuilder.ConversionRuleXml()).Elements("Conversion") select c; foreach (var rule in rules) { ConversionClass cRule = new ConversionClass() { SourceFormat = rule.Element("Source").Value, TargetFormat = rule.Element("Target").Value, IsDefault = true, IsOverridden = false }; ocConversionRules.Add(cRule); } return(ocConversionRules); }