private void Menu_AddItem(ContextMenu c, CustomAction.Actions action) { MenuItem m = new MenuItem(); m.Header = action.GetDescription(); m.Click += delegate { if (action == CustomAction.Actions.RunExternalProgram) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = Loc.GetString("cact_external_app_dialog_title"); dlg.Multiselect = false; dlg.Filter = "Executable Files|*.exe;*.bat;*.cmd;*.pif|" + "All Files (*.*)|*.*"; bool?result = dlg.ShowDialog(); if (result == true) { _action = new CustomAction(action, dlg.FileName); } } else if (action == CustomAction.Actions.Hotkey) { HotkeyRecorder dlg = new HotkeyRecorder(); bool? result = dlg.ShowDialog(); if (result == true) { _action = new CustomAction(action, dlg.HotkeyString + ";" + String.Join(",", dlg.HotKeysVirtualCodeRaw)); } } else { _action = new CustomAction(action); } if (_action != null) { Action.TextDetail = _action.ToLongString(); } }; m.Style = (Style)FindResource("MenuItemStyle"); c.Items.Add(m); }