Esempio n. 1
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            if (m_dStrings == null)
            {
                Debug.Assert(false); throw new InvalidOperationException();
            }

            GlobalWindowManager.AddWindow(this);

            string strTitle, strDesc;

            if (m_strInitName == null)
            {
                strTitle = KPRes.AddStringField;
                strDesc  = KPRes.AddStringFieldDesc;
            }
            else
            {
                strTitle = KPRes.EditStringField;
                strDesc  = KPRes.EditStringFieldDesc;
            }

            BannerFactory.CreateBannerEx(this, m_bannerImage,
                                         Properties.Resources.B48x48_Font, strTitle, strDesc);
            this.Icon = AppIcons.Default;

            UIUtil.ConfigureToolTip(m_ttRect);

            UIUtil.EnableAutoCompletion(m_cmbName, true);

            UIUtil.PrepareStandardMultilineControl(m_rtbValue, true, true);
            m_ctxValue.Attach(m_rtbValue, this);

            GFunc <PwEntry> fGetContextEntry = delegate()
            {
                return(PwEntry.CreateVirtual(((m_pdContext != null) ? m_pdContext.RootGroup :
                                              null) ?? new PwGroup(true, true), m_dStrings));
            };

            m_pgm = new PwGeneratorMenu(m_btnGenPw, m_ttRect, m_rtbValue,
                                        fGetContextEntry, m_pdContext, (m_mvec != null));

            if (m_strInitName != null)
            {
                m_cmbName.Text = m_strInitName;
            }
            if (m_psInitValue != null)
            {
                m_rtbValue.Text = StrUtil.NormalizeNewLines(
                    m_psInitValue.ReadString(), true);
                UIUtil.SetChecked(m_cbProtect, m_psInitValue.IsProtected);
            }

            ValidateStringNameUI();
            PopulateNamesComboBox();

            if (m_mvec != null)
            {
                m_cmbName.Enabled = false;
                MultipleValuesEx.ConfigureText(m_rtbValue, true);

                bool bMultiProt;
                m_mvec.MultiStringProt.TryGetValue(m_cmbName.Text, out bMultiProt);
                if (bMultiProt)
                {
                    MultipleValuesEx.ConfigureState(m_cbProtect, true);
                }
            }

            if (m_bReadOnly)
            {
                m_cmbName.Enabled   = false;
                m_rtbValue.ReadOnly = true;
                m_cbProtect.Enabled = false;
                m_btnGenPw.Enabled  = false;
                // m_btnOK.Enabled = false; // See ValidateStringNameUI
            }

            // UIUtil.SetFocus(..., this); // See PopulateNamesComboBox
        }