private static void ChangeHotKey(ref Keys kPrevHK, HotKeyControlEx hkControl, bool bAutoTypeHotKey, int nHotKeyID) { Keys kNew = hkControl.HotKey | hkControl.HotKeyModifiers; if (kPrevHK != kNew) { kPrevHK = kNew; if (bAutoTypeHotKey) { Program.Config.Integration.HotKeyGlobalAutoType = (ulong)kNew; } else { Program.Config.Integration.HotKeyShowWindow = (ulong)kNew; } HotKeyManager.UnregisterHotKey(nHotKeyID); if (kPrevHK != Keys.None) { HotKeyManager.RegisterHotKey(nHotKeyID, kPrevHK); } } }
private static void ChangeHotKey(ref Keys kPrevHK, HotKeyControlEx hkControl, int nHotKeyID) { Keys kNew = (hkControl.HotKey | hkControl.HotKeyModifiers); if (kPrevHK != kNew) { kPrevHK = kNew; if (nHotKeyID == AppDefs.GlobalHotKeyId.AutoType) { Program.Config.Integration.HotKeyGlobalAutoType = (ulong)kNew; } else if (nHotKeyID == AppDefs.GlobalHotKeyId.AutoTypeSelected) { Program.Config.Integration.HotKeySelectedAutoType = (ulong)kNew; } else if (nHotKeyID == AppDefs.GlobalHotKeyId.ShowWindow) { Program.Config.Integration.HotKeyShowWindow = (ulong)kNew; } HotKeyManager.UnregisterHotKey(nHotKeyID); if (kPrevHK != Keys.None) { HotKeyManager.RegisterHotKey(nHotKeyID, kPrevHK); } } }
private void SetHotKey(HotKeyControlEx hkBox, Keys hk) { if ((hkBox == tbPWOnly) && Config.KPAutoTypePWPossible) { hkBox.TabStop = hkBox.Enabled = false; hkBox.ReadOnly = true; } try { var check = hkBox.GetType().GetProperty("HotKeyModifiers"); if (check == null) { // only available with KeePass versions > 2.41 hkBox.HotKey = hk; return; } hkBox.HotKey = hk & Keys.KeyCode; check.SetValue(hkBox, hk & Keys.Modifiers, null); var render = hkBox.GetType().GetMethod("RenderHotKey"); if (render == null) { return; } render.Invoke(hkBox, null); } catch { } }
private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; Debug.Assert(m_ilIcons != null); if (m_ilIcons != null) { m_tabMain.ImageList = m_ilIcons; m_tabSecurity.ImageIndex = (int)PwIcon.TerminalEncrypted; m_tabPolicy.ImageIndex = (int)PwIcon.List; m_tabGui.ImageIndex = (int)PwIcon.Screen; m_tabIntegration.ImageIndex = (int)PwIcon.Console; m_tabAdvanced.ImageIndex = (int)PwIcon.ClipboardReady; } uint uTab = Program.Config.Defaults.OptionsTabIndex; if (uTab < (uint)m_tabMain.TabPages.Count) { m_tabMain.SelectedTab = m_tabMain.TabPages[(int)uTab]; } m_cmbBannerStyle.Items.Add("(" + KPRes.CurrentStyle + ")"); m_cmbBannerStyle.Items.Add("WinXP Login"); m_cmbBannerStyle.Items.Add("WinVista Black"); m_cmbBannerStyle.Items.Add("KeePass Win32"); m_cmbBannerStyle.Items.Add("Blue Carbon"); CreateDialogBanner(BannerStyle.Default); m_cmbBannerStyle.SelectedIndex = (int)BannerStyle.Default; int nWidth = m_lvPolicy.ClientRectangle.Width - 36; m_lvPolicy.Columns.Add(KPRes.Feature, nWidth / 4); m_lvPolicy.Columns.Add(KPRes.Description, (nWidth * 3) / 4); m_hkGlobalAutoType = HotKeyControlEx.ReplaceTextBox(m_grpHotKeys, m_tbGlobalAutoType); m_hkShowWindow = HotKeyControlEx.ReplaceTextBox(m_grpHotKeys, m_tbShowWindowHotKey); LoadOptions(); if (Program.Config.Meta.IsEnforcedConfiguration) { m_lvPolicy.Enabled = false; } UpdateUIState(); }
private Keys GetHotKey(HotKeyControlEx hkBox) { try { var check = hkBox.GetType().GetProperty("HotKeyModifiers"); if (check == null) { // only available with KeePass versions > 2.41 return(hkBox.HotKey); } return(hkBox.HotKey | (Keys)check.GetValue(hkBox, null)); } catch { } return(Keys.None); }
internal static bool HandleHotKeyIntoSelf(int wParam) { try { OptionsForm f = (GlobalWindowManager.TopWindow as OptionsForm); if (f == null) { return(false); } IntPtr h = NativeMethods.GetForegroundWindowHandle(); if (h != f.Handle) { return(false); } HotKeyControlEx c = (f.ActiveControl as HotKeyControlEx); if (c == null) { return(false); } Keys k; if (!m_vRegKeys.TryGetValue(wParam, out k)) { return(false); } if (k == Keys.None) { Debug.Assert(false); return(false); } c.HotKey = k; return(true); } catch (Exception) { Debug.Assert(false); } return(false); }
private void OnFormLoad(object sender, EventArgs e) { // Can be invoked by tray command; don't use CenterParent Debug.Assert(this.StartPosition == FormStartPosition.CenterScreen); // When multiline is enabled, tabs added by plugins can result // in multiple tab rows, cropping the tab content at the bottom; // https://sourceforge.net/p/keepass/discussion/329220/thread/a17a2734/ Debug.Assert(!m_tabMain.Multiline); GlobalWindowManager.AddWindow(this); this.Icon = AppIcons.Default; Debug.Assert(m_ilIcons != null); if (m_ilIcons != null) { m_tabMain.ImageList = m_ilIcons; m_tabSecurity.ImageIndex = (int)PwIcon.TerminalEncrypted; m_tabPolicy.ImageIndex = (int)PwIcon.List; m_tabGui.ImageIndex = (int)PwIcon.Screen; m_tabIntegration.ImageIndex = (int)PwIcon.Console; m_tabAdvanced.ImageIndex = (int)PwIcon.ClipboardReady; } uint uTab = Program.Config.Defaults.OptionsTabIndex; if (uTab < (uint)m_tabMain.TabPages.Count) { m_tabMain.SelectedTab = m_tabMain.TabPages[(int)uTab]; } m_aceUrlSchemeOverrides = Program.Config.Integration.UrlSchemeOverrides.CloneDeep(); m_strUrlOverrideAll = Program.Config.Integration.UrlOverride; Debug.Assert(!m_cmbMenuStyle.Sorted); m_cmbMenuStyle.Items.Add(KPRes.Auto + " (" + KPRes.Recommended + ")"); m_cmbMenuStyle.Items.Add(new string('-', 24)); int nTsrs = 2, iTsrSel = 0, nSuffixes = 0; foreach (TsrFactory fTsr in TsrPool.Factories) { string strSuffix = string.Empty; if (!fTsr.IsSupported()) { strSuffix = " (" + KPRes.IncompatibleEnv + ")"; ++nSuffixes; } string strUuid = Convert.ToBase64String(fTsr.Uuid.UuidBytes); if (Program.Config.UI.ToolStripRenderer == strUuid) { iTsrSel = nTsrs; } m_cmbMenuStyle.Items.Add((fTsr.Name ?? string.Empty) + strSuffix); m_dTsrUuids[nTsrs] = strUuid; ++nTsrs; } Debug.Assert(m_cmbMenuStyle.Items.Count == nTsrs); m_cmbMenuStyle.SelectedIndex = iTsrSel; if (nSuffixes > 0) { m_cmbMenuStyle.DropDownWidth = m_cmbMenuStyle.Width * 2; } if (AppConfigEx.IsOptionEnforced(Program.Config.UI, "ToolStripRenderer")) { m_lblMenuStyle.Enabled = false; m_cmbMenuStyle.Enabled = false; } Debug.Assert(!m_cmbBannerStyle.Sorted); m_cmbBannerStyle.Items.Add("(" + KPRes.CurrentStyle + ")"); m_cmbBannerStyle.Items.Add("Windows XP Login"); m_cmbBannerStyle.Items.Add("Windows Vista Black"); m_cmbBannerStyle.Items.Add("KeePass Win32"); m_cmbBannerStyle.Items.Add("Blue Carbon"); CreateDialogBanner(BannerStyle.Default); // Default forces generation m_cmbBannerStyle.SelectedIndex = (int)BannerStyle.Default; if ((BannerFactory.CustomGenerator != null) || AppConfigEx.IsOptionEnforced(Program.Config.UI, "BannerStyle")) { m_lblBannerStyle.Enabled = false; m_cmbBannerStyle.Enabled = false; } int nWidth = m_lvPolicy.ClientSize.Width - UIUtil.GetVScrollBarWidth(); m_lvPolicy.Columns.Add(KPRes.Feature, (nWidth * 10) / 29); m_lvPolicy.Columns.Add(KPRes.Description, (nWidth * 19) / 29); m_hkGlobalAutoType = HotKeyControlEx.ReplaceTextBox(m_grpHotKeys, m_tbGlobalAutoType, false); m_hkSelectedAutoType = HotKeyControlEx.ReplaceTextBox(m_grpHotKeys, m_tbSelAutoTypeHotKey, false); m_hkShowWindow = HotKeyControlEx.ReplaceTextBox(m_grpHotKeys, m_tbShowWindowHotKey, false); if (!NativeLib.IsUnix()) { UIUtil.SetShield(m_btnFileExtCreate, true); UIUtil.SetShield(m_btnFileExtRemove, true); m_linkHotKeyHelp.Visible = false; } else // Unix { m_hkGlobalAutoType.TextNone = KPRes.External; m_hkSelectedAutoType.TextNone = KPRes.External; m_hkShowWindow.TextNone = KPRes.External; m_hkGlobalAutoType.Enabled = m_hkSelectedAutoType.Enabled = m_hkShowWindow.Enabled = false; m_btnFileExtCreate.Enabled = m_btnFileExtRemove.Enabled = false; m_cbAutoRun.Enabled = false; } UIUtil.SetExplorerTheme(m_lvSecurityOptions, false); UIUtil.SetExplorerTheme(m_lvPolicy, false); UIUtil.SetExplorerTheme(m_lvGuiOptions, false); UIUtil.SetExplorerTheme(m_lvAdvanced, false); AppConfigEx.ClearXmlPathCache(); LoadOptions(); // if(Program.Config.Meta.IsEnforcedConfiguration) // m_lvPolicy.Enabled = false; UpdateUIState(); }
private void OnFormLoad(object sender, EventArgs e) { // Can be invoked by tray command; don't use CenterParent Debug.Assert(this.StartPosition == FormStartPosition.CenterScreen); GlobalWindowManager.AddWindow(this); this.Icon = Properties.Resources.KeePass; Debug.Assert(m_ilIcons != null); if (m_ilIcons != null) { m_tabMain.ImageList = m_ilIcons; m_tabSecurity.ImageIndex = (int)PwIcon.TerminalEncrypted; m_tabPolicy.ImageIndex = (int)PwIcon.List; m_tabGui.ImageIndex = (int)PwIcon.Screen; m_tabIntegration.ImageIndex = (int)PwIcon.Console; m_tabAdvanced.ImageIndex = (int)PwIcon.ClipboardReady; } uint uTab = Program.Config.Defaults.OptionsTabIndex; if (uTab < (uint)m_tabMain.TabPages.Count) { m_tabMain.SelectedTab = m_tabMain.TabPages[(int)uTab]; } m_aceUrlSchemeOverrides = Program.Config.Integration.UrlSchemeOverrides.CloneDeep(); m_cmbBannerStyle.Items.Add("(" + KPRes.CurrentStyle + ")"); m_cmbBannerStyle.Items.Add("WinXP Login"); m_cmbBannerStyle.Items.Add("WinVista Black"); m_cmbBannerStyle.Items.Add("KeePass Win32"); m_cmbBannerStyle.Items.Add("Blue Carbon"); CreateDialogBanner(BannerStyle.Default); // Default forces generation m_cmbBannerStyle.SelectedIndex = (int)BannerStyle.Default; if ((BannerFactory.CustomGenerator != null) || AppConfigEx.IsOptionEnforced(Program.Config.UI, "BannerStyle")) { m_lblBannerStyle.Enabled = false; m_cmbBannerStyle.Enabled = false; } int nWidth = m_lvPolicy.ClientRectangle.Width - UIUtil.GetVScrollBarWidth() - 1; m_lvPolicy.Columns.Add(KPRes.Feature, (nWidth * 10) / 29); m_lvPolicy.Columns.Add(KPRes.Description, (nWidth * 19) / 29); m_hkGlobalAutoType = HotKeyControlEx.ReplaceTextBox(m_grpHotKeys, m_tbGlobalAutoType, true); m_hkSelectedAutoType = HotKeyControlEx.ReplaceTextBox(m_grpHotKeys, m_tbSelAutoTypeHotKey, true); m_hkShowWindow = HotKeyControlEx.ReplaceTextBox(m_grpHotKeys, m_tbShowWindowHotKey, true); if (!NativeLib.IsUnix()) { UIUtil.SetShield(m_btnFileExtCreate, true); UIUtil.SetShield(m_btnFileExtRemove, true); m_linkHotKeyHelp.Visible = false; } else // Unix { Program.Config.Integration.HotKeyGlobalAutoType = (ulong)Keys.None; Program.Config.Integration.HotKeySelectedAutoType = (ulong)Keys.None; Program.Config.Integration.HotKeyShowWindow = (ulong)Keys.None; m_hkGlobalAutoType.Enabled = m_hkSelectedAutoType.Enabled = m_hkShowWindow.Enabled = false; m_btnFileExtCreate.Enabled = m_btnFileExtRemove.Enabled = false; m_cbAutoRun.Enabled = false; } UIUtil.SetExplorerTheme(m_lvSecurityOptions, false); UIUtil.SetExplorerTheme(m_lvPolicy, false); UIUtil.SetExplorerTheme(m_lvGuiOptions, false); UIUtil.SetExplorerTheme(m_lvAdvanced, false); AppConfigEx.ClearXmlPathCache(); LoadOptions(); // if(Program.Config.Meta.IsEnforcedConfiguration) // m_lvPolicy.Enabled = false; UpdateUIState(); }
private Keys GetHotKey(HotKeyControlEx hkBox) { return(hkBox.HotKey); }
private void SetHotKey(HotKeyControlEx hkBox, Keys hk) { hkBox.HotKey = hk; }
private void Apply(HotKeyControlEx hotKeyControlEx) { hotKeyControlEx.BackColorChanged -= HandleHotKeyControlExOnBackColorChanged; hotKeyControlEx.BackColorChanged += HandleHotKeyControlExOnBackColorChanged; }