public bool Execute(Key key, params FileSystemInfo[] items) { Tuple <Key, ModifierKeys> tuplekey = new Tuple <Key, ModifierKeys>(key, Keyboard.Modifiers); if (this.Dic.ContainsKey(tuplekey)) { KeyBindItem command = this.Dic[tuplekey]; if (command.Modifiers == Keyboard.Modifiers) { if (command.ExecKbn == EKeyBindExecKbn.External) { //外部コマンド実行 try { StringBuilder sb = new StringBuilder(); for (int i = 0; i < items.Length; i++) { if (i != 0) { sb.Append(" "); } sb.Append(items[i].FullName); } ProcessStartInfo psinfo = new ProcessStartInfo(); psinfo.FileName = command.Command; psinfo.CreateNoWindow = false; psinfo.UseShellExecute = false; psinfo.Arguments = sb.ToString(); Process proc = Process.Start(psinfo); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error); } } else { if (this.InternalKeyBindExecute != null) { this.InternalKeyBindExecute(this, new KeyBindInternalEventArgs(command.InternalKbn)); } } } } return(false); }
private void InitKeyBind() { this.KeyBind = new KeyBind(); this.KeyBind.InternalKeyBindExecute += InternalKeyBindExecute; KeyBindItem item = new KeyBindItem(); item.Command = @"C:\Program Files\Hidemaru\Hidemaru.exe"; item.PushDownKey = Key.E; item.Modifiers = ModifierKeys.None; item.ExecKbn = EKeyBindExecKbn.External; this.KeyBind.AddItem(item); item = new KeyBindItem(); item.PushDownKey = Key.F5; item.Modifiers = ModifierKeys.None; item.ExecKbn = EKeyBindExecKbn.Internal; item.InternalKbn = EKeyBindInternalKbn.ReDisp; this.KeyBind.AddItem(item); }
public void AddItem(KeyBindItem item) { Dic.Add(new Tuple <Key, ModifierKeys>(item.PushDownKey, item.Modifiers), item); }