コード例 #1
0
        /// <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();
        }
コード例 #2
0
        public void CalculateTest()
        {
            ITwoArgumentsCalculator calculator = new MaxNumber();
            double result = calculator.Calculate(4, 2);

            Assert.AreEqual(4, result);
        }
コード例 #3
0
        //Returnerar hashkoden för textbeskrivningen av Number+MaxNumber.
        public override int GetHashCode()
        {
            int hashCode = MaxNumber.ToString().GetHashCode();

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

            return(hashCode);
        }
コード例 #4
0
    static void Main(string[] args)
    {
        JsonDeserializer jsonDeserializer = new JsonDeserializer();
        MaxNumber        maxNumber        = new MaxNumber();
        string           json             = File.ReadAllText(args[0]);

        jsonDeserializer = JsonConvert.DeserializeObject <JsonDeserializer>(json);
        Console.WriteLine(maxNumber.showResult(jsonDeserializer.numbers));
    }
コード例 #5
0
        public void Case_0()
        {
            var queries = new[]
            {
                new [] { 1, 5, 3 },
                new [] { 4, 8, 7 },
                new [] { 6, 9, 1 },
            };

            Assert.Equal(10, MaxNumber.arrayManipulation(10, queries));
        }
コード例 #6
0
        public void Case_1()
        {
            var queries = new[]
            {
                new [] { 1, 2, 100 },
                new [] { 2, 5, 100 },
                new [] { 3, 4, 100 },
            };

            Assert.Equal(200, MaxNumber.arrayManipulation(5, queries));
        }
コード例 #7
0
        private Activity GetImplementation()
        {
            var target = new Variable <int>();
            var guess  = new Variable <int>();

            return(new Sequence {
                Variables = { target, guess },
                Activities =
                {
                    new Assign <int>             {
                        To = new OutArgument <int>(target),
                        Value = new InArgument <int>(ctx => new Random().Next(1, MaxNumber.Get(ctx) + 1))
                    },
                    new DoWhile                  {
                        Body = new Sequence      {
                            Activities =
                            {
                                new Prompt       {
                                    BookmarkName = "EnterGuess",
                                    Text = new InArgument <string>(ctx =>
                                                                   "Please enter a number between 1 and " + MaxNumber.Get(ctx)),
                                    Result = new OutArgument <int>(guess)
                                },
                                new Assign <int> {
                                    To = new OutArgument <int>(ctx => Turns.Get(ctx)),
                                    Value = new InArgument <int>(ctx => Turns.Get(ctx) + 1)
                                },
                                new If           {
                                    Condition = new InArgument <bool>(ctx => guess.Get(ctx) != target.Get(ctx)),
                                    Then = new If{
                                        Condition = new InArgument <bool>(ctx => guess.Get(ctx) < target.Get(ctx)),
                                        Then = new WriteLine{
                                            Text = "Your guess is too low."
                                        },
                                        Else = new WriteLine{
                                            Text = "Your guess is too high."
                                        }
                                    }
                                }
                            }
                        },
                        Condition = new LambdaValue <bool>(ctx => guess.Get(ctx) != target.Get(ctx))
                    }
                }
            });
        }
コード例 #8
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;
        }
コード例 #9
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);
            }
        }
コード例 #10
0
ファイル: NumericSetTexture.cs プロジェクト: lemingcen/ZHSan
        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);
            }
        }
コード例 #11
0
 public override int GetHashCode()
 {
     // Return properties of this object as generated hash. (Number and MaxNumber)
     return((this.ToString("G") + MaxNumber.ToString()).GetHashCode());
 }
コード例 #12
0
        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);
        }
コード例 #13
0
 public int GetCellSize()
 {
     return(MaxNumber.ToString().Length + 2);
 }