本文整理汇总了C#中System.Windows.CornerRadius类的典型用法代码示例。如果您正苦于以下问题:C# CornerRadius类的具体用法?C# CornerRadius怎么用?C# CornerRadius使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CornerRadius类属于System.Windows命名空间,在下文中一共展示了CornerRadius类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Comment
public Comment(Node hostNode)
{
HostNode = hostNode;
var scrollViewer = new ScrollViewer
{
HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
VerticalScrollBarVisibility = ScrollBarVisibility.Visible,
Height = 70,
CanContentScroll = true
};
var textBlock = new TextBlock
{
Background = Brushes.Transparent,
TextWrapping = TextWrapping.Wrap,
Margin = new Thickness(5),
FontSize = 12
};
Child = scrollViewer;
CornerRadius = new CornerRadius(5);
scrollViewer.Content = textBlock;
var bindingTextToTextBlock = new Binding("Text")
{
Source = this,
Mode = BindingMode.OneWay
};
textBlock.SetBinding(TextBlock.TextProperty, bindingTextToTextBlock);
hostNode.SpaceCanvas.Children.Add(this);
}
示例2: Convert
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values.Length < 2)
throw new ArgumentException(string.Format("not enough arguments, expected 2, but {0} present", values.Length));
Align align;
Enum.TryParse(values[0].ToString(), out align);
double val = 0.0;
double.TryParse(values[1].ToString(), out val);
CornerRadius radius = new CornerRadius();
if ((align & Align.TopRight) == Align.TopRight)
{
radius.TopRight = val;
}
if ((align & Align.TopLeft) == Align.TopLeft)
{
radius.TopLeft = val;
}
if ((align & Align.BottomRight) == Align.BottomRight)
{
radius.BottomRight = val;
}
if ((align & Align.BottomLeft) == Align.BottomLeft)
{
radius.BottomLeft = val;
}
return radius;
}
示例3: AlmostEquals
/// <summary>Checks whether two nullable corner radii are close enough to be considered equal.</summary>
/// <summary>Use this method instead of strict equality check to reduce the chance for floating-point errors.</summary>
public static bool AlmostEquals(this CornerRadius? c1, CornerRadius? c2) {
if (c1.HasValue && c2.HasValue) {
return c1.Value.AlmostEquals(c2.Value);
} else {
return !c1.HasValue && !c2.HasValue;
}
}
示例4: CheckProperties
static void CheckProperties (CornerRadius cr, double value)
{
Assert.AreEqual (value, cr.TopLeft, "TopLeft");
Assert.AreEqual (value, cr.TopRight, "TopRight");
Assert.AreEqual (value, cr.BottomRight, "BottomRight");
Assert.AreEqual (value, cr.BottomLeft, "BottomLeft");
}
示例5: WidgetActionBarStyle
public WidgetActionBarStyle()
{
BackgroundOpacity = 0.5;
CornerRadius = new CornerRadius(4);
BackgroundColor = Color.FromRgb(32, 32, 32);
TextColor = Colors.WhiteSmoke;
HorizontalAlignment = HorizontalAlignment.Center;
VerticalAlignment = VerticalAlignment.Top;
}
示例6: Border
public void Border(CornerRadius CornerRadius, Color culoare, Thickness thickness, double Width, double Height)
{
myBorder.Width = Width;
myBorder.Height = Height;
myBorder.BorderThickness = thickness;
myBorder.BorderBrush = new SolidColorBrush(culoare);
myBorder.CornerRadius = CornerRadius;
}
示例7: OnCornerRadiusChanged
protected virtual void OnCornerRadiusChanged(CornerRadius oldValue, CornerRadius newValue)
{
//we always want the InnerBorderRadius to be one less than the CornerRadius
CornerRadius newInnerCornerRadius = new CornerRadius(Math.Max(0, newValue.TopLeft - 1),
Math.Max(0, newValue.TopRight - 1),
Math.Max(0, newValue.BottomRight - 1),
Math.Max(0, newValue.BottomLeft - 1));
InnerCornerRadius = newInnerCornerRadius;
}
示例8: ConfigureFromNode
public override void ConfigureFromNode(System.Xml.Linq.XElement node)
{
base.ConfigureFromNode(node);
Banner = XmlUtilities.GetTextFromAttribute(node, "banner");
BorderSize = XmlUtilities.ConvertFromAttributeUsingConverter(
node, "borderSize", new ThicknessConverter(), new Thickness(0));
BorderColor = XmlUtilities.GetTextFromAttribute(node, "borderColor");
CornerRadius = XmlUtilities.ConvertFromAttributeUsingConverter(
node, "cornerRadius", new CornerRadiusConverter(), new CornerRadius(0));
}
示例9: DrawRectangle
/// <summary>See <c>WpfExtensions</c> for details.</summary>
public static void DrawRectangle(DrawingContext dc, Rect rect, Paint paint, CornerRadius corners, CornerStyle cornerStyle, BorderSide borderSide, bool snapToPixel) {
// get brush and stroke resources
if (paint == null) return;
var fill = paint.Fill;
var strokes = paint.GetStrokePens().ToArray();
var hasFill = (fill != null);
var hasStroke = (strokes.Length > 0 && borderSide != BorderSide.None);
if (!hasFill && !hasStroke) return;
// compute the drawing rectangle with offset for pixel snapping
// (assumptions: the box itself is pixel snapped, all strokes have same thickness, and the thickness is a whole number)
var halfThickness = Math.Round(hasStroke ? strokes[0].Thickness : 0.0) / 2;
if (snapToPixel && hasStroke) {
rect = new Rect(rect.X + halfThickness, rect.Y + halfThickness, (rect.Width - 2 * halfThickness).Max(0), (rect.Height - 2 * halfThickness).Max(0));
}
// select drawing function based on the corners complexity
DrawingFunction fillFunc = null;
if (corners.IsZero()) {
fillFunc = _drawSimpleRectangle;
} else if (corners.IsUniform()) {
fillFunc = _drawRoundedRectangle;
} else {
fillFunc = _drawComplexRectangle;
}
// draw the border
if (hasStroke) {
if (paint.IsA<QuadPaint>()) {
rect = _drawSide(dc, rect, null, strokes[0], corners, cornerStyle, BorderSide.Left);
rect = _drawSide(dc, rect, null, strokes[1], corners, cornerStyle, BorderSide.Top);
rect = _drawSide(dc, rect, null, strokes[2], corners, cornerStyle, BorderSide.Right);
rect = _drawSide(dc, rect, null, strokes[3], corners, cornerStyle, BorderSide.Bottom);
corners = _inflateCorners(corners, strokes[3]);
} else {
var strokeFunc = (borderSide == BorderSide.All ? fillFunc : _drawSide);
foreach (var stroke in strokes) {
rect = strokeFunc(dc, rect, null, stroke, corners, cornerStyle, borderSide);
corners = _inflateCorners(corners, stroke);
}
}
}
// draw the background
if (hasFill) {
if (snapToPixel) {
rect = _deflateRect(rect, -halfThickness);
}
if (paint.FillMode == BrushMappingMode.Absolute) {
fill = _mapAbsoluteFill(fill, rect);
}
fillFunc(dc, rect, fill, null, corners, cornerStyle, borderSide);
}
}
示例10: ShouldShareCornerRadiusValueWithBorder
public void ShouldShareCornerRadiusValueWithBorder()
{
var radius1 = new CornerRadius(1, 2, 3, 4);
model.CornerRadius = radius1;
model.Border.CornerRadius.ShouldBe(radius1);
var radius2 = new CornerRadius(9,8,7,6);
model.Border.CornerRadius = radius2;
model.CornerRadius.ShouldBe(radius2);
}
示例11: Convert
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double d = parameter != null ? double.Parse(parameter.ToString()) : -1;
CornerRadius r = (CornerRadius)value;
CornerRadius result = new CornerRadius(
Math.Max(0, r.TopLeft + d),
Math.Max(0, r.TopRight + d),
Math.Max(0, r.BottomRight + d),
Math.Max(0, r.BottomLeft + d));
return result;
}
示例12: HtmlBorderRenderElement
public HtmlBorderRenderElement(IRenderQueue renderQueue, IHtmlValueConverter converter)
: base(renderQueue)
{
this.converter = converter;
bounds = Rect.Zero;
borderThickness = Thickness.Zero;
cornerRadius = CornerRadius.Zero;
Style.SetValue("background-clip", "content-box");
Style.SetBackground(Background, converter);
Style.SetBorderThickness(BorderThickness, converter);
Style.SetBounds(new Rect(Bounds.Location, (Bounds.Size - BorderThickness.Size).Max(Size.Zero)), converter);
Style.SetBorderBrush(BorderBrush, converter);
Style.SetCornerRadius(cornerRadius, converter);
Style.SetIsHitTestVisible(IsHitTestVisible && Background != null);
}
示例13: CtorFourDoubles
public void CtorFourDoubles ()
{
CornerRadius cr = new CornerRadius (4, 3, 2, 1);
Assert.AreEqual ("4,3,2,1", cr.ToString (), "ToString");
CornerRadius cr2 = new CornerRadius (4, 3, 2, 1);
Assert.IsTrue (cr == cr2, "== true");
Assert.IsFalse (cr != cr2, "== false");
cr.TopLeft = 0;
cr.TopRight = 0;
cr.BottomRight = 0;
cr.BottomLeft = 0;
CheckProperties (cr, 0);
Assert.IsFalse (cr == cr2, "== false");
Assert.IsTrue (cr != cr2, "== true");
}
示例14: FlexButton
public FlexButton()
{
HighlightMargin = new Thickness(0);
HighlightBrightness = 100;
GlowColor = Brushes.WhiteSmoke;
OuterBorderBrush = Brushes.Gray;
InnerBorderBrush = new LinearGradientBrush(Colors.White, Colors.LightGray, 90);
InnerBorderThickness = new Thickness(1);
CornerRadius = new CornerRadius(3);
UpdateButtonColor(this, Brushes.Gainsboro);
Foreground = Brushes.Black;
IsEnabledChanged += FlexButtonIsEnabledChanged;
}
示例15: AddCornerRadius
public void AddCornerRadius(CornerRadius th, string prefix, string suffix = null)
{
// if (th.IsZero()) return;
if (th.TopLeft == th.TopRight && th.TopRight== th.BottomLeft && th.BottomLeft == th.BottomRight)
{
if (0 != th.TopLeft)
{
AddComposed(th.TopLeft + "px", prefix, suffix);
}
}
else
{
// TODO:
/*AddComposed(th.Left + "px", prefix, "left", suffix);
AddComposed(th.Top + "px", prefix, "top", suffix);
AddComposed(th.Right + "px", prefix, "right", suffix);
AddComposed(th.Bottom + "px", prefix, "bottom", suffix);*/
}
}