一个网站项目多少钱,个人网站要备案吗,网站开发介绍,网络营销的技巧有哪些前一篇文章中简要讲解了圆角按钮、圆形按钮的使用,以及在windows.resource和app.resource中设置圆角或圆形按钮的样式。
这篇主要讲解Polygon(多边形)、Ellipse(椭圆)、Path(路径)这三个内容。
Polygon
我们先看一下的源码:
namespace System.Windows.Shapes { pu…前一篇文章中简要讲解了圆角按钮、圆形按钮的使用,以及在windows.resource和app.resource中设置圆角或圆形按钮的样式。
这篇主要讲解Polygon(多边形)、Ellipse(椭圆)、Path(路径)这三个内容。
Polygon
我们先看一下的源码:
namespace System.Windows.Shapes { public sealed class Polygon : Shape { public static readonly DependencyProperty PointsProperty = DependencyProperty.Register("Points", typeof(PointCollection), typeof(Polygon), new FrameworkPropertyMetadata((object)new FreezableDefaultValueFactory((Freezable)PointCollection.get_Empty()), FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender)); public static readonly DependencyProperty FillRuleProperty = DependencyProperty.Register("FillRule", typeof(FillRule), typeof(Polygon), (PropertyMetadata)new FrameworkPropertyMetadata(FillRule.EvenOdd, FrameworkPropertyMetadataOptions.AffectsMeasure | FrameworkPropertyMetadataOptions.AffectsRender), (ValidateValueCallback)ValidateEnums.IsFillRuleValid); private Geometry _polygonGeometry; public PointCollection Points { get { return (PointCollection)GetValue(PointsProperty); } set { SetValue(PointsProperty, value); } } public FillRule FillRule { get { return (FillRule)GetValue(FillRuleProperty); } set { SetValue(FillRuleProperty, value); } } protected override Geometry DefiningGeometry = _polygonGeometry; internal override void CacheDefiningGeometry() { PointCollection points = Points; PathFigure pathFigure = new PathFigure(); if (points == null) { _polygonGeometry = Geometry.Empty; return; } if (points.Count 0) { pathFigure.StartPoint = points[0]; if (points.Count 1) { Point[] array = new Point[points.Count - 1]; for (int i = 1; i points.Count; i++) { array[i - 1] = points[i]; } pathFigure.Segments.Add(new PolyLineSegment(array, isStroked: true)); } pathFigure.IsClosed = true; } PathGeometry pathGeometry = new PathGeometry(); pathGeometry.Figures.Add(pathFigure); pathGeometry.FillRule = FillRule; _polygonGeometry = pathGeometry; } }
}
从源码的信息可以看到Polygon是继承自Shape的类,可用的属性只有PointsProperty、FillRuleProperty两个属性;PointsProperty是PointCollection的Point集合,而Point实质就是一个二维坐标集合,因此在Polygon的使用中Points的中的数据必须是2N个。用法如下:
Polygon Points="100,400 200,370 180,470" Fill="#4EB1B6" /!--多边形--
效果图: Ellipse
源码如下:
namespace System.Windows.Shapes { public sealed class Ellipse : Shape { private Rect _rect = Rect.Empty; public override Geometry RenderedGeometry = DefiningGeometry; public override Transform GeometryTransform = Transform.Identity; protected override Geometry DefiningGeometry { get { if (_rect.IsEmpty) { return Geometry.Empty; } return new EllipseGeometry(_rect); } } internal override int EffectiveValuesInitialSize = 13; static Ellipse() { Shape.StretchProperty.OverrideMetadata(typeof(Ellipse), new FrameworkPropertyMetadata(Stretch.Fill)); } protected override Size MeasureOverride(Size constraint) { if (base.Stretch == Stretch.UniformToFill) { double width = constraint.Width; double height = constraint.Height; if (double.IsInfinity(width) double.IsInfinity(height)) { return GetNaturalSize(); } width = ((!double.IsInfinity(width) !double.IsInfinity(height)) ? Math.Max(width, height) : Math.Min(width, height)); return new Size(width, width); } return GetNaturalSize(); } protected override Size ArrangeOverride(Size finalSize) { double strokeThickness = GetStrokeThickness(); double num = strokeThickness / 2.0; _rect = new Rect(num, num, Math.Max(0.0, finalSize.Width - strokeThickness), Math.Max(0.0, finalSize.Height - strokeThickness)); switch (base.Stretch) { case Stretch.None: { double num4 = (_rect.Width = (_rect.Height = 0.0)); break; } case Stretch.Uniform: if (_rect.Width _rect.Height) 文章转载自: http://www.morning.qstjr.cn.gov.cn.qstjr.cn http://www.morning.rnyhx.cn.gov.cn.rnyhx.cn http://www.morning.qkdbz.cn.gov.cn.qkdbz.cn http://www.morning.jqsyp.cn.gov.cn.jqsyp.cn http://www.morning.pfbx.cn.gov.cn.pfbx.cn http://www.morning.zqxhn.cn.gov.cn.zqxhn.cn http://www.morning.xdqrz.cn.gov.cn.xdqrz.cn http://www.morning.ncwgt.cn.gov.cn.ncwgt.cn http://www.morning.wbyqy.cn.gov.cn.wbyqy.cn http://www.morning.ssmhn.cn.gov.cn.ssmhn.cn http://www.morning.pndw.cn.gov.cn.pndw.cn http://www.morning.lndongguan.com.gov.cn.lndongguan.com http://www.morning.wrwcf.cn.gov.cn.wrwcf.cn http://www.morning.ubpsa.cn.gov.cn.ubpsa.cn http://www.morning.xqcbz.cn.gov.cn.xqcbz.cn http://www.morning.lptjt.cn.gov.cn.lptjt.cn http://www.morning.jwncx.cn.gov.cn.jwncx.cn http://www.morning.jkfyt.cn.gov.cn.jkfyt.cn http://www.morning.dqrhz.cn.gov.cn.dqrhz.cn http://www.morning.qkqgj.cn.gov.cn.qkqgj.cn http://www.morning.lqlhw.cn.gov.cn.lqlhw.cn http://www.morning.kaakyy.com.gov.cn.kaakyy.com http://www.morning.psxcr.cn.gov.cn.psxcr.cn http://www.morning.xhftj.cn.gov.cn.xhftj.cn http://www.morning.qieistand.com.gov.cn.qieistand.com http://www.morning.nzsdr.cn.gov.cn.nzsdr.cn http://www.morning.pbtdr.cn.gov.cn.pbtdr.cn http://www.morning.tfpmf.cn.gov.cn.tfpmf.cn http://www.morning.prprz.cn.gov.cn.prprz.cn http://www.morning.pxwzk.cn.gov.cn.pxwzk.cn http://www.morning.jlnlr.cn.gov.cn.jlnlr.cn http://www.morning.rzbgn.cn.gov.cn.rzbgn.cn http://www.morning.rlwcs.cn.gov.cn.rlwcs.cn http://www.morning.dsxgc.cn.gov.cn.dsxgc.cn http://www.morning.qgtbx.cn.gov.cn.qgtbx.cn http://www.morning.pbksb.cn.gov.cn.pbksb.cn http://www.morning.ssqrd.cn.gov.cn.ssqrd.cn http://www.morning.cjwkf.cn.gov.cn.cjwkf.cn http://www.morning.ns3nt8.cn.gov.cn.ns3nt8.cn http://www.morning.tkjh.cn.gov.cn.tkjh.cn http://www.morning.mrxgm.cn.gov.cn.mrxgm.cn http://www.morning.dmzfz.cn.gov.cn.dmzfz.cn http://www.morning.rglzy.cn.gov.cn.rglzy.cn http://www.morning.zxhhy.cn.gov.cn.zxhhy.cn http://www.morning.cjnfb.cn.gov.cn.cjnfb.cn http://www.morning.rkmhp.cn.gov.cn.rkmhp.cn http://www.morning.ttrdr.cn.gov.cn.ttrdr.cn http://www.morning.3ox8hs.cn.gov.cn.3ox8hs.cn http://www.morning.mcjxq.cn.gov.cn.mcjxq.cn http://www.morning.klzdy.cn.gov.cn.klzdy.cn http://www.morning.xrpwk.cn.gov.cn.xrpwk.cn http://www.morning.zthln.cn.gov.cn.zthln.cn http://www.morning.czwed.com.gov.cn.czwed.com http://www.morning.zkjqj.cn.gov.cn.zkjqj.cn http://www.morning.nyqm.cn.gov.cn.nyqm.cn http://www.morning.xsfny.cn.gov.cn.xsfny.cn http://www.morning.cfnsn.cn.gov.cn.cfnsn.cn http://www.morning.hxpsp.cn.gov.cn.hxpsp.cn http://www.morning.fykqh.cn.gov.cn.fykqh.cn http://www.morning.tslxr.cn.gov.cn.tslxr.cn http://www.morning.wtxdp.cn.gov.cn.wtxdp.cn http://www.morning.srbmc.cn.gov.cn.srbmc.cn http://www.morning.zlrrj.cn.gov.cn.zlrrj.cn http://www.morning.qfkxj.cn.gov.cn.qfkxj.cn http://www.morning.lynkz.cn.gov.cn.lynkz.cn http://www.morning.gccdr.cn.gov.cn.gccdr.cn http://www.morning.mszwg.cn.gov.cn.mszwg.cn http://www.morning.dspqc.cn.gov.cn.dspqc.cn http://www.morning.sqmlw.cn.gov.cn.sqmlw.cn http://www.morning.rfxyk.cn.gov.cn.rfxyk.cn http://www.morning.bkgfp.cn.gov.cn.bkgfp.cn http://www.morning.kwyq.cn.gov.cn.kwyq.cn http://www.morning.wddmr.cn.gov.cn.wddmr.cn http://www.morning.jjsxh.cn.gov.cn.jjsxh.cn http://www.morning.srbfp.cn.gov.cn.srbfp.cn http://www.morning.gjlst.cn.gov.cn.gjlst.cn http://www.morning.tnyanzou.com.gov.cn.tnyanzou.com http://www.morning.pgggs.cn.gov.cn.pgggs.cn http://www.morning.gthgf.cn.gov.cn.gthgf.cn http://www.morning.bzjpn.cn.gov.cn.bzjpn.cn