示例#1
0
        private static string ReplacePickPwPlaceholder(string str,
                                                       string strPlaceholder, uint uCharCount, SprContext ctx,
                                                       uint uRecursionLevel)
        {
            if (str.IndexOf(strPlaceholder, StrUtil.CaseIgnoreCmp) < 0)
            {
                return(str);
            }

            ProtectedString ps = ctx.Entry.Strings.Get(PwDefs.PasswordField);

            if (ps != null)
            {
                string strPassword = ps.ReadString();

                string strPick = SprEngine.CompileInternal(strPassword,
                                                           ctx.WithoutContentTransformations(), uRecursionLevel + 1);

                if (!string.IsNullOrEmpty(strPick))
                {
                    ProtectedString psPick    = new ProtectedString(false, strPick);
                    string          strPicked = (CharPickerForm.ShowAndRestore(psPick,
                                                                               true, true, uCharCount, null) ?? string.Empty);

                    str = StrUtil.ReplaceCaseInsensitive(str, strPlaceholder,
                                                         SprEngine.TransformContent(strPicked, ctx));
                }
            }

            return(StrUtil.ReplaceCaseInsensitive(str, strPlaceholder, string.Empty));
        }
示例#2
0
        private static string ShowCharPickDlg(string strWord, uint uCharCount,
                                              bool?bInitHide, SprContext ctx, uint uRecursionLevel)
        {
            string strPick = SprEngine.CompileInternal(strWord,
                                                       ctx.WithoutContentTransformations(), uRecursionLevel + 1);

            // No need to show the dialog when there's nothing to pick from
            // (this also prevents the dialog from showing up MaxRecursionDepth
            // times in case of a cyclic {PICKCHARS})
            if (string.IsNullOrEmpty(strPick))
            {
                return(string.Empty);
            }

            ProtectedString psWord    = new ProtectedString(false, strPick);
            string          strPicked = CharPickerForm.ShowAndRestore(psWord,
                                                                      true, true, uCharCount, bInitHide);

            return(strPicked ?? string.Empty);              // Don't transform here
        }