本文整理汇总了C#中System.Windows.Media.PathGeometry.AddGeometry方法的典型用法代码示例。如果您正苦于以下问题:C# PathGeometry.AddGeometry方法的具体用法?C# PathGeometry.AddGeometry怎么用?C# PathGeometry.AddGeometry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.PathGeometry
的用法示例。
在下文中一共展示了PathGeometry.AddGeometry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAnimation
/// <summary>
/// Create the animation and add it to the master timeline
/// </summary>
protected override void CreateAnimation()
{
var geometry = new PathGeometry();
geometry.AddGeometry(Geometry.Parse("M 10,100 C 10,300 300,-200 300,100"));
var animationX = new DoubleAnimationUsingPath
{
PathGeometry = geometry,
Duration = new Duration(this.AnimationConfiguration.Duration),
Source = PathAnimationSource.X
};
var animationY = new DoubleAnimationUsingPath
{
PathGeometry = geometry,
Duration = new Duration(this.AnimationConfiguration.Duration),
Source = PathAnimationSource.Y
};
Storyboard.SetTargetProperty(animationX, new PropertyPath(Canvas.LeftProperty));
Storyboard.SetTargetProperty(animationY, new PropertyPath(Canvas.TopProperty));
animationX.Freeze();
animationY.Freeze();
this.MasterStoryboard.Children.Add(animationX);
this.MasterStoryboard.Children.Add(animationY);
}
示例2: OnRender
protected override void OnRender(DrawingContext drawingContext) {
base.OnRender(drawingContext);
if (hexBox.Selection == null || hexBox.VisibleBytesPerLine < 1)
return;
ulong selStart = hexBox.Selection.Value.StartOffset;
ulong selEnd = hexBox.Selection.Value.EndOffset;
int lines = hexBox.VisibleLinesPerPage;
ulong bpl = (ulong)hexBox.VisibleBytesPerLine;
ulong visibleStart = hexBox.TopOffset;
ulong visibleEnd = NumberUtils.AddUInt64(NumberUtils.AddUInt64(visibleStart, NumberUtils.MulUInt64(bpl, NumberUtils.SubUInt64((ulong)lines, 1))), NumberUtils.SubUInt64(bpl, 1));
if (selStart > visibleEnd || selEnd < visibleStart)
return;
ulong offset = Math.Max(selStart, visibleStart);
ulong endOffset = Math.Min(selEnd, visibleEnd);
double x = -hexBox.CharacterWidth * hexBox.LeftColumn;
double y = (offset - hexBox.TopOffset) / bpl * hexBox.CharacterHeight;
var path = new PathGeometry();
double hexByteX = hexBox.GetHexByteColumnIndex() * hexBox.CharacterWidth;
double asciiX = hexBox.GetAsciiColumnIndex() * hexBox.CharacterWidth;
while (offset <= endOffset) {
ulong byteIndex = hexBox.GetLineByteIndex(offset);
ulong count = Math.Min(bpl - byteIndex, endOffset - offset + 1);
double dx = byteIndex * hexBox.CharacterWidth;
var rectGeo = new RectangleGeometry(new Rect(x + dx * 3 + hexByteX + hexBox.CharacterWidth, y, count * hexBox.CharacterWidth * 3 - hexBox.CharacterWidth, hexBox.CharacterHeight));
rectGeo.Freeze();
path.AddGeometry(rectGeo);
if (hexBox.ShowAscii) {
rectGeo = new RectangleGeometry(new Rect(x + dx + asciiX, y, count * hexBox.CharacterWidth, hexBox.CharacterHeight));
rectGeo.Freeze();
path.AddGeometry(rectGeo);
}
if (offset + bpl - byteIndex < offset)
break;
offset += bpl - byteIndex;
y += hexBox.CharacterHeight;
}
path.Freeze();
drawingContext.DrawGeometry(Background, null, path);
}
示例3: Convert
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
PathGeometry pathData = new PathGeometry();
if ((Status)value == Status.Connected)
{
pathData.AddGeometry(Geometry.Parse(""));
}
else if ((Status)value == Status.Disconnected)
{
pathData.AddGeometry(Geometry.Parse("F1 M 58.5832,55.4172L 17.4169,55.4171C 15.5619,53.5621 15.5619,50.5546 17.4168,48.6996L 35.201,15.8402C 37.056,13.9852 40.0635,13.9852 41.9185,15.8402L 58.5832,48.6997C 60.4382,50.5546 60.4382,53.5622 58.5832,55.4172 Z M 34.0417,25.7292L 36.0208,41.9584L 39.9791,41.9583L 41.9583,25.7292L 34.0417,25.7292 Z M 38,44.3333C 36.2511,44.3333 34.8333,45.7511 34.8333,47.5C 34.8333,49.2489 36.2511,50.6667 38,50.6667C 39.7489,50.6667 41.1666,49.2489 41.1666,47.5C 41.1666,45.7511 39.7489,44.3333 38,44.3333 Z"));
}
else
{
pathData.AddGeometry(Geometry.Parse("F1 M 37.2083,49.0833C 39.3945,49.0833 41.1667,50.8555 41.1667,53.0417C 41.1667,55.2278 39.3945,57 37.2083,57C 35.0222,57 33.25,55.2278 33.25,53.0417C 33.25,50.8555 35.0222,49.0833 37.2083,49.0833 Z M 38,17.4167C 44.9956,17.4167 50.6666,21.9416 50.6666,28.5C 50.6666,30.875 49.0833,34.8333 45.9167,36.4167C 42.75,38 41.1667,40.1267 41.1667,42.75L 41.1667,45.9167L 33.25,45.9167L 33.25,43.5417C 33.25,38.1571 38,34.8333 39.5833,33.25C 42.75,30.0833 42.75,29.644 42.75,28.5C 42.75,25.8767 40.6233,23.75 38,23.75C 35.3766,23.75 33.25,25.8767 33.25,28.5L 33.25,30.875L 25.3333,30.875L 25.3333,29.2917C 25.3333,22.7333 31.0044,17.4167 38,17.4167 Z"));
}
return pathData;
}
示例4: GetAllToTogether
public string GetAllToTogether(string[] paths)
{
PathGeometry result = new PathGeometry();
foreach (var item in paths)
{
result.AddGeometry ( PathGeometry.Parse(item));
}
return result.ToString();
}
示例5: GetAsPathGeometry
internal override PathGeometry GetAsPathGeometry()
{
PathGeometry pg = new PathGeometry();
pg.AddGeometry(this);
pg.FillRule = FillRule;
Debug.Assert(pg.CanFreeze);
return pg;
}
示例6: DrawCircle
public void DrawCircle(Point center, DrawingContext drawingContext, Size windowSize, bool drawCircle)
{
var rectangle = new Rect(center.X - Radius, center.Y - Radius, Radius * 2, Radius * 2);
var path = new PathGeometry();
path.AddGeometry(new EllipseGeometry(rectangle));
drawingContext.PushClip(path);
var windowRect = new Rect(windowSize);
drawingContext.DrawImage(Bitmap, windowRect);
if (drawCircle)
drawingContext.DrawEllipse(Brushes.Transparent, new Pen(Brushes.Red, 1.5), center, Radius, Radius);
}
示例7: CreateAutoShape
private void CreateAutoShape(object sender, RoutedEventArgs e)
{
PathGeometry sendingPath = new PathGeometry();
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = new Point(47.7778, 48.6667);
pathFigure.IsClosed = true;
LineSegment lineSegment1 = new LineSegment();
lineSegment1.Point = new Point(198, 48.6667);
pathFigure.Segments.Add(lineSegment1);
LineSegment lineSegment2 = new LineSegment();
lineSegment2.Point = new Point(198, 102);
pathFigure.Segments.Add(lineSegment2);
BezierSegment bezierSegment1 = new BezierSegment();
bezierSegment1.Point1 = new Point(174.889, 91.3334);
bezierSegment1.Point2 = new Point(157.111, 79.7778);
bezierSegment1.Point3 = new Point(110.889, 114.444);
pathFigure.Segments.Add(bezierSegment1);
BezierSegment bezierSegment2 = new BezierSegment();
bezierSegment2.Point1 = new Point(64.667, 149.111);
bezierSegment2.Point2 = new Point(58.4444, 130.444);
bezierSegment2.Point3 = new Point(47.7778, 118.889);
pathFigure.Segments.Add(bezierSegment2);
sendingPath.Figures.Add(pathFigure);
PathGeometry pathGeometry = new PathGeometry();
if (sendingPath.FillRule != null)
pathGeometry.FillRule = sendingPath.FillRule;
else pathGeometry.FillRule = FillRule.Nonzero;
pathGeometry.Figures = sendingPath.Figures;
var newThumb = new SandRibbonInterop.AutoShape();
var safePathGeometry = (Geometry)(new GeometryConverter().ConvertFromString(pathGeometry.ToString()));
var safePathData = new PathGeometry();
safePathData.AddGeometry(safePathGeometry);
newThumb.PathData = safePathData;
newThumb.Background = Brushes.LightGreen;
newThumb.Foreground = Brushes.Green;
newThumb.StrokeThickness = 5;
newThumb.Height = 100;
newThumb.Width = 100;
Commands.AddAutoShape.Execute(newThumb);
}
示例8: OnRefresh
protected override void OnRefresh()
{
LineDecoration lineDecoration = Visual as LineDecoration;
if (lineDecoration != null)
{
_pathPen = new Pen(new SolidColorBrush(lineDecoration.LineColor), lineDecoration.Thickness);
_path = new PathGeometry();
Point startPoint = new Point(lineDecoration.Start.X - lineDecoration.Left, lineDecoration.Start.Y - lineDecoration.Top);
Point endPoint = new Point(lineDecoration.End.X - lineDecoration.Left, lineDecoration.End.Y - lineDecoration.Top);
if (lineDecoration.Curve)
{
// Create a vector representing the direction of the line
Vector v1 = lineDecoration.End - lineDecoration.Start;
double length = v1.Length;
// Normalize so it can be used to construct control points
v1.Normalize();
// Create a matrix to rotate arm perpendicular
Matrix m1 = new Matrix();
m1.Rotate(-90);
Point curvePoint1 = (startPoint + (v1 * (length * lineDecoration.CurveStart))) + ((v1 * (length * lineDecoration.CurveDepth)) * m1);
Point curvePoint2 = (endPoint - (v1 * (length * lineDecoration.CurveStart))) + ((v1 * (length * lineDecoration.CurveDepth)) * m1);
//_path.Figures.Add(QuadraticBezierFromIntersection(startPoint, curvePoint1, endPoint));
_path.Figures.Add(BezierFromIntersection(startPoint,curvePoint1,curvePoint2,endPoint));
}
else
{
LineGeometry line = new LineGeometry(startPoint, endPoint);
_path.AddGeometry(line);
}
}
}
示例9: ConstructCaretGeometry
private void ConstructCaretGeometry()
{
PathGeometry geometry = new PathGeometry();
geometry.AddGeometry(new RectangleGeometry(new Rect(0, 0, base.Width, base.Height)));
if (InputLanguageManager.Current.CurrentInputLanguage.TextInfo.IsRightToLeft)
{
PathFigure figure = new PathFigure();
figure.StartPoint = new Point(0, 0);
figure.Segments.Add(new LineSegment(new Point(-2, 0), true));
figure.Segments.Add(new LineSegment(new Point(0, base.Height / 10), true));
figure.IsClosed = true;
geometry.Figures.Add(figure);
}
_caretGeometry = geometry;
if (_caretGeometry.CanFreeze)
{
_caretGeometry.Freeze();
}
base.InvalidateVisual();
}
示例10: AddPath
public void AddPath (IGraphicsPath path, bool connect = false)
{
if (path.IsEmpty)
return;
var wpfPath = path.ToWpf ();
if (!wpfPath.Transform.Value.IsIdentity) {
var newpath = new swm.PathGeometry ();
newpath.AddGeometry (wpfPath);
wpfPath = newpath;
}
var en = wpfPath.Figures.GetEnumerator ();
if (connect) {
// merge current figure (if any) and first figure of new path, if they are not closed paths
if (figure != null && !figure.IsClosed && en.MoveNext ()) {
var firstFigure = en.Current;
if (!firstFigure.IsClosed) {
figure.Segments.Add (new swm.LineSegment (firstFigure.StartPoint, true));
foreach (var seg in firstFigure.Segments)
figure.Segments.Add (seg);
} else {
Control.Figures.Add (firstFigure);
}
}
}
swm.PathFigure pathFigure = null;
while (en.MoveNext ()) {
pathFigure = en.Current;
Control.Figures.Add (pathFigure);
}
// continue with last figure of new path if not closed
if (pathFigure != null && !pathFigure.IsClosed)
figure = pathFigure;
else
figure = null;
}
示例11: ConstructSteinterGeometry
/// <summary>
/// 构造steiner树的几何图形
/// </summary>
/// <param name="st">steinertree类</param>
/// <param name="gm">GraphManager类</param>
/// <param name="radius">每个点的半径</param>
/// <param name="fontsize">每个点说明文字的大小</param>
/// <returns>几何图形组。[0]为点集,[1]为边集</returns>
public PathGeometry[] ConstructSteinterGeometry(SteinerTree st, GraphManager gm, int radius, int fontsize)
{
steinertreeShape = new PathGeometry();
steinertreeLine = new PathGeometry();
//i即要绘制的节点
foreach (int i in st.steinerTreeNode)
{
steinertreeShape.AddGeometry(new EllipseGeometry((Point)gm.arrayPos.GetValue(i), radius, radius));
Point ptext = new Point(((Point)gm.arrayPos.GetValue(i)).X - H_GAP, ((Point)gm.arrayPos.GetValue(i)).Y - V_GAP);
steinertreeShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptext, fontsize).BuildGeometry());
}
//画线
foreach (edge i in st.steinerTreeEdge)
{
steinertreeLine.AddGeometry(new LineGeometry((Point)gm.arrayPos.GetValue(i.x), (Point)gm.arrayPos.GetValue(i.y)));
}
return new PathGeometry[] { steinertreeShape, steinertreeLine };
}
示例12: ConstructGeometrySimple
/// <summary>
/// 从数据图构造几何图形
/// </summary>
/// <param name="gm">数据图GraphManager</param>
/// <param name="radius">每個點的半徑</param>
/// <param name="fontsize">字体大小</param>
/// <returns></returns>
public PathGeometry[] ConstructGeometrySimple(GraphManager gm, int radius, int fontsize)
{
#region 画点
int PCount = 0;
int ACount = 0;
int WCount = 0;
int CCount = 0;
dataGraphShape = new PathGeometry();
dataGraphLine = new PathGeometry();
for (int i = 0; i < gm.nodeNum; i++)
{
if (gm.arrayKey.GetValue(i).ToString()[0] == 't')
{
Point centerP = new Point(H_DIST * PCount + H_DIST, 2 * V_DIST);
dataGraphShape.AddGeometry(new EllipseGeometry(centerP, radius, radius));
gm.arrayPos.SetValue(new Point(H_DIST * PCount + H_DIST, 2 * V_DIST), i);
Point ptextP = new Point(H_DIST * PCount + H_DIST - H_GAP, 2 * V_DIST - V_GAP);
dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextP, fontsize).BuildGeometry());
PCount++;
}
if (gm.arrayKey.GetValue(i).ToString()[0] == 'a')
{
Point centerA = new Point(H_DIST * ACount + H_DIST, 4 * V_DIST);
dataGraphShape.AddGeometry(new EllipseGeometry(centerA, radius, radius));
gm.arrayPos.SetValue(new Point(H_DIST * ACount + H_DIST, 4 * V_DIST), i);
Point ptextA = new Point(H_DIST * ACount + H_DIST - H_GAP, 4 * V_DIST - V_GAP);
dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextA, fontsize).BuildGeometry());
ACount++;
}
if (gm.arrayKey.GetValue(i).ToString()[0] == 'C')
{
Point centerC = new Point(H_DIST * CCount + H_DIST, V_DIST);
dataGraphShape.AddGeometry(new EllipseGeometry(centerC, radius, radius));
gm.arrayPos.SetValue(new Point(H_DIST * CCount + H_DIST, V_DIST), i);
Point ptextC = new Point(H_DIST * CCount + H_DIST - H_GAP, V_DIST - V_GAP);
dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextC, fontsize).BuildGeometry());
CCount++;
}
if (gm.arrayKey.GetValue(i).ToString()[0] == 'W')
{
Point centerW = new Point(H_DIST * WCount + H_DIST, 3 * V_DIST);
dataGraphShape.AddGeometry(new EllipseGeometry(centerW, radius, radius));
gm.arrayPos.SetValue(new Point(H_DIST * WCount + H_DIST, 3 * V_DIST), i);
Point ptextW = new Point(H_DIST * WCount + H_DIST - H_GAP, 3 * V_DIST - V_GAP);
dataGraphShape.AddGeometry(DataGraphPrintText(gm.arrayKey.GetValue(i).ToString(), ptextW, fontsize).BuildGeometry());
WCount++;
}
}
#endregion
#region 画线
for (int i = 0; i < gm.nodeNum; i++)
{
for (int j = 0; j < i; j++)
{
if (gm.graph[i, j] == 1)
{
dataGraphLine.AddGeometry(new LineGeometry((Point)gm.arrayPos.GetValue(i), (Point)gm.arrayPos.GetValue(j)));
}
}
}
#endregion
return new PathGeometry[] { dataGraphShape, dataGraphLine };
}
示例13: BuildSpanGeometry
private PathGeometry BuildSpanGeometry(SnapshotSpan span)
{
PathGeometry path = new PathGeometry();
path.FillRule = FillRule.Nonzero;
foreach ( var line in this.view.TextViewLines ) {
if ( line.Start > span.End ) break;
if ( LineIntersectsSpan(line, span) ) {
var lineGeometry = BuildLineGeometry(span, line);
path.AddGeometry(lineGeometry);
}
}
return path;
}
示例14: GetTightBoundingGeometryFromTextPositions
/// <summary>
/// <see cref="TextViewBase.GetTightBoundingGeometryFromTextPositions"/>
/// </summary>
internal override Geometry GetTightBoundingGeometryFromTextPositions(ITextPointer startPosition, ITextPointer endPosition)
{
PathGeometry boundingGeometry = new PathGeometry();
Debug.Assert(startPosition != null && this.Contains(startPosition));
Debug.Assert(endPosition != null && this.Contains(endPosition));
Dictionary<FixedPage, ArrayList> highlights = new Dictionary<FixedPage,ArrayList>();
FixedTextPointer startftp = this.Container.VerifyPosition(startPosition);
FixedTextPointer endftp = this.Container.VerifyPosition(endPosition);
this.Container.GetMultiHighlights(startftp, endftp, highlights, FixedHighlightType.TextSelection, null, null);
ArrayList highlightList;
highlights.TryGetValue(this.FixedPage, out highlightList);
if (highlightList != null)
{
foreach (FixedHighlight fh in highlightList)
{
if (fh.HighlightType == FixedHighlightType.None)
{
continue;
}
Rect backgroundRect = fh.ComputeDesignRect();
if (backgroundRect == Rect.Empty)
{
continue;
}
GeneralTransform transform = fh.Element.TransformToAncestor(this.FixedPage);
Transform t = transform.AffineTransform;
if (t == null)
{
t = Transform.Identity;
}
Glyphs g = fh.Glyphs;
if (fh.Element.Clip != null)
{
Rect clipRect = fh.Element.Clip.Bounds;
backgroundRect.Intersect(clipRect);
}
Geometry thisGeometry = new RectangleGeometry(backgroundRect);
thisGeometry.Transform = t;
backgroundRect = transform.TransformBounds(backgroundRect);
boundingGeometry.AddGeometry(thisGeometry);
}
}
return boundingGeometry;
}
示例15: SizeGeometry
public static void SizeGeometry(PathGeometry pg, Size size)
{
if (size.Height > 0 && size.Height > 0)
{
PathFigure[] sizeFigures =
{
new PathFigure(new Point(size.Width, size.Height), Enumerable.Empty<PathSegment>(), true),
new PathFigure(new Point(0,0), Enumerable.Empty<PathSegment>(), true),
};
var newGeo = new PathGeometry(sizeFigures.Concat(pg.Figures), pg.FillRule, null);//pg.Transform do not add transform here, it will recalculate all the Points
pg.Clear();
pg.AddGeometry(newGeo);
//return new PathGeometry(sizeFigures.Concat(pg.Figures), pg.FillRule, pg.Transform);
}
}