615 lines
16 KiB
C#
615 lines
16 KiB
C#
![]() |
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using CPF.Drawing;
|
|||
|
using CPF.ReoGrid.Common;
|
|||
|
using CPF.ReoGrid.Drawing;
|
|||
|
using CPF.ReoGrid.Graphics;
|
|||
|
|
|||
|
namespace CPF.ReoGrid.Rendering
|
|||
|
{
|
|||
|
internal class WPFGraphics : IGraphics
|
|||
|
{
|
|||
|
public ResourcePoolManager ResourcePoolManager
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return this.resourceManager;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public DrawingContext PlatformGraphics
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return this.g;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
this.g = value;
|
|||
|
bool flag = value != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
this.reset = value.Transform;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DrawLine(CPFPen p, float x1, float y1, float x2, float y2)
|
|||
|
{
|
|||
|
this.DrawLine(p, new Point(ref x1, ref y1), new Point(ref x2, ref y2));
|
|||
|
}
|
|||
|
|
|||
|
public void DrawLine(CPFPen p, Point startPoint, Point endPoint)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Stroke stroke = p.Stroke;
|
|||
|
drawingContext.DrawLine(stroke, p.Brush, startPoint, endPoint);
|
|||
|
}
|
|||
|
|
|||
|
public void DrawLine(Point startPoint, Point endPoint, Color color)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(color);
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
Brush brush = pen.Brush;
|
|||
|
Point point = startPoint;
|
|||
|
Point point2 = endPoint;
|
|||
|
drawingContext.DrawLine(stroke, brush, point, point2);
|
|||
|
}
|
|||
|
|
|||
|
public void DrawLine(float x1, float y1, float x2, float y2, Color color)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(color);
|
|||
|
this.DrawLine(pen, x1, y1, x2, y2);
|
|||
|
}
|
|||
|
|
|||
|
public void DrawLine(float x1, float y1, float x2, float y2, Color color, float width, LineStyles style)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(color, width, this.ToWPFDashStyle(style));
|
|||
|
bool flag = pen != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
Brush brush = pen.Brush;
|
|||
|
Point point = new Point(ref x1, ref y1);
|
|||
|
Point point2 = new Point(ref x2, ref y2);
|
|||
|
drawingContext.DrawLine(stroke, brush, point, point2);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DrawLine(Point startPoint, Point endPoint, Color color, float width, LineStyles style)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(color, width, this.ToWPFDashStyle(style));
|
|||
|
bool flag = pen != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
drawingContext.DrawLine(stroke, pen.Brush, startPoint, endPoint);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DrawLines(Point[] points, int start, int length, Color color, float width, LineStyles style)
|
|||
|
{
|
|||
|
bool flag = !color.IsTransparent && length > 1;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(color, width, this.ToWPFDashStyle(style));
|
|||
|
bool flag2 = pen != null;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
PathGeometry pathGeometry = new PathGeometry();
|
|||
|
bool flag3 = points != null && points.Length > 1;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
pathGeometry.BeginFigure(points[0].X, points[0].Y);
|
|||
|
for (int i = 1; i < points.Length; i++)
|
|||
|
{
|
|||
|
pathGeometry.LineTo(points[i].X, points[i].Y);
|
|||
|
}
|
|||
|
pathGeometry.EndFigure(false);
|
|||
|
}
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush = pen.Brush;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
drawingContext.DrawPath(brush, stroke, pathGeometry);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DrawRectangle(CPFPen p, Rect rect)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush = p.Brush;
|
|||
|
Stroke stroke = p.Stroke;
|
|||
|
drawingContext.DrawRectangle(brush, stroke, rect);
|
|||
|
}
|
|||
|
|
|||
|
public void DrawRectangle(CPFPen p, float x, float y, float w, float h)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush = p.Brush;
|
|||
|
Stroke stroke = p.Stroke;
|
|||
|
Rect rect = new Rect(ref x, ref y, ref w, ref h);
|
|||
|
drawingContext.DrawRectangle(brush, stroke, rect);
|
|||
|
}
|
|||
|
|
|||
|
public void DrawRectangle(Rect rect, Color color)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(color);
|
|||
|
bool flag = pen != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush = pen.Brush;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
Rect rect2 = rect;
|
|||
|
drawingContext.DrawRectangle(brush, stroke, rect2);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DrawRectangle(float x, float y, float width, float height, Color color)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(color);
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush = pen.Brush;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
Rect rect = new Rect(ref x, ref y, ref width, ref height);
|
|||
|
drawingContext.DrawRectangle(brush, stroke, rect);
|
|||
|
}
|
|||
|
|
|||
|
public void FillRectangle(HatchStyles style, Color hatchColor, Color bgColor, Rect rect)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public void FillRectangle(HatchStyles style, Color hatchColor, Color bgColor, float x, float y, float width, float height)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
public void FillRectangle(Rect rect, Color color)
|
|||
|
{
|
|||
|
this.g.FillRectangle(this.resourceManager.GetBrush(color), rect);
|
|||
|
}
|
|||
|
|
|||
|
public void FillRectangle(float x, float y, float width, float height, Color color)
|
|||
|
{
|
|||
|
this.g.FillRectangle(this.resourceManager.GetBrush(color), new Rect(ref x, ref y, ref width, ref height));
|
|||
|
}
|
|||
|
|
|||
|
public void FillRectangle(Brush b, float x, float y, float width, float height)
|
|||
|
{
|
|||
|
this.g.FillRectangle(b, new Rect(ref x, ref y, ref width, ref height));
|
|||
|
}
|
|||
|
|
|||
|
public void FillRectangleLinear(Color color1, Color color2, float angle, Rect rect)
|
|||
|
{
|
|||
|
Point[] intersectionPoints = this.GetIntersectionPoints(rect, angle);
|
|||
|
LinearGradientBrush fillBrush = new LinearGradientBrush(new GradientStop[]
|
|||
|
{
|
|||
|
new GradientStop(color1, 0f),
|
|||
|
new GradientStop(color2, 1f)
|
|||
|
}, intersectionPoints[0], intersectionPoints[1], Matrix.Identity);
|
|||
|
this.g.FillRectangle(fillBrush, rect);
|
|||
|
}
|
|||
|
|
|||
|
private Vector VectorFromAngle(float angle)
|
|||
|
{
|
|||
|
angle = (float)((double)angle * 0.005555555555555556 * 3.141592653589793);
|
|||
|
return new Vector((float)Math.Cos((double)angle), (float)Math.Sin((double)angle));
|
|||
|
}
|
|||
|
|
|||
|
private Point[] GetIntersectionPoints(Rect rect, float angle)
|
|||
|
{
|
|||
|
Point[] array = new Point[2];
|
|||
|
bool flag = angle % 360f == 0f;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
array[0] = rect.Location;
|
|||
|
Point[] array2 = array;
|
|||
|
int num = 1;
|
|||
|
float num2 = rect.X + rect.Width;
|
|||
|
float num3 = rect.Y;
|
|||
|
array2[num] = new Point(ref num2, ref num3);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag2 = (angle - 90f) % 360f == 0f;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
array[0] = rect.Location;
|
|||
|
Point[] array3 = array;
|
|||
|
int num4 = 1;
|
|||
|
float num2 = rect.X;
|
|||
|
float num3 = rect.Y + rect.Height;
|
|||
|
array3[num4] = new Point(ref num2, ref num3);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag3 = (angle - 180f) % 360f == 0f;
|
|||
|
if (flag3)
|
|||
|
{
|
|||
|
Point[] array4 = array;
|
|||
|
int num5 = 0;
|
|||
|
float num2 = rect.X + rect.Width;
|
|||
|
float num3 = rect.Y;
|
|||
|
array4[num5] = new Point(ref num2, ref num3);
|
|||
|
array[1] = rect.Location;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
bool flag4 = (angle - 270f) % 360f == 0f;
|
|||
|
if (flag4)
|
|||
|
{
|
|||
|
Point[] array5 = array;
|
|||
|
int num6 = 0;
|
|||
|
float num2 = rect.X;
|
|||
|
float num3 = rect.Y + rect.Height;
|
|||
|
array5[num6] = new Point(ref num2, ref num3);
|
|||
|
array[1] = rect.Location;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return array;
|
|||
|
}
|
|||
|
|
|||
|
public void DrawRectangle(Rect rect, Color color, float width, LineStyles lineStyle)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(color, width, this.ToWPFDashStyle(lineStyle));
|
|||
|
bool flag = pen != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush = pen.Brush;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
drawingContext.DrawRectangle(brush, stroke, rect);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DrawAndFillRectangle(Rect rect, Color lineColor, Color fillColor)
|
|||
|
{
|
|||
|
this.g.FillRectangle(this.resourceManager.GetBrush(fillColor), rect);
|
|||
|
CPFPen pen = this.resourceManager.GetPen(lineColor);
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush = pen.Brush;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
Rect rect2 = rect;
|
|||
|
drawingContext.DrawRectangle(brush, stroke, rect2);
|
|||
|
}
|
|||
|
|
|||
|
public void DrawAndFillRectangle(Rect rect, Color lineColor, Color fillColor, float width, LineStyles lineStyle)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(lineColor, width, this.ToWPFDashStyle(lineStyle));
|
|||
|
SolidColorBrush brush = this.resourceManager.GetBrush(fillColor);
|
|||
|
bool flag = pen != null && brush != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
this.g.FillRectangle(brush, rect);
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush2 = pen.Brush;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
drawingContext.DrawRectangle(brush2, stroke, rect);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DrawImage(Image image, float x, float y, float width, float height)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Rect rect = new Rect(ref x, ref y, ref width, ref height);
|
|||
|
float num = 0f;
|
|||
|
float num2 = 0f;
|
|||
|
float num3 = (float)image.Width;
|
|||
|
float num4 = (float)image.Height;
|
|||
|
Rect rect2 = new Rect(ref num, ref num2, ref num3, ref num4);
|
|||
|
float num5 = 1f;
|
|||
|
drawingContext.DrawImage(image, rect, rect2, num5);
|
|||
|
}
|
|||
|
|
|||
|
public void DrawImage(Image image, Rect bounds)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Rect rect = bounds;
|
|||
|
float num = 0f;
|
|||
|
float num2 = 0f;
|
|||
|
float num3 = (float)image.Width;
|
|||
|
float num4 = (float)image.Height;
|
|||
|
Rect rect2 = new Rect(ref num, ref num2, ref num3, ref num4);
|
|||
|
float num5 = 1f;
|
|||
|
drawingContext.DrawImage(image, rect, rect2, num5);
|
|||
|
}
|
|||
|
|
|||
|
public void DrawText(string text, string fontName, float size, Color color, Rect rect)
|
|||
|
{
|
|||
|
this.DrawText(text, fontName, size, color, rect, ReoGridHorAlign.Left, ReoGridVerAlign.Top);
|
|||
|
}
|
|||
|
|
|||
|
public void DrawText(string text, string fontName, float size, Color color, Rect rect, ReoGridHorAlign halign, ReoGridVerAlign valign)
|
|||
|
{
|
|||
|
bool flag = rect.Width > 0f && rect.Height > 0f && !string.IsNullOrEmpty(text);
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
Font font = ResourcePoolManager.CreateFont(fontName, (double)size, FontStyles.Regular);
|
|||
|
Size size2 = DrawingFactory.Default.MeasureString(text, font, rect.Width);
|
|||
|
Point location = rect.Location;
|
|||
|
TextAlignment textAlignment = TextAlignment.Left;
|
|||
|
if (halign != ReoGridHorAlign.Center)
|
|||
|
{
|
|||
|
if (halign == ReoGridHorAlign.Right)
|
|||
|
{
|
|||
|
textAlignment = TextAlignment.Right;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
textAlignment = TextAlignment.Center;
|
|||
|
}
|
|||
|
if (valign != ReoGridVerAlign.Middle)
|
|||
|
{
|
|||
|
if (valign == ReoGridVerAlign.Bottom)
|
|||
|
{
|
|||
|
location.Y += rect.Height - size2.Height;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
location.Y += (rect.Height - size2.Height) / 2f;
|
|||
|
}
|
|||
|
AntialiasMode antialiasMode = this.g.AntialiasMode;
|
|||
|
this.g.AntialiasMode = AntialiasMode.AntiAlias;
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush fillBrush = color;
|
|||
|
float width = rect.Width;
|
|||
|
TextDecoration textDecoration = default(TextDecoration);
|
|||
|
float maxValue = float.MaxValue;
|
|||
|
TextTrimming textTrimming = TextTrimming.None;
|
|||
|
Stroke stroke = default(Stroke);
|
|||
|
drawingContext.DrawString(location, fillBrush, text, font, textAlignment, width, textDecoration, maxValue, textTrimming, stroke, null);
|
|||
|
this.g.AntialiasMode = antialiasMode;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void PushClip(Rect clipRect)
|
|||
|
{
|
|||
|
this.g.PushClip(clipRect);
|
|||
|
}
|
|||
|
|
|||
|
public void PopClip()
|
|||
|
{
|
|||
|
this.g.PopClip();
|
|||
|
}
|
|||
|
|
|||
|
public void PushTransform()
|
|||
|
{
|
|||
|
this.PushTransform(Matrix.Identity);
|
|||
|
}
|
|||
|
|
|||
|
public void PushTransform(Matrix m)
|
|||
|
{
|
|||
|
Matrix transform = this.g.Transform;
|
|||
|
this.transformStack.Push(transform);
|
|||
|
m *= transform;
|
|||
|
this.g.Transform = m;
|
|||
|
}
|
|||
|
|
|||
|
public Matrix PopTransform()
|
|||
|
{
|
|||
|
bool flag = this.transformStack.Count == 0;
|
|||
|
Matrix result;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
this.g.Transform = this.reset;
|
|||
|
result = this.reset;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Matrix matrix = this.transformStack.Pop();
|
|||
|
this.g.Transform = matrix;
|
|||
|
result = matrix;
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
public void TranslateTransform(float x, float y)
|
|||
|
{
|
|||
|
Matrix transform = this.g.Transform;
|
|||
|
transform.TranslatePrepend(x, y);
|
|||
|
this.g.Transform = transform;
|
|||
|
}
|
|||
|
|
|||
|
public void ScaleTransform(float x, float y)
|
|||
|
{
|
|||
|
Matrix transform = this.g.Transform;
|
|||
|
transform.ScalePrepend(x, y);
|
|||
|
this.g.Transform = transform;
|
|||
|
}
|
|||
|
|
|||
|
public void RotateTransform(float angle)
|
|||
|
{
|
|||
|
Matrix transform = this.g.Transform;
|
|||
|
transform.RotatePrepend(angle);
|
|||
|
this.g.Transform = transform;
|
|||
|
}
|
|||
|
|
|||
|
public void ResetTransform()
|
|||
|
{
|
|||
|
this.g.Transform = this.reset;
|
|||
|
}
|
|||
|
|
|||
|
public void DrawEllipse(Color color, Rect rectangle)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(color);
|
|||
|
bool flag = pen != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush = pen.Brush;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
float num = rectangle.X + rectangle.Width / 2f;
|
|||
|
float num2 = rectangle.Y + rectangle.Height / 2f;
|
|||
|
Point point = new Point(ref num, ref num2);
|
|||
|
float width = rectangle.Width;
|
|||
|
float height = rectangle.Height;
|
|||
|
drawingContext.DrawEllipse(brush, stroke, point, width, height);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DrawEllipse(Color color, float x, float y, float width, float height)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(color);
|
|||
|
bool flag = pen != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush = pen.Brush;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
Point point = new Point(ref x, ref y);
|
|||
|
drawingContext.DrawEllipse(brush, stroke, point, width, height);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DrawEllipse(CPFPen pen, Rect rectangle)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush = pen.Brush;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
Point location = rectangle.Location;
|
|||
|
float width = rectangle.Width;
|
|||
|
float height = rectangle.Height;
|
|||
|
drawingContext.DrawEllipse(brush, stroke, location, width, height);
|
|||
|
}
|
|||
|
|
|||
|
public void FillEllipse(Brush b, Rect rectangle)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Point location = rectangle.Location;
|
|||
|
float width = rectangle.Width;
|
|||
|
float height = rectangle.Height;
|
|||
|
drawingContext.FillEllipse(b, location, width, height);
|
|||
|
}
|
|||
|
|
|||
|
public void FillEllipse(Brush b, float x, float y, float width, float height)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Point point = new Point(ref x, ref y);
|
|||
|
drawingContext.FillEllipse(b, point, width, height);
|
|||
|
}
|
|||
|
|
|||
|
public void DrawPolygon(Color color, float width, LineStyles style, params Point[] points)
|
|||
|
{
|
|||
|
this.DrawLines(points, 0, points.Length, color, width, style);
|
|||
|
}
|
|||
|
|
|||
|
public void FillPolygon(Color color, params Point[] points)
|
|||
|
{
|
|||
|
bool flag = !color.IsTransparent;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
PathGeometry pathGeometry = new PathGeometry();
|
|||
|
bool flag2 = points != null && points.Length > 1;
|
|||
|
if (flag2)
|
|||
|
{
|
|||
|
pathGeometry.BeginFigure(points[0].X, points[0].Y);
|
|||
|
for (int i = 1; i < points.Length; i++)
|
|||
|
{
|
|||
|
pathGeometry.LineTo(points[i].X, points[i].Y);
|
|||
|
}
|
|||
|
pathGeometry.EndFigure(true);
|
|||
|
}
|
|||
|
this.g.FillPath(new SolidColorBrush(color), pathGeometry);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public bool IsAntialias
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Reset()
|
|||
|
{
|
|||
|
this.transformStack.Clear();
|
|||
|
}
|
|||
|
|
|||
|
internal void SetPlatformGraphics(DrawingContext dc)
|
|||
|
{
|
|||
|
this.g = dc;
|
|||
|
}
|
|||
|
|
|||
|
internal DashStyles ToWPFDashStyle(LineStyles style)
|
|||
|
{
|
|||
|
DashStyles result;
|
|||
|
switch (style)
|
|||
|
{
|
|||
|
default:
|
|||
|
result = DashStyles.Solid;
|
|||
|
break;
|
|||
|
case LineStyles.Dash:
|
|||
|
result = DashStyles.Dash;
|
|||
|
break;
|
|||
|
case LineStyles.Dot:
|
|||
|
result = DashStyles.Dot;
|
|||
|
break;
|
|||
|
case LineStyles.DashDot:
|
|||
|
result = DashStyles.DashDot;
|
|||
|
break;
|
|||
|
case LineStyles.DashDotDot:
|
|||
|
result = DashStyles.DashDotDot;
|
|||
|
break;
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
public void FillPath(Color color, PathGeometry graphicsPath)
|
|||
|
{
|
|||
|
SolidColorBrush brush = this.resourceManager.GetBrush(color);
|
|||
|
bool flag = brush != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
this.g.FillPath(brush, graphicsPath);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void DrawPath(Color color, PathGeometry graphicsPath)
|
|||
|
{
|
|||
|
CPFPen pen = this.resourceManager.GetPen(color);
|
|||
|
bool flag = pen != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush brush = pen.Brush;
|
|||
|
Stroke stroke = pen.Stroke;
|
|||
|
drawingContext.DrawPath(brush, stroke, graphicsPath);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void FillEllipse(Color fillColor, Rect rect)
|
|||
|
{
|
|||
|
SolidColorBrush brush = this.resourceManager.GetBrush(fillColor);
|
|||
|
bool flag = brush != null;
|
|||
|
if (flag)
|
|||
|
{
|
|||
|
DrawingContext drawingContext = this.g;
|
|||
|
Brush fillBrush = brush;
|
|||
|
Point center = rect.Center;
|
|||
|
float width = rect.Width;
|
|||
|
float height = rect.Height;
|
|||
|
drawingContext.FillEllipse(fillBrush, center, width, height);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
protected ResourcePoolManager resourceManager = new ResourcePoolManager();
|
|||
|
|
|||
|
private DrawingContext g = null;
|
|||
|
|
|||
|
private Matrix reset;
|
|||
|
|
|||
|
private Stack<Matrix> transformStack = new Stack<Matrix>();
|
|||
|
}
|
|||
|
}
|