示例#1
0
        public void Ctor2ArgTest(double min0, double max0, bool vaiid1, double extent1, Order order1)
        {
            Range ut0 = new Range(min0, max0);

            Assert.Equal(Math.Min(min0, max0), ut0.Min);
            Assert.Equal(Math.Max(min0, max0), ut0.Max);
            Assert.Equal(order1, ut0.Order);
            Assert.Equal(vaiid1, ut0.IsValid);
            Assert.Equal(extent1, ut0.Extent);
        }
示例#2
0
        public void Ctor3ArgTest(Order order0, double min0, double max0, bool vaiid1, double extent1)
        {
            Range ut0 = new Range(order0, min0, max0);

            Assert.Equal(order0, ut0.Order);
            Assert.Equal(min0, ut0.Min);
            Assert.Equal(max0, ut0.Max);
            Assert.Equal(vaiid1, ut0.IsValid);
            Assert.Equal(extent1, ut0.Extent);
        }
示例#3
0
        public void ParseTest(string s0, bool valid, Order order, double min, double max)
        {
            Range r1 = Range.Parse(s0);

            Assert.Equal(valid, r1.IsValid);
            if (valid)
            {
                Assert.Equal(order, r1.Order);
                Assert.Equal(min, r1.Min);
                Assert.Equal(max, r1.Max);
            }
        }
        public void GetTransformTest(Orientation orientation, string xrange, string yrange, string size, string[] pp0, string[] pp1)
        {
            Range     xr0 = Range.Parse(xrange);
            Range     yr0 = Range.Parse(yrange);
            Size      s0  = Size.Parse(size);
            Transform t   = TransformSupport.GetTransform(orientation, xr0, yr0, s0);

            for (int i = 0; i < pp0.Length; ++i)
            {
                Point p0 = Point.Parse(pp0[i]);
                Point p1 = Point.Parse(pp1[i]);
                Point p  = t.Transform(p0);
                Assert.Equal(p1.X, p.X, 5);
                Assert.Equal(p1.Y, p.Y, 5);
            }
        }
示例#5
0
 public static Transform GetTransform(Orientation orientation, Range xRange, Range yRange, Size size)
 {
     if (orientation == Orientation.Horizontal)
     {
         if (xRange.Order == Order.Ascending && yRange.Order == Order.Ascending)
         {
             return(new TransformGroup()
             {
                 Children =
                 {
                     new TranslateTransform(-xRange.Min, -yRange.Min), new ScaleTransform(size.Width / xRange.Extent, -size.Height / yRange.Extent),
                     new TranslateTransform(0.0,         size.Height)
                 }
             });
         }
         else if (xRange.Order == Order.Ascending && yRange.Order == Order.Descending)
         {
             return(new TransformGroup()
             {
                 Children =
                 {
                     new TranslateTransform(-xRange.Min, -yRange.Min), new ScaleTransform(size.Width / xRange.Extent, size.Height / yRange.Extent),
                     new TranslateTransform(0.0, 0.0)
                 }
             });
         }
         else if (xRange.Order == Order.Descending && yRange.Order == Order.Ascending)
         {
             return(new TransformGroup()
             {
                 Children =
                 {
                     new TranslateTransform(-xRange.Min, -yRange.Min), new ScaleTransform(-size.Width / xRange.Extent, -size.Height / yRange.Extent),
                     new TranslateTransform(size.Width,  size.Height)
                 }
             });
         }
         else
         {
             return(new TransformGroup()
             {
                 Children =
                 {
                     new TranslateTransform(-xRange.Min, -yRange.Min), new ScaleTransform(-size.Width / xRange.Extent, size.Height / yRange.Extent),
                     new TranslateTransform(size.Width, 0.0)
                 }
             });
         }
     }
     else
     {
         if (xRange.Order == Order.Ascending && yRange.Order == Order.Ascending)
         {
             return(new TransformGroup()
             {
                 Children =
                 {
                     new TranslateTransform(-xRange.Min,               -yRange.Min), new ScaleTransform(size.Height / xRange.Extent, size.Width / yRange.Extent),
                     new RotateTransform(-90),           new TranslateTransform(0.0, size.Height)
                 }
             });
         }
         else if (xRange.Order == Order.Ascending && yRange.Order == Order.Descending)
         {
             return(new TransformGroup()
             {
                 Children =
                 {
                     new TranslateTransform(-xRange.Min,                      -yRange.Min), new ScaleTransform(size.Height / xRange.Extent, -size.Width / yRange.Extent),
                     new RotateTransform(-90),           new TranslateTransform(size.Width, size.Height)
                 }
             });
         }
         else if (xRange.Order == Order.Descending && yRange.Order == Order.Ascending)
         {
             return(new TransformGroup()
             {
                 Children =
                 {
                     new TranslateTransform(-xRange.Min,               -yRange.Min), new ScaleTransform(size.Height / xRange.Extent, -size.Width / yRange.Extent),
                     new RotateTransform(90),            new TranslateTransform(0.0, 0.0)
                 }
             });
         }
         else
         {
             return(new TransformGroup()
             {
                 Children =
                 {
                     new TranslateTransform(-xRange.Min,                      -yRange.Min), new ScaleTransform(size.Height / xRange.Extent, size.Width / yRange.Extent),
                     new RotateTransform(90),            new TranslateTransform(size.Width, 0.0)
                 }
             });
         }
     }
 }