Exemplo n.º 1
0
        /// <summary>
        /// Gets new width for changing height
        /// </summary>
        /// <param name="original">Original square</param>
        /// <param name="newWidth">New width</param>
        /// <returns>Width given original item was resized</returns>
        public static Square HeightChange(Square original, int newWidth)
        {
            var returnValue = new Square();
            var multiplier  = TypeExtension.DefaultDecimal;

            // Height is only specified, have to calculate width
            multiplier = Arithmetic.Divide(newWidth.ToDecimal(), original.Width.ToDecimal());
            // Resize
            returnValue.Height = Arithmetic.Multiply(original.Height.ToDecimal(), multiplier).ToInt();

            return(returnValue);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets new width for changing height
        /// </summary>
        /// <param name="originalWidth">Original items width</param>
        /// <param name="originanHeight">Original items heigth</param>
        /// <param name="newHeight">New height</param>
        /// <returns>Width given original item was resized</returns>
        public static int WidthGet(int originalWidth, int originanHeight, int newHeight)
        {
            var newWidth   = TypeExtension.DefaultInteger;
            var multiplier = TypeExtension.DefaultDecimal;

            // Height is only specified, have to calculate width
            multiplier = Arithmetic.Divide(newHeight.ToDecimal(), originanHeight.ToDecimal());
            // Resize
            newWidth = Arithmetic.Multiply(originalWidth.ToDecimal(), multiplier).ToInt();

            return(newWidth);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Generates a random value with the given length
        /// </summary>
        /// <param name="digits">Number of digits to be returned. Only values between 1 and 10 will be accepted</param>
        /// <returns>Random number</returns>
        public static int Random(int digits = 4)
        {
            var returnValue = TypeExtension.DefaultInteger;

            // Handle for Int32 limitation of 2,147,483,647, low 10 digits
            digits = digits < 1 ? 1 : digits > 10 ? 10 : digits;
            var floor   = Convert.ToInt32(Math.Pow(10, digits - 1));
            var ceiling = Convert.ToInt32((floor * 10) - 1);

            returnValue = Arithmetic.Random(floor, ceiling);

            return(returnValue);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Gets Leas Common Multiplier
 /// </summary>
 /// <param name="num1">First to get LCD</param>
 /// <param name="num2">Second to get LCD</param>
 /// <returns>Least common denominator</returns>
 public static int LCM(int num1, int num2)
 {
     return((num1 * num2) / Arithmetic.GCD(num1, num2));
 }