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 cmdOk_Click(object sender, EventArgs e) { Properties.Settings.Default.OutputFolder = string.IsNullOrEmpty(txtFolder.Text) ? Common.DefaultPath : txtFolder.Text; Properties.Settings.Default.ShowInfoOnStartup = chkShowInfoAtStartup.Checked; Properties.Settings.Default.EnableSound = chkSoundNotification.Checked; Properties.Settings.Default.SoundFile = txtSound.Text; Properties.Settings.Default.EnableShortcuts = chkShortcutsEnabled.Checked; Properties.Settings.Default.ImageFormat = Common.GetCurrentFormat(ddlImageFormats); Properties.Settings.Default.ExecuteAfterCapture = chkExecuteAfterCapture.Checked; Properties.Settings.Default.ExecuteAfterCapturePlugin = ddlPlugins.Items[ddlPlugins.SelectedIndex].ToString(); Properties.Settings.Default.PromptToSave = chkPromptToSave.Checked; var keyboardMapper = keyboardProperties.SelectedObject as KeyboardMapper; Properties.Settings.Default.Shortcuts = Utilities.Serialize <KeyboardMapper>(keyboardMapper); Properties.Settings.Default.IncludeCursor = chkIncludeCursor.Checked; Properties.Settings.Default.StartWithWindows = chkStartsWithWindows.Checked; Properties.Settings.Default.FilenameTemplate = string.IsNullOrEmpty(txtFileNameTemplate.Text) ? Constants.DEFAULT_TEMPLATE : txtFileNameTemplate.Text; Properties.Settings.Default.JpegQuality = tbjpgQuality.Value; Properties.Settings.Default.Save(); KeyboardMapper.UnregisterHotKeys(this); RegisterHotKeys(keyboardMapper); Close(); }
public static KeyboardMapper Load() { KeyboardMapper keyboardMapper = new KeyboardMapper(); if (!string.IsNullOrEmpty(Properties.Settings.Default.Shortcuts)) { keyboardMapper = Utilities.Deserialize <KeyboardMapper>(Properties.Settings.Default.Shortcuts); } return(keyboardMapper); }
private void frmSettings_FormClosing(object sender, FormClosingEventArgs e) { if (e.CloseReason == CloseReason.UserClosing) { WindowState = FormWindowState.Minimized; e.Cancel = true; } else { KeyboardMapper.UnregisterHotKeys(this); e.Cancel = false; captureItSysTrayIcon.Dispose(); } }
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); } } } }
private void frmSettings_Load(object sender, EventArgs e) { WindowState = FormWindowState.Minimized; Common.LoadImageFormats(ddlImageFormats); if (Properties.Settings.Default.ShowInfoOnStartup) { captureItSysTrayIcon.BalloonTipTitle = Constants.APP_TITLE; captureItSysTrayIcon.BalloonTipText = string.Format(Constants.APPINFOMESG, Constants.APP_TITLE); captureItSysTrayIcon.ShowBalloonTip(1); } txtFolder.Text = Foldername; txtSound.Text = Properties.Settings.Default.SoundFile; chkSoundNotification.Checked = Properties.Settings.Default.EnableSound; _isShortcutsEnabled = chkShortcutsEnabled.Checked = Properties.Settings.Default.EnableShortcuts; chkShowInfoAtStartup.Checked = Properties.Settings.Default.ShowInfoOnStartup; chkPromptToSave.Checked = Properties.Settings.Default.PromptToSave; chkExecuteAfterCapture.Checked = Properties.Settings.Default.ExecuteAfterCapture; chkIncludeCursor.Checked = Properties.Settings.Default.IncludeCursor; chkStartsWithWindows.Checked = Properties.Settings.Default.StartWithWindows; txtFileNameTemplate.Text = Properties.Settings.Default.FilenameTemplate; tbjpgQuality.Value = Properties.Settings.Default.JpegQuality; Common.LoadPlugins(captureToolStripMenuItem, Execute); Common.LoadGenericPlugins <ITool>(toolStripTools, ExecuteTools); _sendToPlugins = Common.LoadPlugins(ddlPlugins, toolStripSendTo, sendToMenuItem_Click); _keyboardMapper = KeyboardMapper.Load(); if (null != _keyboardMapper) { RegisterHotKeys(_keyboardMapper); } else { _keyboardMapper = new KeyboardMapper(); } keyboardProperties.SelectedObject = _keyboardMapper; string year = DateTime.Now.Year > 2017 ? DateTime.Now.Year.ToString() : "2017"; lblYearInfo.Text = string.Format("Copyright © 2017 - {0} КонтинентСвободы.рф", year); string version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); lblVersion.Text = string.Format("Версия:{0}", version); Visible = false; }