namespace OINA.Extender.WPF.Testharness { using System.Collections.Specialized; using System.Linq; using System.Windows; /// /// Interaction logic for AutoIdSettings.xaml /// public partial class AutoIdSettings : Window { /// /// Auto ID Settings form constructor /// public AutoIdSettings() { this.InitializeComponent(); this.periodicTableAutoID.IncludeElements(OIHelper.AutoIdSettings.KnownElements.ToArray()); this.periodicTableAutoID.ExcludeElements(OIHelper.AutoIdSettings.ExcludedElements.ToArray()); this.periodicTableAutoID.EnableElements(false, OIHelper.AutoIdSettings.DisabledElements.ToArray()); ((INotifyCollectionChanged)this.periodicTableAutoID.ExcludedElements).CollectionChanged += this.PeriodicTableExcludedElements_CollectionChanged; ((INotifyCollectionChanged)this.periodicTableAutoID.IncludedElements).CollectionChanged += this.PeriodicTableIncludedElements_CollectionChanged; } /// /// PeriodicTableIncludedElements Collection Changed Event Handler /// /// sender /// EventArgs private void PeriodicTableIncludedElements_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (int element in e.NewItems.Cast()) { OIHelper.AutoIdSettings.SetKnownElement(element, true); } break; case NotifyCollectionChangedAction.Remove: foreach (int element in e.OldItems.Cast()) { OIHelper.AutoIdSettings.SetKnownElement(element, false); } break; default: break; } } /// /// PeriodicTableExcludedElements Collection Changed Event Handler /// /// sender /// EventArgs private void PeriodicTableExcludedElements_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (int elements in e.NewItems.Cast()) { OIHelper.AutoIdSettings.SetExcludedElement(elements, true); } break; case NotifyCollectionChangedAction.Remove: foreach (int elements in e.OldItems.Cast()) { OIHelper.AutoIdSettings.SetExcludedElement(elements, false); } break; default: break; } } } }