本文整理汇总了C#中CanvasRenderTarget.GetBounds方法的典型用法代码示例。如果您正苦于以下问题:C# CanvasRenderTarget.GetBounds方法的具体用法?C# CanvasRenderTarget.GetBounds怎么用?C# CanvasRenderTarget.GetBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CanvasRenderTarget
的用法示例。
在下文中一共展示了CanvasRenderTarget.GetBounds方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImageInfo
public ImageInfo(CanvasRenderTarget image)
{
_crt = image;
BitmapSize bsize = image.SizeInPixels;
Size size = image.Size;
_offset = new Point(size.Width / 2.0f, size.Height / 2.0f);
using (CanvasDrawingSession ds = image.CreateDrawingSession())
{
_symbolBounds = image.GetBounds(ds);
_imageBounds = ShapeUtilities.clone(_symbolBounds);
}
}
示例2: getIcon
public static ImageInfo getIcon(String symbolID, int size, Color color, int outlineSize)
{
ImageInfo returnVal = null;
if (_tgl == null)
_tgl = TacticalGraphicLookup.getInstance();
int mapping = _tgl.getCharCodeFromSymbol(symbolID);
CanvasRenderTarget coreBMP = null;
SVGPath svgTG = null;
//SVGPath svgFrame = null;
if (mapping > 0)
svgTG = TGSVGTable.getInstance().getSVGPath(mapping);
//float scale = 1;
Matrix3x2 mScale, mTranslate;
Matrix3x2 mIdentity = Matrix3x2.Identity;
Rect rectF = new Rect();
Matrix3x2 m = svgTG.CreateMatrix(size, size, out rectF, out mScale, out mTranslate);
//svgTG.TransformToFitDimensions(size, size);
Rect rr = svgTG.computeBounds(m);
CanvasDevice device = CanvasDevice.GetSharedDevice();
//CanvasRenderTarget offscreen = new CanvasRenderTarget(device, width, height, 96);
coreBMP = new CanvasRenderTarget(device, (int)(rr.Width + 0.5), (int)(rr.Height + 0.5),96);
using (CanvasDrawingSession cds = coreBMP.CreateDrawingSession())
{
svgTG.Draw(cds, Colors.Transparent, 0, color, m);
cds.DrawRectangle(coreBMP.GetBounds(device), Colors.Red);
}
returnVal = new ImageInfo(coreBMP,new Point(coreBMP.Size.Width/2f,coreBMP.Size.Height/2.0f),new Rect(0,0,coreBMP.Size.Width,coreBMP.Size.Height),coreBMP.GetBounds(device));
return returnVal;
}
示例3: ProcessUnitDisplayModifiers
//private static Bitmap _textBMP = new Bitmap(2, 2);
//private static Graphics _g = Graphics.FromImage(_textBMP);
//private static Matrix _identityMatrix = new Matrix();
//private static int _fontSize = RS.getModifierFontSize();
//private static FontStyle _fontStyle = RS.getModifierFontStyle();
//private static String _fontName = RS.getModifierFontName();
//private static int _modifierFontHeight = ShapeUtilities.round(_g.MeasureString("Hj", RS.getLabelFont()).Height);
//private static Font _modifierFont = RS.getLabelFont();
/// <summary>
///
/// </summary>
/// <param name="symbolID"></param>
/// <param name="msb"></param>
/// <param name="modifiers"></param>
/// <param name="attributes"></param>
/// <returns></returns>
public static ImageInfo ProcessUnitDisplayModifiers(String symbolID, ImageInfo ii, Dictionary<int, String> modifiers, Dictionary<int, String> attributes, Boolean hasTextModifiers, CanvasDevice device)
{
ImageInfo newii = null;
Rect symbolBounds = ShapeUtilities.clone(ii.getSymbolBounds());
Rect imageBounds = ShapeUtilities.clone(ii.getCanvasRenderTarget().GetBounds(device));
Point centerPoint = ShapeUtilities.clone(ii.getAnchorPoint());
TextInfo tiEchelon = null;
TextInfo tiAM = null;
Rect echelonBounds = Rect.Empty;
Rect amBounds = Rect.Empty;
Color textColor = Colors.Black;
Color textBackgroundColor = Colors.Transparent;
int buffer = 0;
//ctx = null;
int offsetX = 0;
int offsetY = 0;
int symStd = RS.getSymbologyStandard();
CanvasTextFormat font = RS.getLabelFont();
/*Pen mobilityPen = new Pen(Colors.Black, 2f);
mobilityPen.MiterLimit = 2;//*/
try
{
if(device == null)
{
device = CanvasDevice.GetSharedDevice();
}
if (attributes.ContainsKey(MilStdAttributes.SymbologyStandard))
{
symStd = Convert.ToInt16(attributes[MilStdAttributes.SymbologyStandard]);
}
if (attributes.ContainsKey(MilStdAttributes.TextColor))
{
textColor = SymbolUtilities.getColorFromHexString(attributes[MilStdAttributes.TextColor]);
}
if (attributes.ContainsKey(MilStdAttributes.TextBackgroundColor))
{
textBackgroundColor = SymbolUtilities.getColorFromHexString(attributes[MilStdAttributes.TextBackgroundColor]);
}
#region Build Mobility Modifiers
Rect mobilityBounds = Rect.Empty;
List<CanvasGeometry> shapes = new List<CanvasGeometry>();
CanvasPathBuilder mobilityPath = null;
CanvasPathBuilder mobilityPathFill = null;
CanvasGeometry cgMobilityPath = null;
CanvasGeometry cgMobilityPathFill = null;
if (symbolID[10] == ('M') || symbolID[10] == ('N'))
{
//Draw Mobility
int fifth = (int)((symbolBounds.Width * 0.2) + 0.5f);
mobilityPath = new CanvasPathBuilder(device);
int x = 0;
int y = 0;
int centerX = 0;
int bottomY = 0;
int height = 0;
int width = 0;
int middleY = 0;
int wheelOffset = 2;
int wheelSize = fifth;//10;
int rrHeight = fifth;//10;
int rrArcWidth = (int)((fifth * 1.5) + 0.5f);//16;
String mobility = symbolID.Substring(10, 2);
x = (int)symbolBounds.Left;
y = (int)symbolBounds.Top;
height = (int)(symbolBounds.Height);
width = (int)(symbolBounds.Width);
bottomY = y + height + 2;
if (symbolID[10] == ('M'))
{
bottomY = y + height + 2;
//wheelSize = width / 7;
//rrHeight = width / 7;
//rrArcWidth = width / 7;
if (mobility.Equals("MO"))
//.........这里部分代码省略.........