當前位置: 首頁>>代碼示例>>C#>>正文


C# Controls.Decorator類代碼示例

本文整理匯總了C#中Perspex.Controls.Decorator的典型用法代碼示例。如果您正苦於以下問題:C# Decorator類的具體用法?C# Decorator怎麽用?C# Decorator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Decorator類屬於Perspex.Controls命名空間,在下文中一共展示了Decorator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Should_Track_Bounds

        public void Should_Track_Bounds()
        {
            var target = new BoundsTracker();
            var control = default(Rectangle);
            var tree = new Decorator
            {
                Padding = new Thickness(10),
                Content = new Decorator
                {
                    Padding = new Thickness(5),
                    Content = (control = new Rectangle
                    {
                        Width = 15,
                        Height = 15,
                    }),
                }
            };

            tree.Measure(Size.Infinity);
            tree.Arrange(new Rect(0, 0, 100, 100));

            var track = target.Track(control, tree);
            var results = new List<TransformedBounds>();
            track.Subscribe(results.Add);

            Assert.Equal(new Rect(15, 15, 15, 15), results.Last().Bounds);

            tree.Padding = new Thickness(15);
            tree.Measure(Size.Infinity);
            tree.Arrange(new Rect(0, 0, 100, 100), true);

            Assert.Equal(new Rect(20, 20, 15, 15), results.Last().Bounds);
        }
開發者ID:MarkWalls,項目名稱:Perspex,代碼行數:33,代碼來源:BoundsTrackerTests.cs

示例2: Border_Bottom_Aligns_Content

        public void Border_Bottom_Aligns_Content()
        {
            Decorator target = new Decorator
            {
                Padding = new Thickness(8),
                Width = 200,
                Height = 200,
                Child = new Border
                {
                    BorderBrush = Brushes.Black,
                    BorderThickness = 2,
                    Child = new TextBlock
                    {
                        Text = "Foo",
                        Background = Brushes.Red,
                        FontFamily = "Segoe UI",
                        FontSize = 12,
                        VerticalAlignment = VerticalAlignment.Bottom,
                    }
                }
            };

            this.RenderToFile(target);
            this.CompareImages();
        }
開發者ID:Robertofon,項目名稱:Perspex,代碼行數:25,代碼來源:BorderTests.cs

示例3: Polyline_10px_Stroke_PenLineJoin

        public void Polyline_10px_Stroke_PenLineJoin()
        {
            var polylinePoints = new Point[] { new Point(0, 0), new Point(5, 0), new Point(6, -2), new Point(7, 3), new Point(8, -3),
                new Point(9, 1), new Point(10, 0), new Point(15, 0) };

            Decorator target = new Decorator
            {
                Padding = new Thickness(8),
                Width = 400,
                Height = 200,
                Child = new Polyline
                {
                    Stroke = Brushes.Brown,
                    Points = polylinePoints,
                    Stretch = Stretch.Uniform,
                    StrokeJoin = PenLineJoin.Round,
                    StrokeStartLineCap = PenLineCap.Round,
                    StrokeEndLineCap = PenLineCap.Round,
                    StrokeThickness = 10
                }
            };

            RenderToFile(target);
            CompareImages();
        }
開發者ID:KvanTTT,項目名稱:Perspex,代碼行數:25,代碼來源:PolylineTests.cs

示例4: LinearGradientBrush_RedBlue_Vertical_Fill

        public void LinearGradientBrush_RedBlue_Vertical_Fill()
        {
            Decorator target = new Decorator
            {
                Padding = new Thickness(8),
                Width = 200,
                Height = 200,
                Child = new Border
                {
                    Background = new LinearGradientBrush
                    {
                        StartPoint = new RelativePoint(0.5, 0, RelativeUnit.Relative),
                        EndPoint = new RelativePoint(0.5, 1, RelativeUnit.Relative),
                        GradientStops =
                        {
                            new GradientStop { Color = Colors.Red, Offset = 0 },
                            new GradientStop { Color = Colors.Blue, Offset = 1 }
                        }
                    }
                }
            };

            RenderToFile(target);
            CompareImages();
        }
開發者ID:Arlorean,項目名稱:Perspex,代碼行數:25,代碼來源:LinearGradientBrushTests.cs

示例5: Path_Expander_With_Border

        public void Path_Expander_With_Border()
        {
            Decorator target = new Decorator
            {
                Width = 200,
                Height = 200,
                Child = new Border
                {
                    BorderBrush = Brushes.Red,
                    BorderThickness = 1,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center,
                    Child = new Path
                    {
                        Fill = Brushes.Black,
                        Stroke = Brushes.Black,
                        StrokeThickness = 1,
                        Stretch = Stretch.Uniform,
                        Data = StreamGeometry.Parse("M 0 2 L 4 6 L 0 10 Z"),
                    }
                }
            };

            this.RenderToFile(target);
            this.CompareImages();
        }
開發者ID:Robertofon,項目名稱:Perspex,代碼行數:26,代碼來源:PathTests.cs

示例6: Border_Fill

        public void Border_Fill()
        {
            Decorator target = new Decorator
            {
                Padding = new Thickness(8),
                Width = 200,
                Height = 200,
                Child = new Border
                {
                    Background = Brushes.Red,
                }
            };

            RenderToFile(target);
            CompareImages();
        }
開發者ID:Arlorean,項目名稱:Perspex,代碼行數:16,代碼來源:BorderTests.cs

示例7: Circle_1px_Stroke

        public void Circle_1px_Stroke()
        {
            Decorator target = new Decorator
            {
                Padding = new Thickness(8),
                Width = 200,
                Height = 200,
                Child = new Ellipse
                {
                    Stroke = Brushes.Black,
                    StrokeThickness = 1,
                }
            };

            this.RenderToFile(target);
            this.CompareImages();
        }
開發者ID:Scellow,項目名稱:Perspex,代碼行數:17,代碼來源:EllipseTests.cs

示例8: Border_1px_Border

        public void Border_1px_Border()
        {
            Decorator target = new Decorator
            {
                Padding = new Thickness(8),
                Width = 200,
                Height = 200,
                Content = new Border
                {
                    BorderBrush = Brushes.Black,
                    BorderThickness = 1,
                }
            };

            this.RenderToFile(target);
            this.CompareImages();
        }
開發者ID:MarkWalls,項目名稱:Perspex,代碼行數:17,代碼來源:BorderTests.cs

示例9: Rectangle_1px_Stroke

        public void Rectangle_1px_Stroke()
        {
            Decorator target = new Decorator
            {
                Padding = new Thickness(8),
                Width = 200,
                Height = 200,
                Content = new Rectangle
                {
                    Stroke = Brushes.Black,
                    StrokeThickness = 1,
                }
            };

            this.RenderToFile(target);
            this.CompareImages();
        }
開發者ID:MarkWalls,項目名稱:Perspex,代碼行數:17,代碼來源:RectangleTests.cs

示例10: Border_2px_Border

        public void Border_2px_Border()
        {
            Decorator target = new Decorator
            {
                Padding = new Thickness(8),
                Width = 200,
                Height = 200,
                Child = new Border
                {
                    BorderBrush = Brushes.Black,
                    BorderThickness = 2,
                }
            };

            RenderToFile(target);
            CompareImages();
        }
開發者ID:Arlorean,項目名稱:Perspex,代碼行數:17,代碼來源:BorderTests.cs

示例11: Negative_Margin_Larger_Than_Constraint_Should_Request_Height_0

        public void Negative_Margin_Larger_Than_Constraint_Should_Request_Height_0()
        {
            Control target;

            var outer = new Decorator
            {
                Width = 100,
                Height = 100,
                Child = target = new Control
                {
                    Margin = new Thickness(0, -100, 0, 0),
                }
            };

            outer.Measure(Size.Infinity);

            Assert.Equal(0, target.DesiredSize.Height);
        }
開發者ID:KvanTTT,項目名稱:Perspex,代碼行數:18,代碼來源:MeasureTests.cs

示例12: Line_1px_Stroke_Vertical

        public void Line_1px_Stroke_Vertical()
        {
            Decorator target = new Decorator
            {
                Width = 200,
                Height = 200,
                Child = new Line
                {
                    Stroke = Brushes.Black,
                    StrokeThickness = 1,
                    StartPoint = new Point(100, 200),
                    EndPoint = new Point(100, 0)
                }
            };

            RenderToFile(target);
            CompareImages();
        }
開發者ID:KvanTTT,項目名稱:Perspex,代碼行數:18,代碼來源:LineTests.cs

示例13: Tapped_Should_Be_Raised_Even_When_PointerPressed_Handled

        public void Tapped_Should_Be_Raised_Even_When_PointerPressed_Handled()
        {
            Border border;
            var decorator = new Decorator
            {
                Child = border = new Border()
            };
            var result = new List<string>();

            border.AddHandler(Border.PointerPressedEvent, (s, e) => e.Handled = true);
            decorator.AddHandler(Gestures.TappedEvent, (s, e) => result.Add("dt"));
            border.AddHandler(Gestures.TappedEvent, (s, e) => result.Add("bt"));

            border.RaiseEvent(new PointerPressedEventArgs());
            border.RaiseEvent(new PointerReleasedEventArgs());

            Assert.Equal(new[] { "bt", "dt" }, result);
        }
開發者ID:KvanTTT,項目名稱:Perspex,代碼行數:18,代碼來源:GestureTests.cs

示例14: Polygon_NonUniformFill

        public void Polygon_NonUniformFill()
        {
            Decorator target = new Decorator
            {
                Padding = new Thickness(8),
                Width = 400,
                Height = 200,
                Child = new Polygon
                {
                    Stroke = Brushes.DarkBlue,
                    Stretch = Stretch.Fill,
                    Fill = Brushes.Violet,
                    Points = new[] { new Point(5, 0), new Point(8, 8), new Point(0, 3), new Point(10, 3), new Point(2, 8) },
                    StrokeThickness = 5,
                }
            };

            RenderToFile(target);
            CompareImages();
        }
開發者ID:KvanTTT,項目名稱:Perspex,代碼行數:20,代碼來源:PolygonTests.cs

示例15: Path_100px_Triangle_Centered

        public void Path_100px_Triangle_Centered()
        {
            Decorator target = new Decorator
            {
                Width = 200,
                Height = 200,
                Child = new Path
                {
                    Fill = Brushes.Gray,
                    Stroke = Brushes.Red,
                    StrokeThickness = 2,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center,
                    Data = StreamGeometry.Parse("M 0,100 L 100,100 50,0 Z"),
                }
            };

            this.RenderToFile(target);
            this.CompareImages();
        }
開發者ID:Robertofon,項目名稱:Perspex,代碼行數:20,代碼來源:PathTests.cs


注:本文中的Perspex.Controls.Decorator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。