本文整理汇总了C#中System.Windows.Media.DrawingContext.DrawDrawing方法的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext.DrawDrawing方法的具体用法?C# DrawingContext.DrawDrawing怎么用?C# DrawingContext.DrawDrawing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.DrawingContext
的用法示例。
在下文中一共展示了DrawingContext.DrawDrawing方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawCore
protected override void DrawCore(DrawingContext drawingContext, DrawingAttributes drawingAttributes)
{
if (drawingContext == null)
{
throw new ArgumentNullException("drawingContext");
}
if (null == drawingAttributes)
{
throw new ArgumentNullException("drawingAttributes");
}
Pen pen = new Pen
{
StartLineCap = PenLineCap.Round,
EndLineCap = PenLineCap.Round,
Brush = new SolidColorBrush(drawingAttributes.Color),
Thickness = drawingAttributes.Width
};
BrushConverter bc = new BrushConverter();
Brush BackGround = (Brush)bc.ConvertFromString(drawingAttributes.GetPropertyData(DrawAttributesGuid.BackgroundColor).ToString());
GeometryConverter gc = new GeometryConverter();
Geometry geometry = (Geometry)gc.ConvertFromString(string.Format("M {0},{1} {2},{3} {4},{5} Z", StylusPoints[0].X, StylusPoints[1].Y, (Math.Abs(StylusPoints[1].X - StylusPoints[0].X))/2 + StylusPoints[0].X, StylusPoints[0].Y, StylusPoints[1].X, StylusPoints[1].Y));
GeometryDrawing gd = new GeometryDrawing(BackGround, pen, geometry);
drawingContext.DrawDrawing(gd);
}
示例2: InnerDraw
protected override void InnerDraw(DrawingContext drawingContext)
{
base.InnerDraw(drawingContext);
drawingContext.PushTransform(_scaleTransform);
drawingContext.DrawDrawing(_textDrawing);
drawingContext.Pop();
}
示例3: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
var ellipse = new EllipseGeometry(new Point(250, 50), 50, 50);
var drawing = new GeometryDrawing(Brushes.BlueViolet, new Pen(Brushes.Bisque, 2), ellipse);
drawingContext.DrawDrawing(drawing);
}
示例4: OnRender
/// <summary>
///
/// </summary>
/// <param name="drawingContext"></param>
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
foreach (var visual in Visuals)
{
drawingContext.DrawDrawing(visual.Drawing);
}
}
示例5: OnRender
protected override void OnRender(DrawingContext dc)
{
if (_drawings.Count == 0 || _size.Height != ActualHeight || _size.Width != ActualWidth)
{
RenderSizeChanged(_size = new Size(ActualWidth, ActualHeight));
}
if (_drawings.Count == 1)
dc.DrawDrawing(_drawings[0]);
base.OnRender(dc);
}
示例6: InnerDraw
//private const int Margin = 3;
protected override void InnerDraw(DrawingContext drawingContext)
{
base.InnerDraw(drawingContext);
if (_scaleTransform != null)
drawingContext.PushTransform(_scaleTransform);
if (_clipGeometry != null)
drawingContext.PushClip(_clipGeometry);
drawingContext.DrawDrawing(_textDrawing);
if (_clipGeometry != null)
drawingContext.Pop();
if (_scaleTransform != null)
drawingContext.Pop();
}
示例7: Render
public void Render(DrawingContext drawingContext)
{
if (BackGround != null)
{
drawingContext.DrawDrawing(BackGround);
}
if (Overlay != null)
{
drawingContext.DrawDrawing(Overlay);
}
}
示例8: DrawScenes
//.........这里部分代码省略.........
figures.Add(new PathFigure(bottomLeft.ToCanvasPoint(), segments, true));
}
var geo = new PathGeometry(figures, FillRule.Nonzero, null);
geo.GetOutlinedPathGeometry();
groupdc.DrawGeometry(RadarResources.WalkableTerrain, null, geo);
}
#endregion
#region Scene Borders
var sceneTopLeft = new Vector3(adventurerScene.Min.X, adventurerScene.Min.Y, 0);
var sceneTopRight = new Vector3(adventurerScene.Max.X, adventurerScene.Min.Y, 0);
var sceneBottomLeft = new Vector3(adventurerScene.Min.X, adventurerScene.Max.Y, 0);
var sceneBottomRight = new Vector3(adventurerScene.Max.X, adventurerScene.Max.Y, 0);
groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopLeft.ToCanvasPoint(), sceneTopRight.ToCanvasPoint()));
groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneBottomLeft.ToCanvasPoint(), sceneBottomRight.ToCanvasPoint()));
groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopLeft.ToCanvasPoint(), sceneBottomLeft.ToCanvasPoint()));
groupdc.DrawGeometry(null, RadarResources.WalkableTerrainBorder, new LineGeometry(sceneTopRight.ToCanvasPoint(), sceneBottomRight.ToCanvasPoint()));
#endregion
#region Scene Title
var textPoint = adventurerScene.Center.ToVector3().ToCanvasPoint();
var glyphRun = DrawingUtilities.CreateGlyphRun(adventurerScene.Name, 10, textPoint);
groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun);
textPoint = adventurerScene.Center.ToVector3().ToCanvasPoint();
textPoint.Y = textPoint.Y + 20;
glyphRun = DrawingUtilities.CreateGlyphRun((adventurerScene.Max - adventurerScene.Min) + " " + (adventurerScene.HasChild ? "HasSubScene" : string.Empty) + " " + (adventurerScene.SubScene != null ? " (Loaded)" : string.Empty), 8, textPoint);
groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun);
#endregion
#region Nodes
var sceneNodePen = new Pen { Brush = Brushes.Black, Thickness = 0.1f };
foreach (var node in adventurerScene.Nodes)
{
if (node.HasEnoughNavigableCells)
{
groupdc.DrawGeometry(null, sceneNodePen,
new LineGeometry(node.TopLeft.ToVector3().ToCanvasPoint(),
node.TopRight.ToVector3().ToCanvasPoint()));
groupdc.DrawGeometry(null, sceneNodePen,
new LineGeometry(node.TopLeft.ToVector3().ToCanvasPoint(),
node.BottomLeft.ToVector3().ToCanvasPoint()));
groupdc.DrawGeometry(null, sceneNodePen,
new LineGeometry(node.BottomLeft.ToVector3().ToCanvasPoint(),
node.BottomRight.ToVector3().ToCanvasPoint()));
groupdc.DrawGeometry(null, sceneNodePen,
new LineGeometry(node.TopRight.ToVector3().ToCanvasPoint(),
node.BottomRight.ToVector3().ToCanvasPoint()));
//var textPoint1 = node.Center.ToVector3().ToCanvasPoint();
//// var glyphRun1 = DrawingUtilities.CreateGlyphRun(string.Format("{2} {0} ({1:P0})", node.NavigableCellCount, node.FillPercentage, node.LevelAreaId), 8, textPoint1);
//var glyphRun1 = DrawingUtilities.CreateGlyphRun(node.LevelAreaId.ToString(), 8, textPoint1);
//groupdc.DrawGlyphRun(Brushes.Wheat, glyphRun1);
}
//foreach (var navPoint in node.Nodes.Where(n=>n.NodeFlags.HasFlag(NodeFlags.NearWall)))
//{
// DrawNavNode(groupdc, canvas, navPoint);
// //groupdc.DrawEllipse(Brushes.LightSlateGray, sceneNodePen, navPoint.Center.ToVector3().ToCanvasPoint(), (float)GridSize / 2, (float)GridSize / 2);
//}
}
#endregion
}
// Have to use SceneHash as key because scenes can appear multiple times with the same name
Drawings.Relative.TryAdd(adventurerScene.HashName, new RelativeDrawing
{
Drawing = drawing,
Origin = CenterActor.Morph,
Center = adventurerScene.Center.ToVector3(),
WorldId = adventurerScene.DynamicWorldId,
//Image = new DrawingImage(drawing),
//ImageRect = drawing.Bounds
});
}
foreach (var pair in Drawings.Relative)
{
//if (pair.Value.WorldId != AdvDia.CurrentWorldDynamicId)
// continue;
if (!pair.Value.Drawing.Bounds.IntersectsWith(CanvasData.ClipRegion.Rect))
continue;
dc.DrawDrawing(pair.Value.Drawing);
//if (!pair.Value.ImageRect.IntersectsWith(CanvasData.ClipRegion.Rect))
// continue;
//dc.DrawImage(pair.Value.Image, pair.Value.ImageRect);
}
}
catch (Exception ex)
{
Logger.Debug("Exception in RadarUI.DrawScenes(). {0} {1} {2}", ex.Message, ex.InnerException, ex);
}
}
示例9: RenderFalseHorizon
protected void RenderFalseHorizon(DrawingContext context)
{
if (falseHorizonPen == null)
{
return;
}
context.DrawDrawing(falseHorizonCrosshairs);
context.DrawDrawing(pitchGauge);
}
示例10: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
var bc = new BrushConverter();
var user = XIVInfoViewModel.Instance.CurrentUser;
if (user == null)
{
return;
}
var origin = new Coordinate
{
X = (float) (ActualWidth / 2),
Y = (float) (ActualHeight / 2)
};
var scale = ((float) (ActualHeight / 2.0f) / 125.0f);
var angle = Math.Abs(user.Heading * (180 / Math.PI) - 180);
if (Settings.Default.RadarCompassMode)
{
var drawingGroup = new DrawingGroup
{
Transform = new RotateTransform
{
Angle = angle,
CenterX = origin.X,
CenterY = origin.Y
}
};
drawingGroup.Children.Add(new ImageDrawing(RadarIconHelper.RadarHeading, new Rect(origin.X - 64, origin.Y - 128, 128, 128)));
drawingContext.DrawDrawing(drawingGroup);
}
else
{
drawingContext.DrawImage(RadarIconHelper.RadarHeading, new Rect(new Point(origin.X - 64, origin.Y - 128), new Size(128, 128)));
}
var sb = new StringBuilder();
var npcEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentNPCs.Select(kvp => kvp.Value)
.ToList());
var monsterEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentMonsters.Select(kvp => kvp.Value)
.ToList());
var pcEntites = new List<ActorEntity>(XIVInfoViewModel.Instance.CurrentPCs.Select(kvp => kvp.Value)
.ToList());
if (Settings.Default.FilterRadarItems)
{
var npcFilters = PluginViewModel.Instance.Filters.Where(filter => filter.Type != Actor.Type.PC && filter.Type != Actor.Type.Monster)
.ToList();
if (npcFilters.Any())
{
npcEntites = RadarFilterHelper.ResolveFilteredEntities(npcFilters, npcEntites);
}
var monsterFilters = PluginViewModel.Instance.Filters.Where(filter => filter.Type == Actor.Type.Monster)
.ToList();
if (PluginViewModel.Instance.RankedFilters.Any())
{
monsterFilters.AddRange(PluginViewModel.Instance.RankedFilters);
}
if (monsterFilters.Any())
{
monsterEntites = RadarFilterHelper.ResolveFilteredEntities(monsterFilters, monsterEntites);
}
var pcFilters = PluginViewModel.Instance.Filters.Where(filter => filter.Type == Actor.Type.PC)
.ToList();
if (pcFilters.Any())
{
pcEntites = RadarFilterHelper.ResolveFilteredEntities(pcFilters, pcEntites);
}
}
#region Resolve PCs
if (Settings.Default.PCShow)
{
foreach (var actorEntity in pcEntites)
{
sb.Clear();
var fsModifier = 0;
drawingContext.PushOpacity(1);
try
{
if (!actorEntity.IsValid || user == null)
{
continue;
}
if (actorEntity.ID == user.ID)
{
continue;
}
Coordinate screen;
if (Settings.Default.RadarCompassMode)
{
//.........这里部分代码省略.........
示例11: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
if (ChartData == null) return;
if (GraphContents == null)
{
// ActualWidth and ActualHeight are NaN at initialization, need to do this here
Viewport.Visible = new Rect(new Size(ActualWidth, ActualHeight));
Viewport.OnViewportResized(ActualWidth, ActualHeight);
GraphContents = new DrawingGroup();
}
if (FilteredPoints == null)
Update();
using (DrawingContext context = GraphContents.Open())
{
// Draw Background
context.DrawRectangle(ChartStyle.BackgroundColor, null, Viewport.Output);
// Draw Chart
ChartDrawing.Draw(context, FilteredPoints, ChartStyle);
//Draw Debug text
context.DrawText(new FormattedText("Viewport.Visible=" + Viewport.Visible + "\n" + "Viewport.Output=" + Viewport.Output,
CultureInfo.InvariantCulture,
FlowDirection.LeftToRight,
new Typeface("Arial"), 12, Brushes.Red),
new Point(10, 10));
}
drawingContext.DrawDrawing(GraphContents);
}
示例12: RenderCompass
protected void RenderCompass(DrawingContext context)
{
if (baselinePen == null)
{
return;
}
compassClippingRectangle.Transform = invertedYawTransform;
compass.Transform = yawTransform;
compass.ClipGeometry = compassClippingRectangle;
context.DrawDrawing(compass);
}
示例13: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
drawingContext.DrawDrawing(m_drawing);
//base.OnRender(drawingContext);
}
示例14: OnRender
protected override void OnRender(DrawingContext drawingContext)
{
var clock = GetAnimationClock(this);
var step = (int)Math.Floor (clock * Spokes);
var halfWidth = ActualWidth/2;
var halfHeight = ActualHeight/2;
var scale = Math.Min (halfWidth, halfHeight);
var matrix = Matrix.Identity;
matrix.Scale (scale, scale);
var angle = -(step*360.0)/Spokes;
matrix.Rotate (angle);
matrix.Translate (halfWidth, halfHeight);
drawingContext.PushTransform(new MatrixTransform (matrix));
drawingContext.DrawDrawing(s_drawing);
drawingContext.Pop();
}
示例15: OnRender
/// <summary>
/// Renders the contents of an <see cref="T:System.Windows.Controls.Image"/> and
/// the SelectorDrawing.
/// </summary>
/// <param name="dc">An instance of <see cref="T:System.Windows.Media.DrawingContext"/>
/// used to render the control.</param>
protected override void OnRender(DrawingContext dc)
{
base.OnRender(dc);
if (ActualWidth == 0 || ActualHeight == 0)
return;
// Render the SelectorDrawing
dc.PushTransform(new TranslateTransform(Position.X, Position.Y));
dc.DrawDrawing(Selector);
dc.Pop();
}