SshHandlerSettings.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // SSH Handler Settings
  2. //
  3. // Douglas Thrift
  4. //
  5. // SshHandlerSettings.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.Diagnostics;
  22. using System.Reflection;
  23. using System.Windows;
  24. using System.Windows.Controls;
  25. public partial class SshHandlerSettings : Window
  26. {
  27. public SshHandlerSettings(IList<Handler> handlers)
  28. {
  29. InitializeComponent();
  30. foreach (Handler handler in handlers)
  31. {
  32. GroupBox box = new GroupBox();
  33. RadioButton button = new RadioButton();
  34. StackPanel panel = new StackPanel();
  35. button.Content = handler.Setting.name;
  36. button.GroupName = "Handlers";
  37. foreach (Setting setting in handler.Settings)
  38. panel.Children.Add(ControlForSetting(setting));
  39. box.Header = button;
  40. box.Content = panel;
  41. SettingsPanel.Children.Add(box);
  42. }
  43. }
  44. private void OkButton_Click(object sender, RoutedEventArgs e)
  45. {
  46. Apply();
  47. DialogResult = true;
  48. }
  49. private void ApplyButton_Click(object sender, RoutedEventArgs e)
  50. {
  51. Apply();
  52. }
  53. private void Apply()
  54. {
  55. string program = Assembly.GetEntryAssembly().Location;
  56. string[] arguments = { "/openssh", "/bash" };
  57. Debug.WriteLine("\"{0}\" {1} \"%1\"", program, string.Join(" ", arguments));
  58. }
  59. private UIElement ControlForSetting(Setting setting)
  60. {
  61. Label label = new Label();
  62. label.Content = string.Format("{0} {1}", setting.name, setting.type);
  63. return label;
  64. }
  65. }