Browse Source

Get the handler command line from the registry so it can be parsed to get the current settings.

Douglas Thrift 10 năm trước cách đây
mục cha
commit
e09311d8eb

+ 5 - 4
ssh-handler/HandlerSettingsBox.xaml.cs

@@ -19,13 +19,14 @@
  *  limitations under the License.
  *  limitations under the License.
  */
  */
 
 
+using System.Collections.Generic;
 using System.Windows.Controls;
 using System.Windows.Controls;
 
 
 public partial class HandlerSettingsBox : GroupBox
 public partial class HandlerSettingsBox : GroupBox
 {
 {
     private Handler handler;
     private Handler handler;
 
 
-    public HandlerSettingsBox(Handler handler)
+    public HandlerSettingsBox(Handler handler, IEnumerable<string> options)
     {
     {
         InitializeComponent();
         InitializeComponent();
 
 
@@ -36,13 +37,13 @@ public partial class HandlerSettingsBox : GroupBox
             switch (setting.type)
             switch (setting.type)
             {
             {
             case SettingType.OptionalExecutable:
             case SettingType.OptionalExecutable:
-                SettingsPanel.Children.Add(new OptionalExecutablePanel(setting));
+                SettingsPanel.Children.Add(new OptionalExecutablePanel(setting, options));
                 break;
                 break;
             case SettingType.OptionalYesNoExecutable:
             case SettingType.OptionalYesNoExecutable:
-                SettingsPanel.Children.Add(new OptionalYesNoExecutablePanel(setting));
+                SettingsPanel.Children.Add(new OptionalYesNoExecutablePanel(setting, options));
                 break;
                 break;
             case SettingType.OptionalYesNoDirectory:
             case SettingType.OptionalYesNoDirectory:
-                SettingsPanel.Children.Add(new OptionalYesNoDirectoryPanel(setting));
+                SettingsPanel.Children.Add(new OptionalYesNoDirectoryPanel(setting, options));
                 break;
                 break;
             }
             }
     }
     }

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

@@ -19,13 +19,14 @@
  *  limitations under the License.
  *  limitations under the License.
  */
  */
 
 
+using System.Collections.Generic;
 using System.Windows.Controls;
 using System.Windows.Controls;
 
 
 public partial class OptionalExecutablePanel : StackPanel
 public partial class OptionalExecutablePanel : StackPanel
 {
 {
     private Setting setting;
     private Setting setting;
 
 
-    public OptionalExecutablePanel(Setting setting)
+    public OptionalExecutablePanel(Setting setting, IEnumerable<string> options)
     {
     {
         InitializeComponent();
         InitializeComponent();
 
 

+ 2 - 1
ssh-handler/OptionalYesNoDirectoryPanel.xaml.cs

@@ -19,13 +19,14 @@
  *  limitations under the License.
  *  limitations under the License.
  */
  */
 
 
+using System.Collections.Generic;
 using System.Windows.Controls;
 using System.Windows.Controls;
 
 
 public partial class OptionalYesNoDirectoryPanel : StackPanel
 public partial class OptionalYesNoDirectoryPanel : StackPanel
 {
 {
     private Setting setting;
     private Setting setting;
 
 
-    public OptionalYesNoDirectoryPanel(Setting setting)
+    public OptionalYesNoDirectoryPanel(Setting setting, IEnumerable<string> options)
     {
     {
         InitializeComponent();
         InitializeComponent();
 
 

+ 2 - 1
ssh-handler/OptionalYesNoExecutablePanel.xaml.cs

@@ -19,13 +19,14 @@
  *  limitations under the License.
  *  limitations under the License.
  */
  */
 
 
+using System.Collections.Generic;
 using System.Windows.Controls;
 using System.Windows.Controls;
 
 
 public partial class OptionalYesNoExecutablePanel : StackPanel
 public partial class OptionalYesNoExecutablePanel : StackPanel
 {
 {
     private Setting setting;
     private Setting setting;
 
 
-    public OptionalYesNoExecutablePanel(Setting setting)
+    public OptionalYesNoExecutablePanel(Setting setting, IEnumerable<string> options)
     {
     {
         InitializeComponent();
         InitializeComponent();
 
 

+ 17 - 1
ssh-handler/SettingsDialog.xaml.cs

@@ -21,9 +21,11 @@
 
 
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Diagnostics;
+using System.Linq;
 using System.Reflection;
 using System.Reflection;
 using System.Windows;
 using System.Windows;
 using System.Windows.Controls;
 using System.Windows.Controls;
+using Microsoft.Win32;
 
 
 public partial class SettingsDialog : Window
 public partial class SettingsDialog : Window
 {
 {
@@ -31,8 +33,22 @@ public partial class SettingsDialog : Window
     {
     {
         InitializeComponent();
         InitializeComponent();
 
 
+        IEnumerable<string> options = new string[0];
+
+        using (RegistryKey baseKey = RegistryKey.OpenBaseKey(RegistryHive.ClassesRoot, RegistryView.Default), key = baseKey.OpenSubKey(@"ssh\shell\open\command"))
+            if (key != null)
+            {
+                string command = (string)key.GetValue(null);
+                if (!string.IsNullOrWhiteSpace(command))
+                {
+                    var args = Shell32.CommandLineToArgv(command);
+
+                    options = args.Skip(1).TakeWhile(arg => arg != "%1");
+                }
+            }
+
         foreach (Handler handler in handlers)
         foreach (Handler handler in handlers)
-            SettingsPanel.Children.Add(new HandlerSettingsBox(handler));
+            SettingsPanel.Children.Add(new HandlerSettingsBox(handler, options));
     }
     }
 
 
     private void OkButton_Click(object sender, RoutedEventArgs e)
     private void OkButton_Click(object sender, RoutedEventArgs e)