コード例 #1
0
        protected override void LoadControlState(object savedState)
        {
            Expression = savedState as DisplayExpression;

            if (Expression == null)
            {
                Expression = new DisplayExpression();
            }
        }
コード例 #2
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (CssClass == null)
            {
                Style.Add(HtmlTextWriterStyle.Padding, "5px");
            }
            else
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
            }

            if (!Width.IsEmpty)
            {
                Style.Add(HtmlTextWriterStyle.Width, Width.ToString());
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Style, Style.Value);
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            if (Expression == null)
            {
                Expression = new DisplayExpression();
            }

            if (!string.IsNullOrEmpty(DisplayMessage))
            {
                writer.Write(DisplayMessage + "<br />");
            }

            // Write the Expression label
            writer.Write(Expression.Value1.ToString() + " " +
                         Expression.Operation + " " +
                         Expression.Value2.ToString() + " = ");

            writer.Write(" <input type='text' value='" + EnteredValue +
                         "' id='" + Expression.Id + "' name='" + Expression.Id + "' style='width: 30px;' />");


            writer.RenderEndTag(); // main div
        }
コード例 #3
0
        /// <summary>
        /// Method can be used to generate a new Expression object
        /// with new values to use. Use this method to update the
        /// wwCaptcha expression after you've saved an entry.
        /// </summary>
        /// <returns></returns>
        public void GenerateExpression()
        {
            DisplayExpression exp  = new DisplayExpression();
            Random            rand = new Random();

            exp.Value1    = rand.Next(9) + 1;
            exp.Value2    = rand.Next(9) + 1;
            exp.Operation = rand.Next(1) == 0 ? "+" : "*";

            if (exp.Operation == "+")
            {
                exp.ExpectedValue = exp.Value1 + exp.Value2;
            }

            if (exp.Operation == "*")
            {
                exp.ExpectedValue = exp.Value1 * exp.Value2;
            }

            exp.UniquePageId = UniquePageId;

            Expression = exp;
        }
コード例 #4
0
        protected override void LoadControlState(object savedState)
        {            
            Expression = savedState as DisplayExpression;

            if (Expression == null)
                Expression = new DisplayExpression();
        }
コード例 #5
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (CssClass == null)
                Style.Add(HtmlTextWriterStyle.Padding, "5px");
            else
                writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);
            
            if (!Width.IsEmpty)
                Style.Add(HtmlTextWriterStyle.Width, Width.ToString());

            writer.AddAttribute(HtmlTextWriterAttribute.Style,Style.Value);
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            if (Expression == null)
                Expression = new DisplayExpression();

            if (!string.IsNullOrEmpty(DisplayMessage))
                writer.Write(DisplayMessage + "<br />" );

            // Write the Expression label
            writer.Write(Expression.Value1.ToString() + " " + 
                         Expression.Operation + " " + 
                         Expression.Value2.ToString() + " = " );
            
            writer.Write(" <input type='text' value='" + EnteredValue +
                         "' id='" + Expression.Id + "' name='" + Expression.Id + "' style='width: 30px;' />");


            writer.RenderEndTag(); // main div
        }
コード例 #6
0
        /// <summary>
        /// Method can be used to generate a new Expression object
        /// with new values to use. Use this method to update the
        /// wwCaptcha expression after you've saved an entry.        
        /// </summary>
        /// <returns></returns>
        public void GenerateExpression()
        {
            DisplayExpression exp = new DisplayExpression();
            Random rand = new Random();
            
            exp.Value1 = rand.Next(9) + 1;
            exp.Value2 = rand.Next(9) + 1;
            exp.Operation =  rand.Next(1) == 0 ? "+" : "*" ;

            if (exp.Operation == "+")
                exp.ExpectedValue = exp.Value1 + exp.Value2;
            
            if (exp.Operation == "*")
               exp.ExpectedValue = exp.Value1 * exp.Value2;

            exp.UniquePageId = UniquePageId;

            Expression = exp;            
        }