AutoIdSettings.xaml.cs 3.1 KB

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