コード例 #1
0
ファイル: SizeUtils.cs プロジェクト: Egaros/lib
        internal static Size Round(Size size, RoundingMode roundingMode, int digits = 0)
        {
            var width  = DoubleUtils.Round(size.Width, digits, roundingMode);
            var height = DoubleUtils.Round(size.Height, digits, roundingMode);

            return(new Size(width, height));
        }
コード例 #2
0
ファイル: RoundingConverter.cs プロジェクト: Egaros/lib
        protected override object ConvertCore(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var roundingMode = RoundingMode.MidPointFromZero;

            if (value is double)
            {
                var dblValue = (double)value;

                return(DoubleUtils.Round(dblValue, Digits, roundingMode));
            }

            if (value is Point)
            {
                var ptValue = (Point)value;

                return(PointUtils.Round(ptValue, roundingMode, Digits));
            }

            if (value is Size)
            {
                var szValue = (Size)value;

                return(SizeUtils.Round(szValue, roundingMode, Digits));
            }

            if (value is Rect)
            {
                var rcValue = (Rect)value;

                return(RectUtils.Round(rcValue, roundingMode, Digits));
            }

            return(value);
        }
コード例 #3
0
        public void DoubleUtils_Round1()
        {
            double?double1 = new double?(1.0);
            long?  result  = DoubleUtils.Round(double1);

            Assert.IsNotNull(result);
            Assert.AreEqual((byte)1, (byte)result);
            Assert.AreEqual((short)1, (short)result);
            Assert.AreEqual(1, (int)result);
            Assert.AreEqual(1L, (long)result);
            Assert.AreEqual(1.0f, (float)result, 1.0f);
            Assert.AreEqual(1.0, (long)result, 1.0);
            Assert.AreEqual("1", result.Value.ToString("0", CultureInfo.InvariantCulture));
        }
コード例 #4
0
 private static double FinalRound(double value)
 {
     return(DoubleUtils.Round(value, 2, RoundingMode.MidPointToEven));
 }
コード例 #5
0
 public double RoundY(double value, RoundingMode roundingMode)
 {
     return(DoubleUtils.Round(value, roundingMode));
 }
コード例 #6
0
 public double RoundY(double value, RoundingMode roundingMode)
 {
     return(FinalRound(DownScaleY(DoubleUtils.Round(UpScaleY(value), roundingMode))));
 }
コード例 #7
0
ファイル: ArtboardSnapGrid.cs プロジェクト: Egaros/lib
 private static double Calc(double value, double gridStep, bool visible)
 {
     return(visible ? gridStep * DoubleUtils.Round(value / gridStep, RoundingMode.MidPointFromZero) : value);
 }
コード例 #8
0
 internal static double RoundMidPointToEven(this double self, int precision)
 {
     return(DoubleUtils.Round(self, precision, RoundingMode.MidPointToEven));
 }
コード例 #9
0
 internal static double RoundMidPointFromZero(this double self)
 {
     return(DoubleUtils.Round(self, RoundingMode.MidPointFromZero));
 }
コード例 #10
0
 internal static double RoundFromZero(this double self, int precision)
 {
     return(DoubleUtils.Round(self, precision, RoundingMode.FromZero));
 }
コード例 #11
0
 internal static double RoundToZero(this double self)
 {
     return(DoubleUtils.Round(self, RoundingMode.ToZero));
 }