private void InvokeShortcut(int keyId) { if (Program.IsCaptureIsActive) { return; } var property = _keyboardMapper.GetType().GetProperty(KeyboardMapper.GetProperty(keyId)); var attribute = property.GetCustomAttributes(typeof(ActionAttribute), false)[0] as ActionAttribute; if (attribute.PluginType != default(Type) && attribute.PluginType == typeof(ISendTo)) { if (string.IsNullOrEmpty(_fileName) || !File.Exists(_fileName)) { if (MessageBox.Show(Constants.IMAGE_SELECT_CONFIRM, Constants.APP_TITLE, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { _fileName = Common.ShowOpenDialog(Constants.IMAGEFILTER, Constants.IMAGESELECTDLGTITLE); } else { return; //No File selected or Found. } } Common.ExecutePlugin(_sendToPlugins, attribute.ActionMethod, _fileName, this); } else { _fileName = Common.ExecuteCaptureMode(attribute.ActionMethod, new object[] { new object[] { Foldername, this, Handle } }).ToString(); } ExecuteAfterCapture(); }
private void RegisterHotKeys(KeyboardMapper keyboardMapper) { var properties = keyboardMapper.GetType().GetProperties(); int i = 100; foreach (var property in properties) { if (property.CanRead) { var shortcut = (Keys)property.GetValue(keyboardMapper, null); if (shortcut != Keys.None) { KeyboardMapper.RegisterHotKeys(this, shortcut, i++, property.Name); } } } }