Esempio n. 1
0
        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_cBlockUIUpdate;

            GlobalWindowManager.AddWindow(this);

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         KeePass.Properties.Resources.B48x48_KGPG_Gen,
                                         KPRes.KeyFileCreateTitle, KPRes.KeyFileCreate + ".");
            this.Icon = AppIcons.Default;
            this.Text = KPRes.KeyFileCreateTitle;

            FontUtil.AssignDefaultBold(m_rbCreate);
            FontUtil.AssignDefaultBold(m_rbRecreate);
            FontUtil.AssignDefaultMono(m_tbRecKeyHash, false);
            FontUtil.AssignDefaultMono(m_tbRecKey, false);

            if (m_bRecreateOnly)
            {
                m_rbRecreate.Checked = true;
                m_rbCreate.Enabled   = false;
            }
            else
            {
                m_rbCreate.Checked = true;
            }

            m_cbNewEntropy.Checked = true;

            Debug.Assert(!m_cmbNewFormat.Sorted);
            foreach (KfcfInfo kfi in m_vNewFormat)
            {
                m_cmbNewFormat.Items.Add(kfi.Name);
            }
            m_cmbNewFormat.SelectedIndex = 0;

            Debug.Assert(!m_cmbRecFormat.Sorted);
            foreach (KfcfInfo kfi in m_vRecFormat)
            {
                m_cmbRecFormat.Items.Add(kfi.Name);
            }
            m_cmbRecFormat.SelectedIndex = 0;

            m_rbCreate.CheckedChanged           += this.OnShouldUpdateUIState;
            m_rbRecreate.CheckedChanged         += this.OnShouldUpdateUIState;
            m_cmbRecFormat.SelectedIndexChanged += this.OnShouldUpdateUIState;
            m_tbRecKey.TextChanged += this.OnShouldUpdateUIState;

            --m_cBlockUIUpdate;
            UpdateUIState();
        }
Esempio n. 3
0
        private void SetRtbData(string strData, bool bRtf, bool bFixedFont,
                                bool bLinkify)
        {
            if (strData == null)
            {
                Debug.Assert(false); strData = string.Empty;
            }

            m_rtbText.Clear();             // Clear formatting (esp. induced by Unicode)

            if (bFixedFont)
            {
                FontUtil.AssignDefaultMono(m_rtbText, false);
            }
            else
            {
                FontUtil.AssignDefault(m_rtbText);
            }

            if (bRtf)
            {
                m_rtbText.Rtf = StrUtil.RtfFix(strData);
            }
            else
            {
                m_rtbText.Text = strData;
            }

            if (bLinkify)
            {
                UIUtil.RtfLinkifyUrls(m_rtbText);
            }

            if (!bRtf)
            {
                Font f = (bFixedFont ? FontUtil.MonoFont : FontUtil.DefaultFont);
                if (f != null)
                {
                    m_rtbText.SelectAll();
                    m_rtbText.SelectionFont = f;
                }
                else
                {
                    Debug.Assert(false);
                }
            }

            m_rtbText.Select(0, 0);
        }
Esempio n. 4
0
        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);

            m_strAdvControlText = m_tabAdvanced.Text;

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_KGPG_Gen, KPRes.PasswordOptions,
                                         KPRes.PasswordOptionsDesc);
            this.Icon = Properties.Resources.KeePass;

            UIUtil.SetButtonImage(m_btnProfileAdd,
                                  Properties.Resources.B16x16_FileSaveAs, false);
            UIUtil.SetButtonImage(m_btnProfileRemove,
                                  Properties.Resources.B16x16_EditDelete, true);

            FontUtil.AssignDefaultBold(m_rbStandardCharSet);
            FontUtil.AssignDefaultBold(m_rbPattern);
            FontUtil.AssignDefaultBold(m_rbCustom);
            FontUtil.AssignDefaultMono(m_tbPreview, true);

            m_ttMain.SetToolTip(m_btnProfileAdd, KPRes.GenProfileSaveDesc);
            m_ttMain.SetToolTip(m_btnProfileRemove, KPRes.GenProfileRemoveDesc);

            m_bBlockUIUpdate = true;

            m_cbUpperCase.Text        += @" (A, B, C, ...)";
            m_cbLowerCase.Text        += @" (a, b, c, ...)";
            m_cbDigits.Text           += @" (0, 1, 2, ...)";
            m_cbMinus.Text            += @" (-)";
            m_cbUnderline.Text        += @" (_)";
            m_cbSpace.Text            += @" ( )";
            m_cbSpecial.Text          += @" (!, $, %, &&, ...)";
            m_cbBrackets.Text         += @" ([, ], {, }, (, ), <, >)";
            m_cbNoRepeat.Text         += @" *";
            m_cbExcludeLookAlike.Text += @" (l|1I, O0) *";
            m_lblExcludeChars.Text    += @" *";
            m_lblSecRedInfo.Text       = @"* " + m_lblSecRedInfo.Text;

            m_cmbCustomAlgo.Items.Add(NoCustomAlgo);
            foreach (CustomPwGenerator pwg in Program.PwGeneratorPool)
            {
                m_cmbCustomAlgo.Items.Add(pwg.Name);
            }
            SelectCustomGenerator((m_optInitial != null) ?
                                  m_optInitial.CustomAlgorithmUuid : null, null);
            if (m_optInitial != null)
            {
                CustomPwGenerator pwg = GetPwGenerator();
                if (pwg != null)
                {
                    m_dictCustomOptions[pwg] = m_optInitial.CustomAlgorithmOptions;
                }
            }

            m_cmbProfiles.Items.Add(CustomMeta);

            if (m_optInitial != null)
            {
                m_cmbProfiles.Items.Add(DeriveFromPrevious);
                SetGenerationOptions(m_optInitial);
            }

            m_rbStandardCharSet.CheckedChanged   += this.UpdateUIProc;
            m_rbPattern.CheckedChanged           += this.UpdateUIProc;
            m_rbCustom.CheckedChanged            += this.UpdateUIProc;
            m_numGenChars.ValueChanged           += this.UpdateUIProc;
            m_cbUpperCase.CheckedChanged         += this.UpdateUIProc;
            m_cbLowerCase.CheckedChanged         += this.UpdateUIProc;
            m_cbDigits.CheckedChanged            += this.UpdateUIProc;
            m_cbMinus.CheckedChanged             += this.UpdateUIProc;
            m_cbUnderline.CheckedChanged         += this.UpdateUIProc;
            m_cbSpace.CheckedChanged             += this.UpdateUIProc;
            m_cbSpecial.CheckedChanged           += this.UpdateUIProc;
            m_cbBrackets.CheckedChanged          += this.UpdateUIProc;
            m_cbHighAnsi.CheckedChanged          += this.UpdateUIProc;
            m_tbCustomChars.TextChanged          += this.UpdateUIProc;
            m_tbPattern.TextChanged              += this.UpdateUIProc;
            m_cbPatternPermute.CheckedChanged    += this.UpdateUIProc;
            m_cbNoRepeat.CheckedChanged          += this.UpdateUIProc;
            m_cbExcludeLookAlike.CheckedChanged  += this.UpdateUIProc;
            m_tbExcludeChars.TextChanged         += this.UpdateUIProc;
            m_cmbCustomAlgo.SelectedIndexChanged += this.UpdateUIProc;

            m_cmbProfiles.Items.Add(AutoGeneratedMeta);

            m_cmbProfiles.SelectedIndex = ((m_optInitial == null) ? 0 : 1);

            foreach (PwProfile ppw in PwGeneratorUtil.GetAllProfiles(true))
            {
                m_cmbProfiles.Items.Add(ppw.Name);

                if (ppw.GeneratorType == PasswordGeneratorType.Custom)
                {
                    CustomPwGenerator pwg = Program.PwGeneratorPool.Find(new
                                                                         PwUuid(Convert.FromBase64String(ppw.CustomAlgorithmUuid)));
                    if (pwg != null)
                    {
                        m_dictCustomOptions[pwg] = ppw.CustomAlgorithmOptions;
                    }
                }
            }

            if (m_optInitial == null)
            {
                // int nIndex = m_cmbProfiles.FindString(Program.Config.PasswordGenerator.LastUsedProfile.Name);
                // if(nIndex >= 0) m_cmbProfiles.SelectedIndex = nIndex;
                SetGenerationOptions(Program.Config.PasswordGenerator.LastUsedProfile);
            }

            if (m_bCanAccept == false)
            {
                m_btnOK.Visible  = false;
                m_btnCancel.Text = KPRes.CloseButton;

                m_tabPreview.Text    = KPRes.Generate;
                m_lblPreview.Visible = false;
                UIUtil.SetChecked(m_cbEntropy, false);
                m_cbEntropy.Enabled = false;
            }

            // Debug.Assert(this.ShowInTaskbar == false);
            // if(m_bForceInTaskbar) this.ShowInTaskbar = true;

            CustomizeForScreenReader();

            m_bBlockUIUpdate = false;
            EnableControlsEx(false);
        }