private void UpdateUI()
        {
            if ((m_uBlockUIUpdate > 0) || m_bInitializing)
            {
                return;
            }
            ++m_uBlockUIUpdate;

            ulong uFlags = 0;

            if (m_fParent is KeyCreationForm)
            {
                uFlags = Program.Config.UI.KeyCreationFlags;
            }

            byte[] pbUtf8 = m_tbPassword.TextEx.ReadUtf8();
            char[] v      = StrUtil.Utf8.GetChars(pbUtf8);

#if DEBUG
            byte[] pbTest = StrUtil.Utf8.GetBytes(v);
            Debug.Assert(MemUtil.ArraysEqual(pbUtf8, pbTest));
            MemUtil.ZeroByteArray(pbTest);
#endif

            m_tbPassword.Enabled = m_bEnabled;
            m_cbHide.Enabled     = (m_bEnabled && ((uFlags &
                                                    (ulong)AceKeyUIFlags.DisableHidePassword) == 0));

            bool bAutoRepeat = this.AutoRepeat;
            if (bAutoRepeat && (m_tbRepeat.TextLength > 0))
            {
                m_tbRepeat.Text = string.Empty;
            }

            byte[] pbRepeat = m_tbRepeat.TextEx.ReadUtf8();
            if (!MemUtil.ArraysEqual(pbUtf8, pbRepeat) && !bAutoRepeat)
            {
                m_tbRepeat.BackColor = AppDefs.ColorEditError;
            }
            else
            {
                m_tbRepeat.ResetBackColor();
            }

            bool bRepeatEnable = (m_bEnabled && !bAutoRepeat);
            m_lblRepeat.Enabled = bRepeatEnable;
            m_tbRepeat.Enabled  = bRepeatEnable;

            bool bQuality = m_bEnabled;
            if (m_bSprVar && bQuality)
            {
                if (SprEngine.MightChange(v))                // Perf. opt.
                {
                    // {S:...} and {REF:...} may reference the entry that
                    // is currently being edited and SprEngine will not see
                    // the current data entered in the dialog; thus we
                    // disable quality estimation for all strings containing
                    // one of these placeholders
                    string str = new string(v);
                    if ((str.IndexOf(@"{S:", StrUtil.CaseIgnoreCmp) >= 0) ||
                        (str.IndexOf(@"{REF:", StrUtil.CaseIgnoreCmp) >= 0))
                    {
                        bQuality = false;
                    }
                    else
                    {
                        SprContext ctx = new SprContext(m_ctxEntry, m_ctxDatabase,
                                                        SprCompileFlags.NonActive, false, false);
                        string strCmp = SprEngine.Compile(str, ctx);
                        if (strCmp != str)
                        {
                            bQuality = false;
                        }
                    }
                }
#if DEBUG
                else
                {
                    string     str = new string(v);
                    SprContext ctx = new SprContext(m_ctxEntry, m_ctxDatabase,
                                                    SprCompileFlags.NonActive, false, false);
                    string strCmp = SprEngine.Compile(str, ctx);
                    Debug.Assert(strCmp == str);
                }
#endif
            }

            m_lblQualityPrompt.Enabled = bQuality;
            m_pbQuality.Enabled        = bQuality;
            m_lblQualityInfo.Enabled   = bQuality;

            if ((Program.Config.UI.UIFlags & (ulong)AceUIFlags.HidePwQuality) != 0)
            {
                m_lblQualityPrompt.Visible = false;
                m_pbQuality.Visible        = false;
                m_lblQualityInfo.Visible   = false;
            }
            else if (bQuality || !m_bSprVar)
            {
                UpdateQualityInfo(v);
            }
            else
            {
                UqiShowQuality(0, 0);
            }

            MemUtil.ZeroByteArray(pbUtf8);
            MemUtil.ZeroByteArray(pbRepeat);
            MemUtil.ZeroArray <char>(v);
            --m_uBlockUIUpdate;
        }