namespace OINA.Extender.Testharness
{
using System.Collections.Specialized;
using System.Linq;
using System.Windows.Forms;
using OINA.Extender.Controls;
///
/// Auto Id Settings form
///
public partial class AutoIdSettings : Form
{
///
/// Periodic table for Auto ID setting
///
private PeriodicTableControl periodicTableAutoId = null;
///
/// Auto ID Settings form constructor
///
public AutoIdSettings()
{
this.InitializeComponent();
this.periodicTableAutoId = new PeriodicTableControl();
this.ehPeriodicTableAutoId.Child = this.periodicTableAutoId;
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;
}
}
}
}