Browse Source

Make the buttons work!

Douglas Thrift 9 years ago
parent
commit
272ad05fa8

+ 3 - 0
ssh-handler/HandlerSettingsBox.xaml

@@ -9,9 +9,12 @@
             GroupName="Handlers"
             Name="HandlerRadioButton"
             Content="Handler"
+            Checked="HandlerRadioButton_Checked"
+            Unchecked="HandlerRadioButton_Unchecked"
             />
     </GroupBox.Header>
     <StackPanel
         Name="SettingsPanel"
+        IsEnabled="False"
         />
 </GroupBox>

+ 11 - 1
ssh-handler/HandlerSettingsBox.xaml.cs

@@ -30,7 +30,7 @@ public partial class HandlerSettingsBox : GroupBox
         InitializeComponent();
 
         this.handler = handler;
-        HandlerRadioButton.Content = handler.Setting.name;
+        HandlerRadioButton.Content = handler.Setting.usage;
 
         foreach (Setting setting in handler.Settings)
             switch (setting.type)
@@ -46,4 +46,14 @@ public partial class HandlerSettingsBox : GroupBox
                 break;
             }
     }
+
+    private void HandlerRadioButton_Checked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingsPanel.IsEnabled = true;
+    }
+
+    private void HandlerRadioButton_Unchecked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingsPanel.IsEnabled = false;
+    }
 }

+ 15 - 7
ssh-handler/OptionalExecutablePanel.xaml

@@ -17,13 +17,21 @@
         <CheckBox
             Name="SettingCheckBox"
             Content="Executable:"
+            Checked="SettingCheckBox_Checked"
+            Unchecked="SettingCheckBox_Unchecked"
             />
-        <toolkit:AutoCompleteBox
-            Name="SettingExecutableBox"
-            />
-        <Button
-            Name="SettingExecutableBrowse"
-            Content="Browse..."
-            />
+        <StackPanel
+            Name="SettingExecutablePanel"
+            Orientation="Horizontal"
+            IsEnabled="False"
+            >
+            <toolkit:AutoCompleteBox
+                Name="SettingExecutableBox"
+                />
+            <Button
+                Name="SettingExecutableBrowse"
+                Content="Browse..."
+                />
+        </StackPanel>
     </StackPanel>
 </StackPanel>

+ 15 - 2
ssh-handler/OptionalExecutablePanel.xaml.cs

@@ -31,9 +31,22 @@ public partial class OptionalExecutablePanel : StackPanel
 
         this.setting = setting;
 
-        if (!setting.handler)
+        if (setting.handler)
+            SettingUsage.Text = "Use a specific executable for " + setting.name + ":";
+        else
+        {
             SettingCheckBox.Content = setting.name + " Executable:";
+            SettingUsage.Text = setting.usage + ":";
+        }
+    }
 
-        SettingUsage.Text = setting.usage + ":";
+    private void SettingCheckBox_Checked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingExecutablePanel.IsEnabled = true;
+    }
+
+    private void SettingCheckBox_Unchecked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingExecutablePanel.IsEnabled = false;
     }
 }

+ 36 - 19
ssh-handler/OptionalYesNoDirectoryPanel.xaml

@@ -16,26 +16,43 @@
         >
         <CheckBox
             Name="SettingCheckBox"
-            Content="Executable:"
-            />
-        <RadioButton
-            Name="SettingYes"
-            Content="Yes"
-            />
-        <RadioButton
-            Name="SettingNo"
-            Content="No"
-            />
-        <RadioButton
-            Name="SettingDirectory"
             Content="Directory:"
+            Checked="SettingCheckBox_Checked"
+            Unchecked="SettingCheckBox_Unchecked"
             />
-        <toolkit:AutoCompleteBox
-            Name="SettingDirectoryBox"
-            />
-        <Button
-            Name="SettingDirectoryBrowse"
-            Content="Browse..."
-            />
+        <StackPanel
+            Name="SettingRadioPanel"
+            Orientation="Horizontal"
+            IsEnabled="False"
+            >
+            <RadioButton
+                Name="SettingYes"
+                Content="Yes"
+                IsChecked="True"
+                />
+            <RadioButton
+                Name="SettingNo"
+                Content="No"
+                />
+            <RadioButton
+                Name="SettingDirectory"
+                Content="Directory:"
+                Checked="SettingDirectory_Checked"
+                Unchecked="SettingDirectory_Unchecked"
+                />
+            <StackPanel
+                Name="SettingDirectoryPanel"
+                Orientation="Horizontal"
+                IsEnabled="False"
+                >
+                <toolkit:AutoCompleteBox
+                    Name="SettingDirectoryBox"
+                    />
+                <Button
+                    Name="SettingDirectoryBrowse"
+                    Content="Browse..."
+                    />
+            </StackPanel>
+        </StackPanel>
     </StackPanel>
 </StackPanel>

+ 20 - 3
ssh-handler/OptionalYesNoDirectoryPanel.xaml.cs

@@ -30,10 +30,27 @@ public partial class OptionalYesNoDirectoryPanel : StackPanel
         InitializeComponent();
 
         this.setting = setting;
+        SettingCheckBox.Content = setting.name + ":";
+        SettingUsage.Text = setting.usage + ":";
+    }
 
-        if (!setting.handler)
-            SettingCheckBox.Content = setting.name + ":";
+    private void SettingCheckBox_Checked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingRadioPanel.IsEnabled = true;
+    }
 
-        SettingUsage.Text = setting.usage + ":";
+    private void SettingCheckBox_Unchecked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingRadioPanel.IsEnabled = false;
+    }
+
+    private void SettingDirectory_Checked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingDirectoryPanel.IsEnabled = true;
+    }
+
+    private void SettingDirectory_Unchecked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingDirectoryPanel.IsEnabled = false;
     }
 }

+ 36 - 19
ssh-handler/OptionalYesNoExecutablePanel.xaml

@@ -17,25 +17,42 @@
         <CheckBox
             Name="SettingCheckBox"
             Content="Executable:"
+            Checked="SettingCheckBox_Checked"
+            Unchecked="SettingCheckBox_Unchecked"
             />
-        <RadioButton
-            Name="SettingYes"
-            Content="Yes"
-            />
-        <RadioButton
-            Name="SettingNo"
-            Content="No"
-            />
-        <RadioButton
-            Name="SettingExecutable"
-            Content="Executable:"
-            />
-        <toolkit:AutoCompleteBox
-            Name="SettingExecutableBox"
-            />
-        <Button
-            Name="SettingExecutableBrowse"
-            Content="Browse..."
-            />
+        <StackPanel
+            Name="SettingRadioPanel"
+            Orientation="Horizontal"
+            IsEnabled="False"
+            >
+            <RadioButton
+                Name="SettingYes"
+                Content="Yes"
+                IsChecked="True"
+                />
+            <RadioButton
+                Name="SettingNo"
+                Content="No"
+                />
+            <RadioButton
+                Name="SettingExecutable"
+                Content="Executable:"
+                Checked="SettingExecutable_Checked"
+                Unchecked="SettingExecutable_Unchecked"
+                />
+            <StackPanel
+                Name="SettingExecutablePanel"
+                Orientation="Horizontal"
+                IsEnabled="False"
+                >
+                <toolkit:AutoCompleteBox
+                    Name="SettingExecutableBox"
+                    />
+                <Button
+                    Name="SettingExecutableBrowse"
+                    Content="Browse..."
+                    />
+            </StackPanel>
+        </StackPanel>
     </StackPanel>
 </StackPanel>

+ 20 - 3
ssh-handler/OptionalYesNoExecutablePanel.xaml.cs

@@ -30,10 +30,27 @@ public partial class OptionalYesNoExecutablePanel : StackPanel
         InitializeComponent();
 
         this.setting = setting;
+        SettingCheckBox.Content = setting.name + ":";
+        SettingUsage.Text = setting.usage + ":";
+    }
 
-        if (!setting.handler)
-            SettingCheckBox.Content = setting.name + ":";
+    private void SettingCheckBox_Checked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingRadioPanel.IsEnabled = true;
+    }
 
-        SettingUsage.Text = setting.usage + ":";
+    private void SettingCheckBox_Unchecked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingRadioPanel.IsEnabled = false;
+    }
+
+    private void SettingExecutable_Checked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingExecutablePanel.IsEnabled = true;
+    }
+
+    private void SettingExecutable_Unchecked(object sender, System.Windows.RoutedEventArgs e)
+    {
+        SettingExecutablePanel.IsEnabled = false;
     }
 }

+ 1 - 0
ssh-handler/SettingsDialog.xaml

@@ -23,6 +23,7 @@
                         <RadioButton
                             Content="Find the first suitable SSH application"
                             GroupName="Handlers"
+                            IsChecked="True"
                             />
                     </GroupBox.Header>
                 </GroupBox>

+ 1 - 1
ssh-handler/Shell32.cs

@@ -51,4 +51,4 @@ public static class Shell32
 
     [DllImport("shell32.dll", SetLastError = true)]
     private static extern IntPtr CommandLineToArgvW([MarshalAs(UnmanagedType.LPWStr)] string lpCmdLine, out int pNumArgs);
-}
+}