本文整理汇总了C#中DrawingContext类的典型用法代码示例。如果您正苦于以下问题:C# DrawingContext类的具体用法?C# DrawingContext怎么用?C# DrawingContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrawingContext类属于命名空间,在下文中一共展示了DrawingContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Draw
/// <inheritdoc/>
protected internal override void Draw(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
{
if (Shader.IsValid && Shader.IsLoaded)
{
DrawRenderTargetAtVisualBounds(dc, element, target, Shader);
}
}
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:8,代码来源:ShaderEffect.cs
示例2: DrawScene
void DrawScene(DrawingContext dc) {
dc.Rect(Color.FromArgb(255, 0, 0, 30), 0, 0, 500, 500);
// sun
dc.Ellipse(Colors.Yellow, 250, 250, 30, 30);
Planet(dc);
Stars(dc);
}
开发者ID:iamnp,项目名称:CSharpLiveCodingEnvironment,代码行数:9,代码来源:Orbit.cs
示例3: ConvertUnitToPixelPoint
public static Point ConvertUnitToPixelPoint(Point unitPoint, DrawingContext drawingContext)
{
Point pixelPoint = new Point();
pixelPoint.X = drawingContext.DrawingSize.Width / (drawingContext.XMaximum - drawingContext.XMinimum) * (unitPoint.X - drawingContext.XMinimum);
pixelPoint.Y = drawingContext.DrawingSize.Height / (drawingContext.YMaximum - drawingContext.YMinimum) * (unitPoint.Y - drawingContext.YMinimum);
return pixelPoint;
}
开发者ID:AndreasSummer,项目名称:WPF-UI-Development-Best-Practices,代码行数:9,代码来源:MathHelpers.cs
示例4: OnRender
/// <summary>
/// When overriden in a class, renders the visual
/// </summary>
/// <param name="drawingContext">The <see cref="DrawingContext"/> in whihc to render the visual</param>
protected override void OnRender(DrawingContext drawingContext)
{
if(this.Background != null || this.BorderBrush != null)
{
drawingContext.DrawRectangle(this.RenderTarget, this.BorderThickness, this.Background, this.BorderBrush);
}
if (this.Child != null)
{
this.Child.Render(drawingContext);
}
}
开发者ID:yonglehou,项目名称:Photon,代码行数:15,代码来源:Border.cs
示例5: ConvertUnitToPixelPointCollection
public static PointCollection ConvertUnitToPixelPointCollection(IEnumerable<Point> unitPoints, DrawingContext drawingContext)
{
PointCollection pixelPoints = new PointCollection();
foreach (var unitPoint in unitPoints)
{
pixelPoints.Add(ConvertUnitToPixelPoint(unitPoint, drawingContext));
}
return pixelPoints;
}
开发者ID:AndreasSummer,项目名称:WPF-UI-Development-Best-Practices,代码行数:11,代码来源:MathHelpers.cs
示例6: RegisterDrawMethod
public static AutoResetEvent RegisterDrawMethod(Action action)
{
Exceptions.CheckArgumentNull(action, "action");
DrawingContext drawingContext = new DrawingContext(action, new Thread(DrawingThreadProc) {IsBackground = true});
if (!DrawingContexts.TryAdd(action, drawingContext))
throw new Exception("Метод уже зарегистрирован.");
drawingContext.StartWorking();
return drawingContext.DrawEvent;
}
开发者ID:kidaa,项目名称:Pulse,代码行数:12,代码来源:GLService.cs
示例7: DrawingContext
internal DrawingContext(DrawingContext context)
{
Context = context.Context;
if (context.Pen != null)
AllocatePen (context.colorBrush.Color, context.Pen.Thickness, context.Pen.DashStyle);
patternBrush = context.patternBrush;
geometry = (PathGeometry) context.Geometry.Clone ();
Path = geometry.Figures[geometry.Figures.Count - 1];
positionSet = context.positionSet;
}
开发者ID:nite2006,项目名称:xwt,代码行数:13,代码来源:DrawingContext.cs
示例8: DrawRenderTargets
/// <inheritdoc/>
protected internal override void DrawRenderTargets(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
{
var blurTarget = target.Next.RenderTarget;
var gfx = dc.Ultraviolet.GetGraphics();
gfx.SetRenderTarget(blurTarget);
gfx.Clear(Color.Transparent);
effect.Value.Radius = GetRadiusInPixels(element);
effect.Value.Direction = BlurDirection.Horizontal;
dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
dc.Draw(target.ColorBuffer, Vector2.Zero, Color.White);
dc.End();
}
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:16,代码来源:BlurEffect.cs
示例9: DrawScene
void DrawScene(DrawingContext dc) {
dc.DrawEllipse(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), null, new Point(50, 18), 12, 12);
dc.DrawEllipse(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Point(50, 51), 12, 12);
dc.DrawEllipse(null, new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Point(50, 87), 12, 12);
dc.DrawRectangle(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), null, new Rect(25, 111, 24, 24));
dc.DrawRectangle(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Rect(25, 147, 24, 24));
dc.DrawRectangle(null, new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Rect(25, 184, 24, 24));
dc.DrawRoundedRectangle(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), null, new Rect(25, 237, 24, 24), 5, 5);
dc.DrawRoundedRectangle(new SolidColorBrush(Color.FromArgb(255, 200, 200, 200)), new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Rect(25, 270, 24, 24), 5, 5);
dc.DrawRoundedRectangle(null, new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Rect(25, 307, 24, 24), 5, 5);
dc.DrawLine(new Pen(new SolidColorBrush(Color.FromArgb(255, 100, 100, 100)), 3), new Point(50, 340), new Point (70, 360));
}
开发者ID:iamnp,项目名称:CSharpLiveCodingEnvironment,代码行数:15,代码来源:Shapes.cs
示例10: DrawScene
void DrawScene(DrawingContext dc) {
dc.Rect(Color.FromArgb(0, 0, 0, 0), 0, 0, 500, 500);
dc.Ellipse(Colors.Red, 250, 250, 20, 20);
for (int i = 0; i < 5; ++i) {
dc.PushTransform(new RotateTransform(36*i, 250, 250));
dc.Ellipse(Colors.Gray, 3, 250, 250, 40, 150);
dc.Ellipse(Colors.Black,
250 + 40*Math.Cos(angle[i]*0.05),
250 + 150*Math.Sin(angle[i]*0.05),
8, 8);
dc.Pop();
}
}
开发者ID:iamnp,项目名称:CSharpLiveCodingEnvironment,代码行数:15,代码来源:AtomModel.cs
示例11: DrawOverride
/// <inheritdoc/>
protected override void DrawOverride(UltravioletTime time, DrawingContext dc)
{
var font = Font;
if (font.IsLoaded)
{
View.Resources.StringFormatter.Reset();
View.Resources.StringFormatter.AddArgument(Value);
View.Resources.StringFormatter.Format(Format ?? "{0}", View.Resources.StringBuffer);
var face = font.Resource.Value.GetFace(FontStyle);
var position = Display.DipsToPixels(UntransformedAbsolutePosition);
var positionRounded = dc.IsTransformed ? (Vector2)position : (Vector2)(Point2)position;
dc.DrawString(face, View.Resources.StringBuffer, positionRounded, Foreground);
}
base.DrawOverride(time, dc);
}
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:18,代码来源:NumericTextBlock.cs
示例12: GetShape
public IShape GetShape(DrawingContext drawingContext, Point start, Point end)
{
var pen = (Pen)drawingContext.Pen.Clone();
var brush = drawingContext.Brush == Brushes.Transparent ? Brushes.Transparent : (Brush)drawingContext.Brush.Clone();
switch (drawingContext.ShapeType)
{
case ShapeType.Line:
return new Line(pen, start, end);
case ShapeType.Rectangle:
return new Rectangle(pen, brush, start, end);
case ShapeType.Ellipse:
return new Ellipse(pen, brush, start, end);
default:
throw new ArgumentException("Unknown shape type.");
}
}
开发者ID:jsikorski,项目名称:dotnet-paint,代码行数:17,代码来源:ShapesProvider.cs
示例13: Draw
/// <inheritdoc/>
protected internal override void Draw(DrawingContext dc, UIElement element, OutOfBandRenderTarget target)
{
var state = dc.GetCurrentState();
var position = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);
dc.End();
effect.Value.Radius = GetRadiusInPixels(element);
effect.Value.Direction = BlurDirection.Vertical;
dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
var shadowTexture = target.Next.ColorBuffer;
dc.Draw(shadowTexture, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
dc.End();
dc.Begin(state);
}
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:21,代码来源:BlurEffect.cs
示例14: MainWindow
public MainWindow()
{
InitializeComponent();
InitializeGraphics();
InitializePlugins();
drawingArea.CanUndoChanged += newValue => undo.Enabled = newValue;
drawingArea.CanRedoChanged += newValue => redo.Enabled = newValue;
_lastSelectedShapeTypeSelector = lineSelector;
_drawingContext = new DrawingContext
{
ShapeType = ShapeType.Line,
Pen = new Pen(penColorSelector.Value, int.Parse(penWidthSelector.Text)),
Brush = Brushes.Transparent
};
drawingArea.DrawingContext = _drawingContext;
}
开发者ID:jsikorski,项目名称:dotnet-paint,代码行数:20,代码来源:MainWindow.cs
示例15: DrawRenderTargetAtVisualBounds
/// <summary>
/// Draws the specified render target at its desired visual bounds.
/// </summary>
/// <param name="dc">The current drawing context.</param>
/// <param name="element">The element being drawn.</param>
/// <param name="target">The render target that contains the element's graphics.</param>
/// <param name="effect">The shader effect to apply to the render target, if any.</param>
public static void DrawRenderTargetAtVisualBounds(DrawingContext dc, UIElement element, OutOfBandRenderTarget target, GraphicsEffect effect = null)
{
Contract.Require(dc, "dc");
Contract.Require(element, "element");
Contract.Require(target, "rtarget");
if (element.View == null)
return;
var state = dc.GetCurrentState();
dc.End();
dc.Begin(SpriteSortMode.Immediate, effect, Matrix.Identity);
var position = (Vector2)element.View.Display.DipsToPixels(target.VisualBounds.Location);
var positionRounded = new Vector2((Int32)position.X, (Int32)position.Y);
dc.Draw(target.ColorBuffer, positionRounded, null, Color.White, 0f, Vector2.Zero, Vector2.One, SpriteEffects.None, 0f);
dc.End();
dc.Begin(state);
}
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:28,代码来源:Effect.cs
示例16: OnRender
protected override void OnRender(DrawingContext dc)
{
string testString = "Formatted MML Document is displayed here!\nPlease implement the user oriented layout logic.";
FormattedText formattedText = new FormattedText(testString, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Verdana"), 30, Brushes.Black);
formattedText.MaxTextWidth = 280;
formattedText.MaxTextHeight = 280;
formattedText.SetForegroundBrush(new LinearGradientBrush(Colors.Blue, Colors.Teal, 90.0), 10, 12);
formattedText.SetFontStyle(FontStyles.Italic, 36, 5);
formattedText.SetForegroundBrush(new LinearGradientBrush(Colors.Pink, Colors.Crimson, 90.0), 36, 5);
formattedText.SetFontSize(36, 36, 5);
formattedText.SetFontWeight(FontWeights.Bold, 42, 48);
dc.DrawRectangle(Brushes.White, null, new Rect(0, 0, 300, 300));
dc.DrawText(formattedText, new Point(10, 10));
}
开发者ID:anhlai,项目名称:EMR-MML,代码行数:21,代码来源:SampleMmlLayout.cs
示例17: EnqueueForDrawing
/// <summary>
/// Adds the popup to the view's popup queue for drawing.
/// </summary>
/// <param name="time">Time elapsed since the last call to <see cref="UltravioletContext.Draw(UltravioletTime)"/>.</param>
/// <param name="dc">The drawing context that describes the render state of the layout.</param>
internal void EnqueueForDrawing(UltravioletTime time, DrawingContext dc)
{
if (View.Popups.IsDrawingPopup(this))
return;
View.Popups.Enqueue(this);
}
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:12,代码来源:Popup.cs
示例18: AppendPath
public void AppendPath(DrawingContext context)
{
foreach (var f in context.Geometry.Figures)
geometry.Figures.Add (f.Clone ());
Path = context.geometry.Figures[context.geometry.Figures.Count - 1];
}
开发者ID:nite2006,项目名称:xwt,代码行数:6,代码来源:DrawingContext.cs
示例19: Draw
public void Draw(ApplicationContext actx, SWM.DrawingContext dc, double scaleFactor, double x, double y, ImageDescription idesc)
{
if (drawCallback != null) {
DrawingContext c = new DrawingContext (dc, scaleFactor);
actx.InvokeUserCode (delegate {
drawCallback (c, new Rectangle (x, y, idesc.Size.Width, idesc.Size.Height));
});
}
else {
if (idesc.Alpha < 1)
dc.PushOpacity (idesc.Alpha);
var f = GetBestFrame (actx, scaleFactor, idesc.Size.Width, idesc.Size.Height, false);
dc.DrawImage (f, new Rect (x, y, idesc.Size.Width, idesc.Size.Height));
if (idesc.Alpha < 1)
dc.Pop ();
}
}
开发者ID:jijamw,项目名称:xwt,代码行数:19,代码来源:ImageHandler.cs
示例20: DrawBlocks
void DrawBlocks(DrawingContext dc) {
for (int i = 0; i < blockCount; ++i) {
for (int j = 0; j < blockCount; ++j) {
if (blocks[i, j] == 1)
dc.Rect(Colors.Green, i * blockSize, j * blockSize, blockSize, blockSize);
if (blocks[i, j] == 2)
dc.Rect(Colors.Blue, i * blockSize, j * blockSize, blockSize, blockSize);
}
}
}
开发者ID:iamnp,项目名称:CSharpLiveCodingEnvironment,代码行数:10,代码来源:SimplePlatformer.cs
注:本文中的DrawingContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论