示例#1
0
        public void DrawingBackgroundBorderBrushNonUniformBorderThicknessIsCheckedRenderMouseOver()
        {
            BulletChrome c = new BulletChrome();

            c.Background      = new SolidColorBrush(Color.FromArgb(0x11, 0x11, 0x11, 0x11));
            c.BorderBrush     = new SolidColorBrush(Color.FromArgb(0x22, 0x22, 0x22, 0x22));
            c.BorderThickness = new Thickness(1, 2, 3, 4);
            c.IsChecked       = true;
            c.RenderMouseOver = true;
            c.Width           = 100;
            c.Height          = 100;
            Window w = new Window();

            w.Content = c;
            w.Show();
            DrawingGroup drawing_group = VisualTreeHelper.GetDrawing(c);

            Assert.AreEqual(drawing_group.Children.Count, 4, "1");

            GeometryDrawing gd = (GeometryDrawing)drawing_group.Children [0];

            Assert.AreEqual(((SolidColorBrush)gd.Brush).Color, ((SolidColorBrush)c.Background).Color, "2");
            Assert.IsNull(gd.Pen, "3");
            RectangleGeometry rg = (RectangleGeometry)gd.Geometry;

            Assert.AreEqual(rg.Rect, new Rect(1, 2, 96, 94), "4");
            Assert.AreEqual(rg.RadiusX, 0, "5");
            Assert.AreEqual(rg.RadiusY, 0, "6");

            gd = (GeometryDrawing)drawing_group.Children [1];
            Assert.IsNull(gd.Brush, "6 2 2");
            Assert.AreEqual(gd.Pen.Thickness, 2, "6 3");
            LinearGradientBrush lgb = (LinearGradientBrush)gd.Pen.Brush;

            Assert.AreEqual(lgb.StartPoint, new Point(0, 0), "6 4");
            Assert.AreEqual(lgb.EndPoint, new Point(1, 1), "6 5");
            Assert.AreEqual(lgb.GradientStops.Count, 2, "6 6");
            Assert.AreEqual(lgb.GradientStops [0].Color, Color.FromArgb(0xFF, 0xFF, 0xF0, 0xCF), "6 7");
            Assert.AreEqual(lgb.GradientStops [0].Offset, 0, "6 8");
            Assert.AreEqual(lgb.GradientStops [1].Color, Color.FromArgb(0xFF, 0xF8, 0xB3, 0x30), "6 9");
            Assert.AreEqual(lgb.GradientStops [1].Offset, 1, "6 10");
            rg = (RectangleGeometry)gd.Geometry;
            Assert.AreEqual(rg.Rect, new Rect(2, 3, 94, 92), "6 11");
            Assert.AreEqual(rg.RadiusX, 0, "6 12");
            Assert.AreEqual(rg.RadiusY, 0, "6 13");

            Assert.AreEqual(((DrawingGroup)drawing_group.Children [2]).Children.Count, 1, "6 1");
            Assert.AreEqual(((TranslateTransform)((DrawingGroup)drawing_group.Children [2]).Transform).Value, new Matrix(1, 0, 0, 1, 0, 1), "6 2");
            gd = (GeometryDrawing)((DrawingGroup)drawing_group.Children [2]).Children [0];
            Assert.AreEqual(((SolidColorBrush)gd.Brush).Color, Color.FromArgb(0xFF, 0x21, 0xA1, 0x21), "7");
            Assert.IsNull(gd.Pen, "8");
            StreamGeometry sg = (StreamGeometry)gd.Geometry;

            Assert.AreEqual(sg.ToString(), "M3;5L3;7,8 5,5;10,4 10,1;5,8 10,1;3 5,5;7,6z", "9");

            gd = (GeometryDrawing)drawing_group.Children [3];
            Assert.IsNull(gd.Pen, "10");
            Assert.AreEqual(((SolidColorBrush)gd.Brush).Color, ((SolidColorBrush)c.BorderBrush).Color, "12");
            Assert.AreEqual(gd.Geometry.ToString(), "M0;0L100;0L100;100L0;100z M1;2L97;2L97;96L1;96z", "13");
        }
示例#2
0
        public void RenderedGeometry()
        {
            TestShape      e = new TestShape();
            Geometry       g = e.RenderedGeometry;
            StreamGeometry stream_geometry = (StreamGeometry)g;

            Assert.AreEqual(stream_geometry.ToString(), "");
        }
示例#3
0
        public void DrawingBackgroundBorderBrushBorderThicknessIsChecked()
        {
            BulletChrome c = new BulletChrome();

            c.Background      = new SolidColorBrush(Color.FromArgb(0x11, 0x11, 0x11, 0x11));
            c.BorderBrush     = new SolidColorBrush(Color.FromArgb(0x22, 0x22, 0x22, 0x22));
            c.BorderThickness = new Thickness(1);
            c.IsChecked       = true;
            c.Width           = 100;
            c.Height          = 100;
            Window w = new Window();

            w.Content = c;
            w.Show();
            DrawingGroup drawing_group = VisualTreeHelper.GetDrawing(c);

            Assert.AreEqual(drawing_group.Children.Count, 3, "1");

            GeometryDrawing gd = (GeometryDrawing)drawing_group.Children [0];

            Assert.AreEqual(((SolidColorBrush)gd.Brush).Color, ((SolidColorBrush)c.Background).Color, "2");
            Assert.IsNull(gd.Pen, "3");
            RectangleGeometry rg = (RectangleGeometry)gd.Geometry;

            Assert.AreEqual(rg.Rect, new Rect(1, 1, 98, 98), "4");
            Assert.AreEqual(rg.RadiusX, 0, "5");
            Assert.AreEqual(rg.RadiusY, 0, "6");

            gd = (GeometryDrawing)drawing_group.Children [1];

            Assert.AreEqual(((SolidColorBrush)gd.Brush).Color, Color.FromArgb(0xFF, 0x21, 0xA1, 0x21), "7");
            Assert.IsNull(gd.Pen, "8");
            StreamGeometry sg = (StreamGeometry)gd.Geometry;

            Assert.AreEqual(sg.ToString(), "M3;5L3;7,8 5,5;10,4 10,1;5,8 10,1;3 5,5;7,6z", "9");

            gd = (GeometryDrawing)drawing_group.Children [2];
            Assert.IsNull(gd.Brush, "10");
            Assert.AreEqual(gd.Pen.Thickness, 1, "11");
            Assert.AreEqual(((SolidColorBrush)gd.Pen.Brush).Color, ((SolidColorBrush)c.BorderBrush).Color, "12");
            rg = (RectangleGeometry)gd.Geometry;
            Assert.AreEqual(rg.Rect, new Rect(0.5, 0.5, 99, 99), "13");
            Assert.AreEqual(rg.RadiusX, 0, "14");
            Assert.AreEqual(rg.RadiusY, 0, "15");
        }
示例#4
0
        public void DrawingBackgroundBorderBrushNonUniformBorderThicknessIsChecked2()
        {
            BulletChrome c = new BulletChrome();

            c.Background      = new SolidColorBrush(Color.FromArgb(0x11, 0x11, 0x11, 0x11));
            c.BorderBrush     = new SolidColorBrush(Color.FromArgb(0x22, 0x22, 0x22, 0x22));
            c.BorderThickness = new Thickness(10, 20, 30, 40);
            c.IsChecked       = true;
            c.Width           = 100;
            c.Height          = 100;
            Window w = new Window();

            w.Content = c;
            w.Show();
            DrawingGroup drawing_group = VisualTreeHelper.GetDrawing(c);

            Assert.AreEqual(drawing_group.Children.Count, 3, "1");

            GeometryDrawing gd = (GeometryDrawing)drawing_group.Children [0];

            Assert.AreEqual(((SolidColorBrush)gd.Brush).Color, ((SolidColorBrush)c.Background).Color, "2");
            Assert.IsNull(gd.Pen, "3");
            RectangleGeometry rg = (RectangleGeometry)gd.Geometry;

            Assert.AreEqual(rg.Rect, new Rect(10, 20, 60, 40), "4");
            Assert.AreEqual(rg.RadiusX, 0, "5");
            Assert.AreEqual(rg.RadiusY, 0, "6");

            Assert.AreEqual(((DrawingGroup)drawing_group.Children [1]).Children.Count, 1, "6 1");
            Assert.AreEqual(((TranslateTransform)((DrawingGroup)drawing_group.Children [1]).Transform).Value, new Matrix(1, 0, 0, 1, 9, 19), "6 2");
            gd = (GeometryDrawing)((DrawingGroup)drawing_group.Children [1]).Children [0];
            Assert.AreEqual(((SolidColorBrush)gd.Brush).Color, Color.FromArgb(0xFF, 0x21, 0xA1, 0x21), "7");
            Assert.IsNull(gd.Pen, "8");
            StreamGeometry sg = (StreamGeometry)gd.Geometry;

            Assert.AreEqual(sg.ToString(), "M3;5L3;7,8 5,5;10,4 10,1;5,8 10,1;3 5,5;7,6z", "9");

            gd = (GeometryDrawing)drawing_group.Children [2];
            Assert.IsNull(gd.Pen, "10");
            Assert.AreEqual(((SolidColorBrush)gd.Brush).Color, ((SolidColorBrush)c.BorderBrush).Color, "12");
            Assert.AreEqual(gd.Geometry.ToString(), "M0;0L100;0L100;100L0;100z M10;20L70;20L70;60L10;60z", "13");
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sg"></param>
 /// <returns></returns>
 public static string ToSource(this StreamGeometry sg)
 {
     return(sg.ToString());
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="sg"></param>
 /// <returns></returns>
 public static string ToSource(this StreamGeometry sg)
 {
     return(sg.ToString(System.Globalization.CultureInfo.InvariantCulture));
 }