本文整理汇总了C#中BoundingRectangle类的典型用法代码示例。如果您正苦于以下问题:C# BoundingRectangle类的具体用法?C# BoundingRectangle怎么用?C# BoundingRectangle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoundingRectangle类属于命名空间,在下文中一共展示了BoundingRectangle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TestHoldValue
public void TestHoldValue()
{
BoundingRectangle boundingRectangle0 = new BoundingRectangle();
Assert.AreEqual(boundingRectangle0.Left, 0);
Assert.AreEqual(boundingRectangle0.Bottom, 0);
Assert.AreEqual(boundingRectangle0.Right, 0);
Assert.AreEqual(boundingRectangle0.Top, 0);
Assert.AreEqual(boundingRectangle0.Height, 0);
Assert.AreEqual(boundingRectangle0.Width, 0);
Assert.AreEqual(BoundingRectangle.Empty.Left, 0);
Assert.AreEqual(BoundingRectangle.Empty.Bottom, 0);
Assert.AreEqual(BoundingRectangle.Empty.Right, 0);
Assert.AreEqual(BoundingRectangle.Empty.Top, 0);
Assert.AreEqual(BoundingRectangle.Empty.Height, 0);
Assert.AreEqual(BoundingRectangle.Empty.Width, 0);
BoundingRectangle boundingRectangle1 = new BoundingRectangle(1, 2, 3, 4);
Assert.AreEqual(boundingRectangle1.Left, 1);
Assert.AreEqual(boundingRectangle1.Bottom, 2);
Assert.AreEqual(boundingRectangle1.Right, 3);
Assert.AreEqual(boundingRectangle1.Top, 4);
Assert.AreEqual(boundingRectangle1.Height, 2);
Assert.AreEqual(boundingRectangle1.Width, 2);
}
开发者ID:AnalyticalGraphicsInc,项目名称:czml-writer,代码行数:25,代码来源:TestBoundingRectangle.cs
示例2: RenderRaster
public void RenderRaster(Graphics g, Bitmap bitmap, RasterStyle style, BoundingRectangle viewBox, BoundingRectangle bitmapBounds, double scaleFactor)
{
ICoordinate minPoint = bitmapBounds.Min;
ICoordinate maxPoint = bitmapBounds.Max;
if (viewBox.Intersects(bitmapBounds))
{
Point minP = new Point((int)((minPoint.X - viewBox.MinX) * scaleFactor),
(int)((viewBox.MaxY - minPoint.Y) * scaleFactor));
Point maxP = new Point((int)((maxPoint.X - viewBox.MinX) * scaleFactor),
(int)((viewBox.MaxY - maxPoint.Y) * scaleFactor));
g.InterpolationMode = style.InterpolationMode;
Rectangle r = new Rectangle(minP.X, maxP.Y, maxP.X - minP.X, minP.Y - maxP.Y);
using (ImageAttributes imageAttributes = new ImageAttributes())
{
imageAttributes.SetColorMatrix(style.ColorAdjustmentMatrix,
ColorMatrixFlag.Default,
ColorAdjustType.Bitmap);
g.DrawImage(bitmap, r, 0, 0, bitmap.Width, bitmap.Height,
GraphicsUnit.Pixel, imageAttributes);
}
}
}
开发者ID:gkrsu,项目名称:maparound.core,代码行数:28,代码来源:RasterRendering.cs
示例3: Read
/// <summary>
/// Читает запись представляющую коллекцию точек.
/// </summary>
/// <param name="file">Входной поток</param>
/// <param name="record">Запись Shape-файла в которую будет помещена прочитанная информация</param>
/// <param name="bounds">Ограничивающий прямоугольник, с которым должен пересекаться ограничивающий прямоугольник записи</param>
public override bool Read(Stream file, BoundingRectangle bounds, ShapeFileRecord record)
{
try
{
record.MinX = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
record.MinY = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
record.MaxX = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
record.MaxY = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
int numPoints = file.ReadInt32();// ShapeFile.ReadInt32_LE(stream);
if (!ShapeHandler.IsRecordInView(bounds, record))
{
file.Seek((long)numPoints * 16, SeekOrigin.Current);
return false;
}
for (int i = 0; i < numPoints; i++)
{
ICoordinate p =
PlanimetryEnvironment.NewCoordinate(
file.ReadDouble(),//ShapeFile.ReadDouble64_LE(stream),
file.ReadDouble());//ShapeFile.ReadDouble64_LE(stream));
record.Points.Add(p);
}
return true;
}
catch { throw; }
}
开发者ID:gkrsu,项目名称:maparound.core,代码行数:37,代码来源:MultiPointHandler.cs
示例4: WriteBoundingRectangle
/// <summary>
/// Writes a <see cref="BoundingRectangle"/> value as an array in X, Y, Width, Height order.
/// </summary>
/// <param name="output">The stream to which to write the value.</param>
/// <param name="value">The value to write.</param>
public static void WriteBoundingRectangle(CesiumOutputStream output, BoundingRectangle value)
{
output.WriteStartSequence();
output.WriteValue(value.Left);
output.WriteValue(value.Bottom);
output.WriteValue(value.Width);
output.WriteValue(value.Height);
output.WriteEndSequence();
}
开发者ID:AnalyticalGraphicsInc,项目名称:czml-writer,代码行数:14,代码来源:CesiumWritingHelper.cs
示例5: Init
public void Init()
{
circle1 = new BoundingCircle(Vector2D.YAxis, 2);
circle2 = new BoundingCircle(Vector2D.XAxis, 2);
rect1 = BoundingRectangle.FromCircle(circle1);
circle3 = BoundingCircle.FromRectangle(rect1);
rect2 = BoundingRectangle.FromCircle(circle3);
polygon1 = new BoundingPolygon(rect1.Corners());
}
开发者ID:bsvercl,项目名称:physics2d,代码行数:9,代码来源:BoundingCircleTest.cs
示例6: TestGetHashCode
public void TestGetHashCode()
{
BoundingRectangle boundingRectangle1 = new BoundingRectangle(1, 2, 3, 4);
BoundingRectangle boundingRectangle2 = new BoundingRectangle(1, 2, 3, 4);
BoundingRectangle boundingRectangle3 = new BoundingRectangle(2, 3, 4, 5);
Assert.AreEqual(boundingRectangle1.GetHashCode(), boundingRectangle2.GetHashCode());
Assert.AreNotEqual(boundingRectangle1.GetHashCode(), boundingRectangle3.GetHashCode());
}
开发者ID:AnalyticalGraphicsInc,项目名称:czml-writer,代码行数:9,代码来源:TestBoundingRectangle.cs
示例7: TestEqualsEpsilon
public void TestEqualsEpsilon()
{
BoundingRectangle boundingRectangle = new BoundingRectangle(1000, 2000, 3000, 4000);
BoundingRectangle similarBoundingRectangle = new BoundingRectangle(1010, 2010, 3010, 4010);
Assert.IsTrue(boundingRectangle.EqualsEpsilon(similarBoundingRectangle, 1000));
Assert.IsTrue(boundingRectangle.EqualsEpsilon(similarBoundingRectangle, 100));
Assert.IsTrue(boundingRectangle.EqualsEpsilon(similarBoundingRectangle, 10));
Assert.IsFalse(boundingRectangle.EqualsEpsilon(similarBoundingRectangle, 1));
}
开发者ID:AnalyticalGraphicsInc,项目名称:czml-writer,代码行数:10,代码来源:TestBoundingRectangle.cs
示例8: IsRecordInView
/// <summary>Проверка записи на нахождение границ фигуры в указанной области</summary>
/// <param name="bounds">Границы области</param>
/// <param name="record">Запись shape-файла</param>
/// <returns></returns>
protected static bool IsRecordInView(BoundingRectangle bounds, ShapeFileRecord record)
{
if (bounds != null && !bounds.IsEmpty())
{
if (!bounds.Intersects(
new BoundingRectangle(PlanimetryEnvironment.NewCoordinate(record.MinX, record.MinY),
PlanimetryEnvironment.NewCoordinate(record.MaxX, record.MaxY))))
return false;
}
return true;
}
开发者ID:gkrsu,项目名称:maparound.core,代码行数:15,代码来源:ShapeHandler.cs
示例9: ContainsPoint
public void ContainsPoint()
{
BoundingRectangle rect = new BoundingRectangle(0, 0, 2, 2);
Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(1, 1)), "1");
Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(2, 2)), "2");
Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(0, 2)), "3");
Assert.AreEqual(ContainmentType.Contains, rect.Contains(new Vector2D(0, 0)), "4");
Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(2, 3)), "5");
Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(-1, 0)), "6");
Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(-.0001f, 0)), "7");
Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(3, 1)), "8");
Assert.AreEqual(ContainmentType.Disjoint, rect.Contains(new Vector2D(1, -1)), "9");
}
开发者ID:bsvercl,项目名称:physics2d,代码行数:13,代码来源:BoundingRectangleTest.cs
示例10: Open
protected override void Open()
{
dispose += DemoHelper.BasicDemoSetup(DemoInfo);
Scene.Engine.AddLogic(new LineFluidLogic(new Line(0, -1, -400), 1.95f, .02f, new Vector2D(0, 0), new Lifespan()));
Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan()));
Rectangle rect1 = Viewport.Rectangle;
BoundingRectangle rect = new BoundingRectangle(rect1.Left, rect1.Top, rect1.Right, rect1.Bottom);
rect.Min.X -= 75;
rect.Min.Y -= 75;
rect.Max.X += 75;
rect.Max.Y += 75;
DemoHelper.AddShell(DemoInfo, rect, 100, Scalar.PositiveInfinity).ForEach(delegate(Body b) { b.IgnoresGravity = true; });
DemoHelper.AddRagDoll(DemoInfo, new Vector2D(340, 300));
DemoHelper.AddRagDoll(DemoInfo, new Vector2D(640, 300));
IShape shape = ShapeFactory.CreateSprite(Cache<SurfacePolygons>.GetItem("fighter.png"), 3, 16, 4);
DemoHelper.AddShape(DemoInfo, shape, 200, new ALVector2D(0, new Vector2D(200, 300)));
DemoHelper.AddShape(DemoInfo, shape, 100, new ALVector2D(0, new Vector2D(500, 300)));
DemoHelper.AddRectangle(DemoInfo, 20, 200, 25 / 5, new ALVector2D(0, 600, 600));
DemoHelper.AddRectangle(DemoInfo, 20, 200, 25 / 5, new ALVector2D(0, 600, 620));
DemoHelper.AddRectangle(DemoInfo, 50, 100, 50, new ALVector2D(0, 200, 400));
DemoHelper.AddRectangle(DemoInfo, 50, 100, 50, new ALVector2D(0, 400, 200));
Vector2D[] waterVertexes = new Vector2D[4]
{
new Vector2D(-10, 400),
new Vector2D(10000, 400),
new Vector2D(10000, 1000),
new Vector2D(-10, 1000)
};
ScalarColor3[] waterColor = new ScalarColor3[4]
{
new ScalarColor3(0,0,1),
new ScalarColor3(0,0,1),
new ScalarColor3(0,0,1),
new ScalarColor3(0,0,1)
};
Colored3VertexesDrawable drawable = new Colored3VertexesDrawable(Gl.GL_QUADS, waterVertexes, waterColor);
Graphic graphic = new Graphic(drawable, Matrix2x3.Identity, new Lifespan());
graphic.ZOrder = -1;
Scene.AddGraphic(graphic);
}
开发者ID:timdetering,项目名称:Physics2D.Net,代码行数:49,代码来源:FluidDragBuoyancyDemo.cs
示例11: TransformBoundingRectangle
/// <summary>
/// Transforms coordinates of the bounding rectangle.
/// </summary>
/// <param name="box">Rectangle to transform</param>
/// <param name="transform">The transformation to apply</param>
/// <returns>The transformed rectangle</returns>
public static BoundingRectangle TransformBoundingRectangle(BoundingRectangle box, IMathTransform transform)
{
if (box == null)
return null;
ICoordinate[] corners = new ICoordinate[4];
corners[0] = PlanimetryEnvironment.NewCoordinate(transform.Transform(box.Min.Values()));
corners[1] = PlanimetryEnvironment.NewCoordinate(transform.Transform(box.Max.Values()));
corners[2] = PlanimetryEnvironment.NewCoordinate(transform.Transform(PlanimetryEnvironment.NewCoordinate(box.MinX, box.MaxY).Values()));
corners[3] = PlanimetryEnvironment.NewCoordinate(transform.Transform(PlanimetryEnvironment.NewCoordinate(box.MaxX, box.MinY).Values()));
BoundingRectangle result = new BoundingRectangle();
for (int i = 0; i < 4; i++)
result.Join(corners[i]);
return result;
}
开发者ID:gkrsu,项目名称:maparound.core,代码行数:21,代码来源:Transformers.cs
示例12: EqualityTest
public void EqualityTest()
{
BoundingRectangle boundingRectangle = new BoundingRectangle(1, 2, 3, 4);
BoundingRectangle sameBoundingRectangle = new BoundingRectangle(1, 2, 3, 4);
BoundingRectangle diffBoundingRectangle = new BoundingRectangle(2, 3, 4, 5);
Assert.IsTrue(boundingRectangle.Equals(sameBoundingRectangle));
Assert.IsFalse(boundingRectangle.Equals(diffBoundingRectangle));
Assert.IsTrue(boundingRectangle == sameBoundingRectangle);
Assert.IsTrue(boundingRectangle != diffBoundingRectangle);
object nonBoundingRectangleObject = new object();
Assert.IsFalse(boundingRectangle.Equals(nonBoundingRectangleObject));
object boundingRectangleObject = boundingRectangle;
Assert.IsTrue(boundingRectangle.Equals(boundingRectangleObject));
}
开发者ID:AnalyticalGraphicsInc,项目名称:czml-writer,代码行数:17,代码来源:TestBoundingRectangle.cs
示例13: Read
/// <summary>
/// Читает запись представляющую точку.
/// </summary>
/// <param name="file">Входной поток</param>
/// <param name="record">Запись Shape-файла в которую будет помещена прочитанная информация</param>
/// <param name="bounds">Ограничивающий прямоугольник, с которым должен пересекаться ограничивающий прямоугольник записи</param>
public override bool Read(/*BigEndianBinaryReader*/Stream file, BoundingRectangle bounds, ShapeFileRecord record)
{
ICoordinate p = PlanimetryEnvironment.NewCoordinate(0, 0);
p.X = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
p.Y = file.ReadDouble();// ShapeFile.ReadDouble64_LE(stream);
if (bounds != null && !bounds.IsEmpty() && !bounds.ContainsPoint(p))
return false;
record.Points.Add(p);
record.MinX = p.X;
record.MinY = p.Y;
record.MaxX = record.MinX;
record.MaxY = record.MinY;
return true;
}
开发者ID:gkrsu,项目名称:maparound.core,代码行数:25,代码来源:PointHandler.cs
示例14: Open
protected override void Open()
{
dispose += DemoHelper.BasicDemoSetup(DemoInfo);
Rectangle rect1 = Viewport.Rectangle;
BoundingRectangle rect = new BoundingRectangle(rect1.Left, rect1.Top, rect1.Right, rect1.Bottom);
rect.Min.X -= 75;
rect.Min.Y -= 75;
rect.Max.X += 75;
rect.Max.Y += 75;
DemoHelper.AddShell(DemoInfo, rect, 100, Scalar.PositiveInfinity).ForEach(delegate(Body b) { b.IgnoresGravity = true; });
rect.Min.X += 110;
rect.Min.Y += 110;
rect.Max.X -= 110;
rect.Max.Y -= 110;
IShape shape = ShapeFactory.CreateColoredCircle(3, 7);
DemoHelper.AddGrid(DemoInfo, shape, 40,
rect,
1, 1).ForEach(delegate(Body b) { b.State.Velocity.Linear = new Vector2D(DemoHelper.Rand.Next(-100, 100), DemoHelper.Rand.Next(-100, 100)); });
}
开发者ID:bsvercl,项目名称:physics2d,代码行数:20,代码来源:CirclesContainedStressDemo.cs
示例15: GetBoundsFromPath
public static BoundingRectangle GetBoundsFromPath(List<PathInfo> list)
{
// Only support simple paths
if (list.First().segmentType != SegmentType.Move)
{
return null;
}
if (list.Last().segmentType != SegmentType.Close)
{
return null;
}
if (list.Skip(1).Take(list.Count - 2).Any(p => p.segmentType != SegmentType.Line))
{
return null;
}
BoundingRectangle ret = new BoundingRectangle();
foreach (var i in list.Take(list.Count - 1))
{
ret.UpdateBounds(i.point);
}
return ret;
}
开发者ID:jcookems,项目名称:freezing-ninja,代码行数:24,代码来源:BoundingRectangle.cs
示例16: drawPolylineSimple
private void drawPolylineSimple(Graphics g, Feature feature, PolylineStyle style, BoundingRectangle viewBox, double scaleFactor)
{
foreach (LinePath path in feature.Polyline.Paths)
{
if (path.Vertices.Count < 2)
continue;
PointF[] points = new PointF[path.Vertices.Count];
for (int j = 0; j < path.Vertices.Count; j++)
{
points[j].X = (float)((path.Vertices[j].X - viewBox.MinX) * scaleFactor);
points[j].Y = (float)((viewBox.MaxY - path.Vertices[j].Y) * scaleFactor);
}
//selection and Stroke
if (style.UseOutline || feature.Selected)
drawLinePathSelectionAndOutline(g, feature.Selected, points, style);
using (Pen pen = style.GetPen())
{
pen.DashOffset = 0;
//main polyline
g.DrawLines(pen, points);
if (style.UseAnnexLine)
using (Pen annexPen = style.GetAnnexPen())
{
// additional line
g.DrawLines(annexPen, points);
}
}
}
}
开发者ID:gkrsu,项目名称:maparound.core,代码行数:34,代码来源:FeatureRendering.cs
示例17: DrawPolygon
/// <summary>
/// Draw a polygon.
/// </summary>
protected virtual void DrawPolygon(Feature feature, Graphics g, PolygonStyle style, TitleStyle titleStyle,
BoundingRectangle viewBox, bool titleVisible, double scaleFactor)
{
if (feature.Polygon.Contours.Count == 0)
return;
//if (feature.Layer != null && feature.Layer.Title == "adp.TAB")
//{
// drawPrismPolygon(feature, g, viewBox, scaleFactor);
// // inscription
// if (!string.IsNullOrEmpty(feature.Title) && titleVisible)
// addTitleBufferElement(g, feature, titleStyle, viewBox, scaleFactor);
// return;
//}
if (!_isSelectionRendering && feature.Selected)
{
PolygonBufferElement element = new PolygonBufferElement(feature, style, titleStyle, titleVisible);
_selectedPolygons.Add(element);
return;
}
double pixelsize = 1/scaleFactor;
if (_reduceSubpixelDetails)
{
if (feature.BoundingRectangle.Width < pixelsize && feature.BoundingRectangle.Height < pixelsize)
return;
Polygon tempPolygon = (Polygon) feature.Polygon.Clone();
tempPolygon.Weed(pixelsize);
Feature tempFeature = new Feature(FeatureType.Polygon);
tempFeature.Title = feature.Title;
tempFeature.Selected = feature.Selected;
tempFeature.Polygon = tempPolygon;
feature = tempFeature;
if (feature.Polygon.Contours.Count == 0)
return;
}
using (Pen pen = style.GetPen())
{
using (GraphicsPath path = new GraphicsPath(FillMode.Alternate))
{
path.StartFigure();
float x = (float) ((feature.Polygon.Contours[0].Vertices[0].X - viewBox.MinX)*scaleFactor);
float y = (float) ((viewBox.MaxY - feature.Polygon.Contours[0].Vertices[0].Y)*scaleFactor);
g.RenderingOrigin = new Point((int) Math.Round(x), (int) Math.Round(y));
foreach (Contour c in feature.Polygon.Contours)
{
// there is no point in trying to draw the contours of the degenerate
if (c.Vertices.Count <= 2)
continue;
PointF[] points = new PointF[c.Vertices.Count];
for (int j = 0; j < c.Vertices.Count; j++)
{
points[j].X = (float) ((c.Vertices[j].X - viewBox.MinX)*scaleFactor);
points[j].Y = (float) ((viewBox.MaxY - c.Vertices[j].Y)*scaleFactor);
}
if (points.Length > 2)
path.AddPolygon(points);
}
path.CloseFigure();
// Fill polygon
using (Brush b = style.GetBrush())
{
if (style.FillPatternInternal != null)
{
int w = style.FillPatternInternal.Width;
int h = style.FillPatternInternal.Height;
((TextureBrush) b).TranslateTransform(g.RenderingOrigin.X%w, g.RenderingOrigin.Y%h);
}
g.FillPath(b, path);
}
if (feature.Selected)
{
//Fills the selected polygon
//Color color = Color.FromArgb(50, _selectionColor);
//using (Brush b = new HatchBrush(HatchStyle.Percent70, color, Color.Transparent))
if (_selectionColorChanged || _selectionTexture == null)
createSelectionTexture();
using (Brush b = new TextureBrush(_selectionTexture))
{
((TextureBrush) b).TranslateTransform(g.RenderingOrigin.X%8, g.RenderingOrigin.Y%8);
//.........这里部分代码省略.........
开发者ID:gkrsu,项目名称:maparound.core,代码行数:101,代码来源:FeatureRendering.cs
示例18: DrawPolyline
/// <summary>
/// Drawing the line.
/// </summary>
protected virtual void DrawPolyline(Feature feature, Graphics g, PolylineStyle style, TitleStyle titleStyle,
BoundingRectangle viewBox, bool titleVisible, double scaleFactor)
{
if (!_isSelectionRendering && feature.Selected)
{
PolylineBufferElement element = new PolylineBufferElement(feature, style, titleStyle, titleVisible);
_selectedPolylines.Add(element);
return;
}
double pixelsize = 1/scaleFactor;
if (_reduceSubpixelDetails)
{
if (feature.BoundingRectangle.Width < pixelsize && feature.BoundingRectangle.Height < pixelsize)
return;
Polyline p1 = (Polyline) feature.Polyline.Clone();
p1.Weed(pixelsize);
Feature tempFeature = new Feature(FeatureType.Polyline);
tempFeature.Title = feature.Title;
tempFeature.Selected = feature.Selected;
tempFeature.Polyline = p1;
feature = tempFeature;
if (feature.Polyline.Paths.Count == 0)
return;
}
using (Pen pen = style.GetPen())
{
if (Math.Min(viewBox.Width/(feature.BoundingRectangle.Width),
viewBox.Height/(feature.BoundingRectangle.Height)) < 2)
drawPolylineWithIntersectCalculation(g, feature, style, viewBox, scaleFactor);
else
drawPolylineSimple(g, feature, style, viewBox, scaleFactor);
// inscription
if (!string.IsNullOrEmpty(feature.Title) && titleVisible)
addTitleBufferElement(g, feature, titleStyle, viewBox, scaleFactor);
}
}
开发者ID:gkrsu,项目名称:maparound.core,代码行数:45,代码来源:FeatureRendering.cs
示例19: DrawPoint
/// <summary>
/// Draw a point.
/// </summary>
protected virtual void DrawPoint(Feature feature, Graphics g, PointStyle style, TitleStyle titleStyle,
BoundingRectangle viewBox, bool titleVisible, double scaleFactor)
{
if (!_isSelectionRendering && feature.Selected)
{
PointBufferElement element = new PointBufferElement(feature, style, titleStyle, titleVisible);
_selectedPoints.Add(element);
return;
}
string _fontName = string.IsNullOrEmpty(style.FontName) ? _symbolsDefaultFontName : style.FontName;
using (Font f = new Font(_fontName, style.Size, FontStyle.Regular, GraphicsUnit.Pixel))
{
using (SolidBrush fontBrush = new SolidBrush(style.Color))
{
SizeF size;
SizeF offset;
if (style.DisplayKind == PointDisplayKind.Symbol)
// character size
size = g.MeasureString(style.Symbol.ToString(), f, new PointF(0, 0), _symbolStringFormat);
else
{
// image size
if (style.Image != null)
size = new SizeF(style.Image.Width, style.Image.Height);
else
size = new SizeF(1, 1);
}
//Offset relative to the center point
offset = new SizeF(size.Width/2,size.Height/2);
switch (style.ContentAlignment)
{
case ContentAlignment.TopLeft: offset = new SizeF(0, 0); break;
case ContentAlignment.TopCenter: offset = new SizeF(size.Width / 2,0); break;
case ContentAlignment.TopRight: offset = new SizeF(size.Width, 0); break;
case ContentAlignment.BottomLeft: offset = new SizeF(0, size.Height ); break;
case ContentAlignment.BottomCenter: offset = new SizeF(size.Width / 2, size.Height); break;
case ContentAlignment.BottomRight: offset = new SizeF(size.Width, size.Height); break;
case ContentAlignment.MiddleLeft: offset = new SizeF(0, size.Height / 2); break;
case ContentAlignment.MiddleCenter: offset = new SizeF(size.Width / 2, size.Height / 2); break;
case ContentAlignment.MiddleRight: offset = new SizeF(size.Width, size.Height / 2); break;
default:
throw new NotSupportedException();
}
IEnumerable<ICoordinate> targetPoints = null;
if (feature.FeatureType == FeatureType.Point)
targetPoints = new ICoordinate[] {feature.Point.Coordinate};
else
targetPoints = feature.MultiPoint.Points;
foreach (ICoordinate targetPoint in targetPoints)
{
if (style.DisplayKind == PointDisplayKind.Symbol)
{
// symbol
using (GraphicsPath path = new GraphicsPath())
{
path.AddString(style.Symbol.ToString(),
f.FontFamily,
(int) f.Style,
f.Size,
new PointF((float) ((targetPoint.X - viewBox.MinX)*scaleFactor-offset.Width),
(float)
((viewBox.MaxY - targetPoint.Y)*scaleFactor -offset.Height)),
_symbolStringFormat);
g.FillPath(fontBrush, path);
}
}
else
{
// image
if (style.Image != null)
g.DrawImageUnscaled(style.Image,
new Point(
(int)
Math.Round(((targetPoint.X - viewBox.MinX)*scaleFactor -
offset.Width)),
(int)
Math.Round(((viewBox.MaxY - targetPoint.Y)*scaleFactor -
offset.Height))));
}
if (feature.Selected)
{
// Frame selected object
using (Pen p = new Pen(_selectionColor, 2))
g.DrawRectangle(p,
//.........这里部分代码省略.........
开发者ID:gkrsu,项目名称:maparound.core,代码行数:101,代码来源:FeatureRendering.cs
示例20: FlushTitles
void IFeatureRenderer.FlushTitles(Graphics g, BoundingRectangle viewBox, double scaleFactor)
{
FlushTitles(g, viewBox, scaleFactor);
}
开发者ID:gkrsu,项目名称:maparound.core,代码行数:4,代码来源:FeatureRendering.cs
注:本文中的BoundingRectangle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论