示例#1
0
        private void OnFormLoad(object sender, EventArgs e)
        {
            Debug.Assert(m_vStringDict != null); if (m_vStringDict == null)
            {
                throw new InvalidOperationException();
            }

            GlobalWindowManager.AddWindow(this);

            m_ctxValue.Attach(m_richStringValue, this);

            string strTitle, strDesc;

            if (m_strStringName == 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.EnableAutoCompletion(m_cmbStringName, true);
            UIUtil.PrepareStandardMultilineControl(m_richStringValue, true, true);

            if (m_strStringName != null)
            {
                m_cmbStringName.Text = m_strStringName;
            }
            if (m_psStringInitialValue != null)
            {
                m_richStringValue.Text = StrUtil.NormalizeNewLines(
                    m_psStringInitialValue.ReadString(), true);
                UIUtil.SetChecked(m_cbProtect, m_psStringInitialValue.IsProtected);
            }

            ValidateStringNameUI();
            PopulateNamesComboBox();

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

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

            if (m_bReadOnly)
            {
                m_cmbStringName.Enabled    = false;
                m_richStringValue.ReadOnly = true;
                m_cbProtect.Enabled        = false;
                // m_btnOK.Enabled = false; // See ValidateStringNameUI
            }

            // UIUtil.SetFocus(..., this); // See PopulateNamesComboBox
        }
示例#2
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
        }