HandlerSettingsBox.xaml.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Handler Settings Box
  2. //
  3. // Douglas Thrift
  4. //
  5. // HandlerSettingsBox.xaml.cs
  6. /* Copyright 2014 Douglas Thrift
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. using System.Collections.Generic;
  21. using System.Windows.Controls;
  22. public partial class HandlerSettingsBox : GroupBox
  23. {
  24. private Handler handler;
  25. public HandlerSettingsBox(Handler handler, IEnumerable<string> options)
  26. {
  27. InitializeComponent();
  28. this.handler = handler;
  29. HandlerRadioButton.Content = handler.Setting.usage;
  30. foreach (Setting setting in handler.Settings)
  31. switch (setting.type)
  32. {
  33. case SettingType.OptionalExecutable:
  34. SettingsPanel.Children.Add(new OptionalExecutablePanel(setting, options));
  35. break;
  36. case SettingType.OptionalYesNoExecutable:
  37. SettingsPanel.Children.Add(new OptionalYesNoExecutablePanel(setting, options));
  38. break;
  39. case SettingType.OptionalYesNoDirectory:
  40. SettingsPanel.Children.Add(new OptionalYesNoDirectoryPanel(setting, options));
  41. break;
  42. }
  43. }
  44. private void HandlerRadioButton_Checked(object sender, System.Windows.RoutedEventArgs e)
  45. {
  46. SettingsPanel.IsEnabled = true;
  47. }
  48. private void HandlerRadioButton_Unchecked(object sender, System.Windows.RoutedEventArgs e)
  49. {
  50. SettingsPanel.IsEnabled = false;
  51. }
  52. }