/// <summary>
        /// Initialize the form
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (_macroList.Items.Count < 1)
            {
                _macroList.DataValueField = "Alias";
                _macroList.DataTextField  = "Name";
                _macroList.DataSource     = Macro.GetAll();
                _macroList.DataBound     += new EventHandler(MacroList_DataBound);
            }
            if (!Page.IsPostBack)
            {
                if (MaxNumber != 0)
                {
                    _txtMaxNumber.Text = MaxNumber.ToString();
                }
                if (PreferedWidth != 0)
                {
                    _txtPreferedWidth.Text = PreferedWidth.ToString();
                }
                if (PreferedHeight != 0)
                {
                    _txtPreferedHeight.Text = PreferedHeight.ToString();
                }
            }

            _macroList.DataBind();
        }
        //Returnerar hashkoden för textbeskrivningen av Number+MaxNumber.
        public override int GetHashCode()
        {
            int hashCode = MaxNumber.ToString().GetHashCode();

            hashCode ^= Number.ToString().GetHashCode();

            return(hashCode);
        }
示例#3
0
        private void TextBox_TextChanging(TextBox sender = null, TextBoxTextChangingEventArgs args = null)
        {
            var caret = SelectionStart;

            bool isBadText = !Text.All(c => char.IsNumber(c));

            if (isBadText)
            {
                Text           = m_oldText;
                SelectionStart = Math.Max(0, caret - 1);
                return;
            }

            if (Text.Length == 0)
            {
                Text      = new string('0', MaxLength);
                m_oldText = Text;
                return;
            }

            // if character was deleted
            if (Text.Length < MaxLength)
            {
                Text = new string('0', MaxLength - Text.Length) + Text;
            }
            else if (Text.Length > MaxLength)
            {
                Text = Text.Substring(1);
            }

            SelectionStart = caret;

            int value = int.Parse(Text);

            if (value > MaxNumber)
            {
                Text = MaxNumber.ToString();
            }
            m_oldText = Text;
            return;
        }
示例#4
0
        public void Draw(Vector2 basePosition, float alpha)
        {
            Vector2 pos = Position + new Vector2(leftTexture.Width + (IsModeS ? 2 : 10), 0);

            CacheManager.Draw(IsModeS ? @"Content\Textures\Resources\Start\NumberSetS-Bottom" : @"Content\Textures\Resources\Start\NumberSet-Bottom", new Rectangle(Convert.ToInt32(pos.X + basePosition.X), Convert.ToInt32(pos.Y + basePosition.Y), groundTextureWidth + Widthchange, groundTextureHeight + Heightchange), null, Color.White * alpha, 0f, Vector2.Zero, SpriteEffects.None, 0f);
            if (NowNumber == null)
            {
                NowNumber = 0;
            }
            int width = 0;

            if (MaxNumber != 0)
            {
                width = Convert.ToInt32(NowNumber * (groundTextureWidth + Widthchange) / MaxNumber);
            }
            else
            {
                width = 0;
            }

            //CacheManager.Draw(IsModeS ? @"Content\Textures\Resources\Start\NumberSetS-Fill" : @"Content\Textures\Resources\Start\NumberSet-Fill", new Vector2(Convert.ToInt32(pos.X + basePosition.X) + 2, Convert.ToInt32(pos.Y + basePosition.Y) + 3), new Rectangle(0, 0, width, fillTextureHeight + Heightchange - 3), Color.Orange * alpha);
            CacheManager.Draw(IsModeS ? @"Content\Textures\Resources\Start\NumberSetS-Fill" : @"Content\Textures\Resources\Start\NumberSet-Fill", new Rectangle(Convert.ToInt32(pos.X + basePosition.X) + 2, Convert.ToInt32(pos.Y + basePosition.Y), width - 4, fillTextureHeight + Heightchange), null, Color.White * alpha, 0f, Vector2.Zero, SpriteEffects.None, 0f);

            rightTexture.Draw(new Vector2(basePosition.X + Widthchange, basePosition.Y), Color.White * alpha);
            leftTexture.Draw(basePosition, Color.White * alpha);

            if (DisNumber)
            {
                CacheManager.DrawString(Session.Current.Font, MinNumber.ToString(), leftTexture.Position + basePosition + new Vector2(0, 50), NumColor * alpha);
                CacheManager.DrawString(Session.Current.Font, NowNumber.ToString(), leftTexture.Position + basePosition + new Vector2(64, 50), NumColor * alpha);
                CacheManager.DrawString(Session.Current.Font, MaxNumber.ToString(), leftTexture.Position + basePosition + new Vector2(64 + groundTextureWidth + Widthchange, 50), NumColor * alpha);
            }
            else
            {
                CacheManager.DrawString(Session.Current.Font, DisNumberText ? ViewText + NowNumber.ToString() : NowNumber.ToString(), new Vector2((leftTexture.Position + basePosition + (IsModeS ? new Vector2(55, 3) : new Vector2(156, 8))).X, (leftTexture.Position + basePosition + (IsModeS ? new Vector2(55, 3) : new Vector2(156, 8))).Y + Heightchange), Color.White * alpha, 0f, Vector2.Zero, ((float)leftTexture.Height + Heightchange) / leftTexture.Height, SpriteEffects.None, 0f);
            }
        }
示例#5
0
        public void Draw(Vector2 basePosition, float alpha)
        {
            Vector2 pos = Position + new Vector2(leftTexture.Width + (IsModeS ? 2 : 10), 0);

            CacheManager.Draw(IsModeS ? @"Content\Textures\Resources\Start\NumberSetS-Bottom" : @"Content\Textures\Resources\Start\NumberSet-Bottom", pos + basePosition, Color.White * alpha);
            if (NowNumber == null)
            {
                NowNumber = 0;
            }
            int width = 0;

            if (MaxNumber != 0)
            {
                width = (int)NowNumber * fillTextureWidth / MaxNumber;
            }
            else
            {
                width = 0;
            }

            CacheManager.Draw(IsModeS ? @"Content\Textures\Resources\Start\NumberSetS-Fill" : @"Content\Textures\Resources\Start\NumberSet-Fill", new Vector2(Convert.ToInt32(pos.X + basePosition.X) + 2, Convert.ToInt32(pos.Y + basePosition.Y) + 2), new Rectangle(0, 0, width, fillTextureHeight), Color.Orange * alpha);

            rightTexture.Draw(basePosition, Color.White * alpha);
            leftTexture.Draw(basePosition, Color.White * alpha);

            if (DisNumber)
            {
                CacheManager.DrawString(Session.Current.Font, MinNumber.ToString(), leftTexture.Position + basePosition + new Vector2(0, 50), NumColor * alpha);
                CacheManager.DrawString(Session.Current.Font, NowNumber.ToString(), leftTexture.Position + basePosition + new Vector2(64, 50), NumColor * alpha);
                CacheManager.DrawString(Session.Current.Font, MaxNumber.ToString(), leftTexture.Position + basePosition + new Vector2(64 + groundTextureWidth, 50), NumColor * alpha);
            }
            else
            {
                CacheManager.DrawString(Session.Current.Font, DisNumberText ? ViewText + NowNumber.ToString() : NowNumber.ToString(), leftTexture.Position + basePosition + (IsModeS ? new Vector2(55, 3) : new Vector2(156, 8)), Color.Black * alpha);
            }
        }
示例#6
0
 public override int GetHashCode()
 {
     // Return properties of this object as generated hash. (Number and MaxNumber)
     return((this.ToString("G") + MaxNumber.ToString()).GetHashCode());
 }
        protected override void OnLoad(EventArgs e)
        {
            // startup init script
            WetControls.Extensions.ClientScript.InitScript(Page);

            // datepicker script
            if (IsDate)
            {
                WetControls.Extensions.ClientScript.InitDatePicker(this.Page);
            }
            // gouvernment email script
            if (IsGovernmentEmail)
            {
                WetControls.Extensions.ClientScript.InitFrmvldGovemail(this.Page, this.ErrorGovEmail);
            }
            // price script
            if (IsPrice)
            {
                WetControls.Extensions.ClientScript.InitFrmvldPrice(this.Page, this.ErrorPrice);
            }

            if (EnableClientValidation)
            {
                // attributes validation conflicts
                VerifyValidationConflicts();

                if (IsRequired)
                {
                    base.Attributes.Add("required", "required");
                }
                if (IsPhoneNumber)
                {
                    base.Attributes.Add("data-rule-phoneUS", "true");
                }
                if (IsPostalCode)
                {
                    base.Attributes.Add("size", "7");
                    base.Attributes.Add("data-rule-postalCodeCA", "true");
                }
                if (IsEmail)
                {
                    base.Attributes.Add("type", "email");
                }
                if (IsGovernmentEmail)
                {
                    base.Attributes.Add("data-rule-govemail", "true");
                }
                if (IsUrl)
                {
                    base.Attributes.Add("type", "url");
                }
                if (IsDate)
                {
                    base.Attributes.Add("type", "date");
                    base.Attributes.Add("data-rule-dateISO", "true");
                }
                if (IsTime)
                {
                    base.Attributes.Add("type", "time");
                }
                if (IsAlphanumeric)
                {
                    base.Attributes.Add("pattern", "[A-Za-z0-9_\\s]");
                    base.Attributes.Add("data-rule-alphanumeric", "true");
                }
                if (IsDigitsOnly)
                {
                    base.Attributes.Add("type", "number");
                    base.Attributes.Add("data-rule-digits", "true");
                }
                if (IsPrice)
                {
                    base.Attributes.Add("data-rule-price", "true");
                }
                if (IsLettersOnly)
                {
                    base.Attributes.Add("pattern", "[A-Za-z\\s]");
                    base.Attributes.Add("data-rule-lettersonly", "true");
                }
                if (IsLettersWithBasicPunc)
                {
                    base.Attributes.Add("pattern", "[A-Za-z-.,()'\"\\s]");
                    base.Attributes.Add("data-rule-letterswithbasicpunc", "true");
                }
                if (IsNoWhiteSpace)
                {
                    base.Attributes.Add("pattern", "[A-Za-z-.,()'\"\\s]");
                    base.Attributes.Add("data-rule-nowhitespace", "true");
                }
                if (IsNumber)
                {
                    base.Attributes.Add("type", "number");
                }
                if (MinNumber != 0 && MaxNumber != 0)
                {
                    base.Attributes.Add("data-rule-range", string.Format("[{0},{1}]", MinNumber, MaxNumber));
                }
                else if (MinNumber != 0)
                {
                    base.Attributes.Add("min", MinNumber.ToString());
                }
                else if (MaxNumber != 0)
                {
                    base.Attributes.Add("max", MaxNumber.ToString());
                }
                if (StepNumber != 0)
                {
                    base.Attributes.Add("step", StepNumber.ToString());
                }
                if (MinLength > 0 && MaxLength > 0)
                {
                    base.Attributes.Add("data-rule-rangelength", string.Format("[{0},{1}]", MinLength, MaxLength));
                }
                else if (MinLength > 0)
                {
                    base.Attributes.Add("data-rule-minlength", MinLength.ToString());
                }
                else if (MaxLength > 0)
                {
                    base.Attributes.Add("maxlength", MaxLength.ToString());
                }
                if (MinWords > 0 && MaxWords > 0)
                {
                    base.Attributes.Add("data-rule-rangeWords", string.Format("[{0},{1}]", MinWords, MaxWords));
                }
                else if (MinWords > 0)
                {
                    base.Attributes.Add("data-rule-minWords", MinWords.ToString());
                }
                else if (MaxWords > 0)
                {
                    base.Attributes.Add("data-rule-maxWords", MaxWords.ToString());
                }
                if (!string.IsNullOrEmpty(EqualTo))
                {
                    Control ctrl = Page.FindControlRecursive(EqualTo.TrimStart('#')); // prevent tag at beginning
                    base.Attributes.Add("data-rule-equalTo", (ctrl == null ? "#" + EqualTo : "#" + ctrl.ClientID));
                }
                if (!string.IsNullOrEmpty(ValidationErrorMsg))
                {
                    base.Attributes.Add("data-msg", ValidationErrorMsg);
                }
            }
            if (!string.IsNullOrEmpty(Placeholder))
            {
                base.Attributes.Add("placeholder", Placeholder);
            }

            base.OnLoad(e);
        }
示例#8
0
 public int GetCellSize()
 {
     return(MaxNumber.ToString().Length + 2);
 }