private void OnFormLoad(object sender, EventArgs e) { GlobalWindowManager.AddWindow(this); BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KGPG_Sign, KPRes.CreateMasterKey, m_ioInfo.GetDisplayName()); this.Icon = Properties.Resources.KeePass; this.Text = KPRes.CreateMasterKey; FontUtil.SetDefaultFont(m_cbPassword); FontUtil.AssignDefaultBold(m_cbPassword); FontUtil.AssignDefaultBold(m_cbKeyFile); FontUtil.AssignDefaultBold(m_cbUserAccount); Bitmap bmpBig = SystemIcons.Warning.ToBitmap(); m_imgAccWarning = GfxUtil.ScaleImage(bmpBig, DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16), ScaleTransformFlags.UIIcon); bmpBig.Dispose(); m_picAccWarning.Image = m_imgAccWarning; // m_ttRect.SetToolTip(m_cbHidePassword, KPRes.TogglePasswordAsterisks); m_ttRect.SetToolTip(m_btnSaveKeyFile, KPRes.KeyFileCreate); m_ttRect.SetToolTip(m_btnOpenKeyFile, KPRes.KeyFileUseExisting); m_ttRect.SetToolTip(m_tbRepeatPassword, KPRes.PasswordRepeatHint); if (!m_bCreatingNew) { m_lblIntro.Text = KPRes.ChangeMasterKeyIntroShort; } m_icgPassword.Attach(m_tbPassword, m_cbHidePassword, m_lblRepeatPassword, m_tbRepeatPassword, m_lblEstimatedQuality, m_pbPasswordQuality, m_lblQualityInfo, m_ttRect, this, true, false); m_cmbKeyFile.Items.Add(KPRes.NoKeyFileSpecifiedMeta); foreach (KeyProvider prov in Program.KeyProviderPool) { m_cmbKeyFile.Items.Add(prov.Name); } m_cmbKeyFile.SelectedIndex = 0; m_cbPassword.Checked = true; UIUtil.ApplyKeyUIFlags(Program.Config.UI.KeyCreationFlags, m_cbPassword, m_cbKeyFile, m_cbUserAccount, m_cbHidePassword); if (WinUtil.IsWindows9x || NativeLib.IsUnix()) { UIUtil.SetChecked(m_cbUserAccount, false); UIUtil.SetEnabled(m_cbUserAccount, false); UIUtil.SetEnabled(m_lblWindowsAccDesc, false); UIUtil.SetEnabled(m_lblWindowsAccDesc2, false); } CustomizeForScreenReader(); EnableUserControls(); // UIUtil.SetFocus(m_tbPassword, this); // See OnFormShown }
public void EnableProtection(bool bEnable) { if (m_tbPassword == null) { Debug.Assert(false); return; } if (!MonoWorkarounds.IsRequired(5795)) { if (bEnable) { FontUtil.AssignDefault(m_tbPassword); } else { FontUtil.SetDefaultFont(m_tbPassword); FontUtil.AssignDefaultMono(m_tbPassword, true); } } if (m_tbPassword.UseSystemPasswordChar == bEnable) { return; } m_tbPassword.UseSystemPasswordChar = bEnable; ShowCurrentPassword(-1, -1); }
private void OnFormLoad(object sender, EventArgs e) { m_bInitializing = true; GlobalWindowManager.AddWindow(this); // if(m_bRedirectActivation) Program.MainForm.RedirectActivationPush(this); string strBannerTitle = (!string.IsNullOrEmpty(m_strCustomTitle) ? m_strCustomTitle : KPRes.EnterCompositeKey); string strBannerDesc = WinUtil.CompactPath(m_ioInfo.Path, 45); BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KGPG_Key2, strBannerTitle, strBannerDesc); this.Icon = AppIcons.Default; FontUtil.SetDefaultFont(m_cbPassword); FontUtil.AssignDefaultBold(m_cbPassword); FontUtil.AssignDefaultBold(m_cbKeyFile); FontUtil.AssignDefaultBold(m_cbUserAccount); UIUtil.ConfigureToolTip(m_ttRect); // m_ttRect.SetToolTip(m_cbHidePassword, KPRes.TogglePasswordAsterisks); m_ttRect.SetToolTip(m_btnOpenKeyFile, KPRes.KeyFileSelect); PwInputControlGroup.ConfigureHideButton(m_cbHidePassword, m_ttRect); string strStart = (!string.IsNullOrEmpty(m_strCustomTitle) ? m_strCustomTitle : KPRes.OpenDatabase); string strNameEx = UrlUtil.GetFileName(m_ioInfo.Path); if (!string.IsNullOrEmpty(strNameEx)) { this.Text = strStart + " - " + strNameEx; } else { this.Text = strStart; } // Must be set manually due to possible object override m_tbPassword.TextChanged += this.ProcessTextChangedPassword; // m_cmbKeyFile.OrderedImageList = m_lKeyFileImages; AddKeyFileSuggPriv(KPRes.NoKeyFileSpecifiedMeta, true); // Do not directly compare with Program.CommandLineArgs.FileName, // because this may be a relative path instead of an absolute one string strCmdLineFile = Program.CommandLineArgs.FileName; if ((strCmdLineFile != null) && (Program.MainForm != null)) { strCmdLineFile = Program.MainForm.IocFromCommandLine().Path; } if ((strCmdLineFile != null) && strCmdLineFile.Equals(m_ioInfo.Path, StrUtil.CaseIgnoreCmp)) { string str; str = Program.CommandLineArgs[AppDefs.CommandLineOptions.Password]; if (str != null) { m_cbPassword.Checked = true; m_tbPassword.Text = str; } str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PasswordEncrypted]; if (str != null) { m_cbPassword.Checked = true; m_tbPassword.Text = StrUtil.DecryptString(str); } str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PasswordStdIn]; if (str != null) { ProtectedString ps = KeyUtil.ReadPasswordStdIn(true); if (ps != null) { m_cbPassword.Checked = true; m_tbPassword.TextEx = ps; } } str = Program.CommandLineArgs[AppDefs.CommandLineOptions.KeyFile]; if (str != null) { m_cbKeyFile.Checked = true; AddKeyFileSuggPriv(str, true); } str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PreSelect]; if (str != null) { m_cbKeyFile.Checked = true; AddKeyFileSuggPriv(str, true); } } m_cbHidePassword.Checked = true; OnCheckedHidePassword(sender, e); Debug.Assert(m_cmbKeyFile.Text.Length != 0); m_btnExit.Enabled = m_bCanExit; m_btnExit.Visible = m_bCanExit; ulong uKpf = Program.Config.UI.KeyPromptFlags; UIUtil.ApplyKeyUIFlags(uKpf, m_cbPassword, m_cbKeyFile, m_cbUserAccount, m_cbHidePassword); if ((uKpf & (ulong)AceKeyUIFlags.DisableKeyFile) != 0) { UIUtil.SetEnabled(m_cmbKeyFile, m_cbKeyFile.Checked); UIUtil.SetEnabled(m_btnOpenKeyFile, m_cbKeyFile.Checked); } if (((uKpf & (ulong)AceKeyUIFlags.CheckPassword) != 0) || ((uKpf & (ulong)AceKeyUIFlags.UncheckPassword) != 0)) { m_bPwStatePreset = true; } if (((uKpf & (ulong)AceKeyUIFlags.CheckUserAccount) != 0) || ((uKpf & (ulong)AceKeyUIFlags.UncheckUserAccount) != 0)) { m_bUaStatePreset = true; } CustomizeForScreenReader(); EnableUserControls(); m_bInitializing = false; // E.g. command line options have higher priority m_bCanModKeyFile = (m_cmbKeyFile.SelectedIndex == 0); m_aKeyAssoc = Program.Config.Defaults.GetKeySources(m_ioInfo); if (m_aKeyAssoc != null) { if (m_aKeyAssoc.Password && !m_bPwStatePreset) { m_cbPassword.Checked = true; } if (m_aKeyAssoc.KeyFilePath.Length > 0) { AddKeyFileSuggPriv(m_aKeyAssoc.KeyFilePath, null); } if (m_aKeyAssoc.UserAccount && !m_bUaStatePreset) { m_cbUserAccount.Checked = true; } } foreach (KeyProvider prov in Program.KeyProviderPool) { AddKeyFileSuggPriv(prov.Name, null); } // Local, but thread will continue to run anyway Thread th = new Thread(new ThreadStart(this.AsyncFormLoad)); th.Start(); // ThreadPool.QueueUserWorkItem(new WaitCallback(this.AsyncFormLoad)); this.BringToFront(); this.Activate(); // UIUtil.SetFocus(m_tbPassword, this); // See OnFormShown }
private void OnFormLoad(object sender, EventArgs e) { // The password text box should not be focused by default // in order to avoid a Caps Lock warning tooltip bug; // https://sourceforge.net/p/keepass/bugs/1807/ Debug.Assert((m_tbPassword.TabIndex >= 2) && !m_tbPassword.Focused); GlobalWindowManager.AddWindow(this); BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KGPG_Sign, KPRes.CreateMasterKey, m_ioInfo.GetDisplayName()); this.Icon = AppIcons.Default; this.Text = KPRes.CreateMasterKey; FontUtil.SetDefaultFont(m_cbPassword); FontUtil.AssignDefaultBold(m_cbPassword); FontUtil.AssignDefaultBold(m_cbKeyFile); FontUtil.AssignDefaultBold(m_cbUserAccount); using (Bitmap bmp = SystemIcons.Warning.ToBitmap()) { m_imgAccWarning = GfxUtil.ScaleImage(bmp, DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16), ScaleTransformFlags.UIIcon); m_imgKeyFileWarning = (Image)m_imgAccWarning.Clone(); } m_picKeyFileWarning.Image = m_imgKeyFileWarning; m_picAccWarning.Image = m_imgAccWarning; UIUtil.ConfigureToolTip(m_ttRect); // m_ttRect.SetToolTip(m_cbHidePassword, KPRes.TogglePasswordAsterisks); m_ttRect.SetToolTip(m_btnSaveKeyFile, KPRes.KeyFileCreate); m_ttRect.SetToolTip(m_btnOpenKeyFile, KPRes.KeyFileUseExisting); m_ttRect.SetToolTip(m_tbRepeatPassword, KPRes.PasswordRepeatHint); Debug.Assert(!m_lblIntro.AutoSize); // For RTL support if (!m_bCreatingNew) { m_lblIntro.Text = KPRes.ChangeMasterKeyIntroShort; } m_icgPassword.Attach(m_tbPassword, m_cbHidePassword, m_lblRepeatPassword, m_tbRepeatPassword, m_lblEstimatedQuality, m_pbPasswordQuality, m_lblQualityInfo, m_ttRect, this, true, false); m_cmbKeyFile.Items.Add(KPRes.NoKeyFileSpecifiedMeta); foreach (KeyProvider prov in Program.KeyProviderPool) { m_cmbKeyFile.Items.Add(prov.Name); } m_cmbKeyFile.SelectedIndex = 0; m_cbPassword.Checked = true; UIUtil.ApplyKeyUIFlags(Program.Config.UI.KeyCreationFlags, m_cbPassword, m_cbKeyFile, m_cbUserAccount, m_cbHidePassword); if (WinUtil.IsWindows9x || NativeLib.IsUnix()) { UIUtil.SetChecked(m_cbUserAccount, false); UIUtil.SetEnabled(m_cbUserAccount, false); UIUtil.SetEnabled(m_lblWindowsAccDesc, false); UIUtil.SetEnabled(m_lblWindowsAccDesc2, false); } CustomizeForScreenReader(); EnableUserControls(); // UIUtil.SetFocus(m_tbPassword, this); // See OnFormShown }
private void OnFormLoad(object sender, EventArgs e) { ++m_uUIAutoBlocked; // The password text box should not be focused by default // in order to avoid a Caps Lock warning tooltip bug; // https://sourceforge.net/p/keepass/bugs/1807/ Debug.Assert((m_tbPassword.TabIndex >= 2) && !m_tbPassword.Focused); GlobalWindowManager.AddWindow(this); // if(m_bRedirectActivation) Program.MainForm.RedirectActivationPush(this); string strBannerTitle = (!string.IsNullOrEmpty(m_strCustomTitle) ? m_strCustomTitle : KPRes.EnterCompositeKey); string strBannerDesc = m_ioInfo.GetDisplayName(); // Compacted by banner BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KGPG_Key2, strBannerTitle, strBannerDesc); this.Icon = AppIcons.Default; string strStart = (!string.IsNullOrEmpty(m_strCustomTitle) ? m_strCustomTitle : KPRes.OpenDatabase); string strName = UrlUtil.GetFileName(m_ioInfo.Path); if (!string.IsNullOrEmpty(strName)) { this.Text = strStart + " - " + strName; } else { this.Text = strStart; } FontUtil.SetDefaultFont(m_cbPassword); // FontUtil.AssignDefaultBold(m_cbPassword); // FontUtil.AssignDefaultBold(m_cbKeyFile); // FontUtil.AssignDefaultBold(m_cbUserAccount); UIUtil.ConfigureToolTip(m_ttRect); UIUtil.SetToolTip(m_ttRect, m_btnOpenKeyFile, KPRes.KeyFileSelect, true); UIUtil.AccSetName(m_tbPassword, m_cbPassword); UIUtil.AccSetName(m_cmbKeyFile, m_cbKeyFile); PwInputControlGroup.ConfigureHideButton(m_cbHidePassword, m_ttRect); // Enable protection before possibly setting a text m_cbHidePassword.Checked = true; OnHidePasswordCheckedChanged(null, EventArgs.Empty); // Must be set manually due to possible object override m_tbPassword.TextChanged += this.OnPasswordTextChanged; // m_cmbKeyFile.OrderedImageList = m_lKeyFileImages; AddKeyFileItem(KPRes.NoKeyFileSpecifiedMeta, true); Debug.Assert(!AnyComponentOn()); // Do not directly compare with Program.CommandLineArgs.FileName, // because this may be a relative path instead of an absolute one string strCmdLineFile = Program.CommandLineArgs.FileName; if (!string.IsNullOrEmpty(strCmdLineFile) && (Program.MainForm != null)) { strCmdLineFile = Program.MainForm.IocFromCommandLine().Path; } if (!string.IsNullOrEmpty(strCmdLineFile) && strCmdLineFile.Equals( m_ioInfo.Path, StrUtil.CaseIgnoreCmp)) { string str; str = Program.CommandLineArgs[AppDefs.CommandLineOptions.Password]; if (str != null) { m_cbPassword.Checked = true; m_tbPassword.Text = str; } str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PasswordEncrypted]; if (str != null) { m_cbPassword.Checked = true; m_tbPassword.Text = StrUtil.DecryptString(str); } str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PasswordStdIn]; if (str != null) { ProtectedString ps = KeyUtil.ReadPasswordStdIn(true); if (ps != null) { m_cbPassword.Checked = true; m_tbPassword.TextEx = ps; } } str = Program.CommandLineArgs[AppDefs.CommandLineOptions.KeyFile]; if (!string.IsNullOrEmpty(str)) { AddKeyFileItem(str, true); } str = Program.CommandLineArgs[AppDefs.CommandLineOptions.PreSelect]; if (!string.IsNullOrEmpty(str)) { AddKeyFileItem(str, true); } str = Program.CommandLineArgs[AppDefs.CommandLineOptions.UserAccount]; if (str != null) { m_cbUserAccount.Checked = true; } } AceKeyAssoc a = Program.Config.Defaults.GetKeySources(m_ioInfo); if ((a != null) && !AnyComponentOn()) { if (a.Password) { m_cbPassword.Checked = true; } if (!string.IsNullOrEmpty(a.KeyFilePath)) { AddKeyFileItem(a.KeyFilePath, true); } if (!string.IsNullOrEmpty(a.KeyProvider)) { AddKeyFileItem(a.KeyProvider, true); } if (a.UserAccount) { m_cbUserAccount.Checked = true; } } foreach (KeyProvider kp in Program.KeyProviderPool) { AddKeyFileItem(kp.Name, false); } UIUtil.ApplyKeyUIFlags(Program.Config.UI.KeyPromptFlags, m_cbPassword, m_cbKeyFile, m_cbUserAccount, m_cbHidePassword); if (!m_cbPassword.Enabled && !m_cbPassword.Checked) { m_tbPassword.Text = string.Empty; UIUtil.SetEnabledFast(false, m_tbPassword, m_cbHidePassword); } if (!m_cbKeyFile.Enabled && !m_cbKeyFile.Checked) { UIUtil.SetEnabledFast(false, m_cmbKeyFile, m_btnOpenKeyFile); } if (WinUtil.IsWindows9x || NativeLib.IsUnix()) { UIUtil.SetChecked(m_cbUserAccount, false); UIUtil.SetEnabled(m_cbUserAccount, false); } m_btnExit.Enabled = m_bCanExit; m_btnExit.Visible = m_bCanExit; --m_uUIAutoBlocked; UpdateUIState(); // Local, but thread will continue to run anyway Thread th = new Thread(new ThreadStart(this.OnFormLoadAsync)); th.Start(); // ThreadPool.QueueUserWorkItem(new WaitCallback(this.OnFormLoadAsync)); this.BringToFront(); this.Activate(); // UIUtil.SetFocus(m_tbPassword, this); // See OnFormShown }
private void OnFormLoad(object sender, EventArgs e) { ++m_uUIAutoBlocked; // The password text box should not be focused by default // in order to avoid a Caps Lock warning tooltip bug; // https://sourceforge.net/p/keepass/bugs/1807/ Debug.Assert((m_tbPassword.TabIndex >= 2) && !m_tbPassword.Focused); GlobalWindowManager.AddWindow(this); BannerFactory.CreateBannerEx(this, m_bannerImage, Properties.Resources.B48x48_KGPG_Sign, KPRes.CreateMasterKey, m_ioInfo.GetDisplayName()); this.Icon = AppIcons.Default; this.Text = KPRes.CreateMasterKey; FontUtil.SetDefaultFont(m_cbPassword); FontUtil.AssignDefaultBold(m_cbPassword); FontUtil.AssignDefaultBold(m_cbKeyFile); FontUtil.AssignDefaultBold(m_cbUserAccount); UIUtil.ConfigureToolTip(m_ttRect); UIUtil.SetToolTip(m_ttRect, m_tbRepeatPassword, KPRes.PasswordRepeatHint, false); UIUtil.SetToolTip(m_ttRect, m_btnSaveKeyFile, KPRes.KeyFileCreate, false); UIUtil.SetToolTip(m_ttRect, m_btnOpenKeyFile, KPRes.KeyFileUseExisting, false); UIUtil.AccSetName(m_tbPassword, m_cbPassword); UIUtil.AccSetName(m_cmbKeyFile, m_cbKeyFile); UIUtil.AccSetName(m_picKeyFileWarning, KPRes.Warning); UIUtil.AccSetName(m_picAccWarning, KPRes.Warning); Debug.Assert(!m_lblIntro.AutoSize); // For RTL support if (!m_bCreatingNew) { m_lblIntro.Text = KPRes.ChangeMasterKeyIntroShort; } m_cbPassword.Checked = true; m_icgPassword.Attach(m_tbPassword, m_cbHidePassword, m_lblRepeatPassword, m_tbRepeatPassword, m_lblEstimatedQuality, m_pbPasswordQuality, m_lblQualityInfo, m_ttRect, this, true, m_bSecureDesktop); Debug.Assert(!m_cmbKeyFile.Sorted); m_cmbKeyFile.Items.Add(KPRes.NoKeyFileSpecifiedMeta); m_cmbKeyFile.SelectedIndex = 0; foreach (KeyProvider kp in Program.KeyProviderPool) { m_cmbKeyFile.Items.Add(kp.Name); } m_imgKeyFileWarning = UIUtil.IconToBitmap(SystemIcons.Warning, DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16)); m_imgAccWarning = (Image)m_imgKeyFileWarning.Clone(); m_picKeyFileWarning.Image = m_imgKeyFileWarning; m_picAccWarning.Image = m_imgAccWarning; UIUtil.ApplyKeyUIFlags(Program.Config.UI.KeyCreationFlags, m_cbPassword, m_cbKeyFile, m_cbUserAccount, m_cbHidePassword); if (!m_cbKeyFile.Enabled && !m_cbKeyFile.Checked) { UIUtil.SetEnabledFast(false, m_lblKeyFileInfo, m_lblKeyFileWarning); } if (WinUtil.IsWindows9x || NativeLib.IsUnix() || (!m_cbUserAccount.Enabled && !m_cbUserAccount.Checked)) { UIUtil.SetChecked(m_cbUserAccount, false); UIUtil.SetEnabledFast(false, m_cbUserAccount, m_lblWindowsAccDesc, m_lblWindowsAccDesc2); } m_cbExpert.Checked = (m_cbKeyFile.Checked || m_cbUserAccount.Checked); --m_uUIAutoBlocked; UpdateUIState(); // UIUtil.SetFocus(m_tbPassword, this); // See OnFormShown }