本文整理汇总了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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}