AutoIDSettings.cs 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. namespace OINA.Extender.Testharness
  2. {
  3. using System.Collections.Specialized;
  4. using System.Linq;
  5. using System.Windows.Forms;
  6. using OINA.Extender.Controls;
  7. /// <summary>
  8. /// Auto Id Settings form
  9. /// </summary>
  10. public partial class AutoIdSettings : Form
  11. {
  12. /// <summary>
  13. /// Periodic table for Auto ID setting
  14. /// </summary>
  15. private PeriodicTableControl periodicTableAutoId = null;
  16. /// <summary>
  17. /// Auto ID Settings form constructor
  18. /// </summary>
  19. public AutoIdSettings()
  20. {
  21. this.InitializeComponent();
  22. this.periodicTableAutoId = new PeriodicTableControl();
  23. this.ehPeriodicTableAutoId.Child = this.periodicTableAutoId;
  24. this.periodicTableAutoId.IncludeElements(OIHelper.AutoIdSettings.KnownElements.ToArray<int>());
  25. this.periodicTableAutoId.ExcludeElements(OIHelper.AutoIdSettings.ExcludedElements.ToArray<int>());
  26. this.periodicTableAutoId.EnableElements(false, OIHelper.AutoIdSettings.DisabledElements.ToArray<int>());
  27. ((INotifyCollectionChanged)this.periodicTableAutoId.ExcludedElements).CollectionChanged += this.PeriodicTableExcludedElements_CollectionChanged;
  28. ((INotifyCollectionChanged)this.periodicTableAutoId.IncludedElements).CollectionChanged += this.PeriodicTableIncludedElements_CollectionChanged;
  29. }
  30. /// <summary>
  31. /// PeriodicTableIncludedElements Collection Changed Event Handler
  32. /// </summary>
  33. /// <param name="sender">sender</param>
  34. /// <param name="e">EventArgs</param>
  35. private void PeriodicTableIncludedElements_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
  36. {
  37. switch (e.Action)
  38. {
  39. case NotifyCollectionChangedAction.Add:
  40. foreach (int element in e.NewItems.Cast<int>())
  41. {
  42. OIHelper.AutoIdSettings.SetKnownElement(element, true);
  43. }
  44. break;
  45. case NotifyCollectionChangedAction.Remove:
  46. foreach (int element in e.OldItems.Cast<int>())
  47. {
  48. OIHelper.AutoIdSettings.SetKnownElement(element, false);
  49. }
  50. break;
  51. default:
  52. break;
  53. }
  54. }
  55. /// <summary>
  56. /// PeriodicTableExcludedElements Collection Changed Event Handler
  57. /// </summary>
  58. /// <param name="sender">sender</param>
  59. /// <param name="e">EventArgs</param>
  60. private void PeriodicTableExcludedElements_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
  61. {
  62. switch (e.Action)
  63. {
  64. case NotifyCollectionChangedAction.Add:
  65. foreach (int elements in e.NewItems.Cast<int>())
  66. {
  67. OIHelper.AutoIdSettings.SetExcludedElement(elements, true);
  68. }
  69. break;
  70. case NotifyCollectionChangedAction.Remove:
  71. foreach (int elements in e.OldItems.Cast<int>())
  72. {
  73. OIHelper.AutoIdSettings.SetExcludedElement(elements, false);
  74. }
  75. break;
  76. default:
  77. break;
  78. }
  79. }
  80. }
  81. }