本文整理汇总了C#中VerticalAlignment类的典型用法代码示例。如果您正苦于以下问题:C# VerticalAlignment类的具体用法?C# VerticalAlignment怎么用?C# VerticalAlignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VerticalAlignment类属于命名空间,在下文中一共展示了VerticalAlignment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DrawTextInternal
protected override void DrawTextInternal(string value, Font font, Rectangle rectangle, Color color, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
{
System.Windows.Forms.TextFormatFlags flags = System.Windows.Forms.TextFormatFlags.Left;
switch (horizontalAlignment)
{
case HorizontalAlignment.Center:
{
flags |= System.Windows.Forms.TextFormatFlags.HorizontalCenter;
break;
}
case HorizontalAlignment.Right:
{
flags |= System.Windows.Forms.TextFormatFlags.Right;
break;
}
}
switch (verticalAlignment)
{
case VerticalAlignment.Bottom:
{
flags |= System.Windows.Forms.TextFormatFlags.Bottom;
break;
}
case VerticalAlignment.Middle:
{
flags |= System.Windows.Forms.TextFormatFlags.VerticalCenter;
break;
}
}
System.Windows.Forms.TextRenderer.DrawText(mvarGraphics, value, FontToNativeFont(font), RectangleToNativeRectangle(rectangle), ColorToNativeColor(color), flags);
}
开发者ID:alcexhim,项目名称:UniversalWidgetToolkit,代码行数:31,代码来源:Win32Graphics.cs
示例2: CreateSprite
public void CreateSprite(SpriteBatch batch, int px, int py, string text, Color color, HorizontalAlignment horizontal, VerticalAlignment vertical)
{
int width = MeasureWidth(text);
int height = MeasureHeight(text);
int x = 0, y = 0;
switch (horizontal)
{
case HorizontalAlignment.Left: x = px; break;
case HorizontalAlignment.Center: x = px - width / 2; break;
case HorizontalAlignment.Right: x = px - width; break;
}
switch (vertical)
{
case VerticalAlignment.Top: y = py; break;
case VerticalAlignment.Center: y = py - height / 2 - 1; break;
case VerticalAlignment.Bottom: y = py - height; break;
}
byte[] bytes = System.Text.Encoding.Default.GetBytes(text);
for (int i = 0; i < bytes.Length; i++)
{
var b = bytes[i];
if (b != 32)
{
if (i > 0)
{
x -= _kerning[bytes[i - 1] * 256 + bytes[i]]-1;
}
batch.AddSprite(_material, new Vector2(x, y + _charInfo[b].YOffset), new Vector2(x + _charInfo[b].Width, y + _charInfo[b].YOffset + _charInfo[b].Height), _charInfo[b].U1, _charInfo[b].V1, _charInfo[b].U2, _charInfo[b].V2, color);
}
x += _charInfo[b].Width;
}
}
开发者ID:Tokter,项目名称:TokED,代码行数:34,代码来源:Font.cs
示例3: GetPolygon
/// <summary>
/// Gets the polygon outline of the specified rotated and aligned box.
/// </summary>
/// <param name="size">The size of the box.</param>
/// <param name="origin">The origin of the box.</param>
/// <param name="angle">The rotation angle of the box.</param>
/// <param name="horizontalAlignment">The horizontal alignment of the box.</param>
/// <param name="verticalAlignment">The vertical alignment of the box.</param>
/// <returns>A sequence of points defining the polygon outline of the box.</returns>
public static IEnumerable<ScreenPoint> GetPolygon(this OxySize size, ScreenPoint origin, double angle, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
{
var u = horizontalAlignment == HorizontalAlignment.Left ? 0 : horizontalAlignment == HorizontalAlignment.Center ? 0.5 : 1;
var v = verticalAlignment == VerticalAlignment.Top ? 0 : verticalAlignment == VerticalAlignment.Middle ? 0.5 : 1;
var offset = new ScreenVector(u * size.Width, v * size.Height);
// the corners of the rectangle
var p0 = new ScreenVector(0, 0) - offset;
var p1 = new ScreenVector(size.Width, 0) - offset;
var p2 = new ScreenVector(size.Width, size.Height) - offset;
var p3 = new ScreenVector(0, size.Height) - offset;
if (angle != 0)
{
var theta = angle * Math.PI / 180.0;
var costh = Math.Cos(theta);
var sinth = Math.Sin(theta);
Func<ScreenVector, ScreenVector> rotate = p => new ScreenVector((costh * p.X) - (sinth * p.Y), (sinth * p.X) + (costh * p.Y));
p0 = rotate(p0);
p1 = rotate(p1);
p2 = rotate(p2);
p3 = rotate(p3);
}
yield return origin + p0;
yield return origin + p1;
yield return origin + p2;
yield return origin + p3;
}
开发者ID:apmKrauser,项目名称:RCUModulTest,代码行数:40,代码来源:OxySizeExtensions.cs
示例4: drawStringCustom
public static void drawStringCustom(SpriteBatch sprite, String text, String fontName, int size, Color color,
Vector2 position, VerticalAlignment alignment, HorizontalAlignment horizontalAlignment, Matrix transform)
{
SpriteFont font = FontFactory.getInstance().getFont(fontName).getSize(size);
switch (alignment)
{
case VerticalAlignment.LEFTALIGN:
position = new Vector2(position.X - font.MeasureString(text).X, position.Y);
break;
case VerticalAlignment.RIGHTALIGN:
break;
case VerticalAlignment.CENTERED:
position = new Vector2(position.X - (font.MeasureString(text).X / 2), position.Y);
break;
}
switch (horizontalAlignment)
{
case HorizontalAlignment.ABOVE:
position = new Vector2(position.X, position.Y - font.MeasureString(text).Y);
break;
case HorizontalAlignment.BELOW:
break;
case HorizontalAlignment.CENTERED:
position = new Vector2(position.X, position.Y - font.MeasureString(text).Y / 2);
break;
}
SpriteBatchWrapper.DrawStringCustom(font, text, new Vector2((int)position.X, (int)position.Y), color, transform);
}
开发者ID:AliMohsen,项目名称:untitled-game,代码行数:28,代码来源:DrawStringHelper.cs
示例5: Sprite
protected internal Sprite(GridPointMatrix matrix, Frame frame)
{
id = Guid.NewGuid().ToString();
parentGrid = matrix;
animator = new Animator(this);
movement = new Movement(this);
pauseAnimation = false;
pauseMovement = false;
horizAlign = HorizontalAlignment.Center;
vertAlign = VerticalAlignment.Bottom;
nudgeX = 0;
nudgeY = 0;
CurrentFrame = frame;
if ((Sprites.SizeNewSpritesToParentGrid) && (parentGrid != null))
renderSize = new Size(parentGrid.GridPointWidth, parentGrid.GridPointHeight);
else
renderSize = CurrentFrame.Tilesheet.TileSize;
zOrder = 1;
if (parentGrid != null)
parentGrid.RefreshQueue.AddPixelRangeToRefreshQueue(this.DrawLocation, true);
Sprites._spriteList.Add(this);
CreateChildSprites();
}
开发者ID:Isthimius,项目名称:Gondwana,代码行数:27,代码来源:Sprite.cs
示例6: MatrixViewModel
public MatrixViewModel(IReadOnlyList<BoxModel> boxes,
int columnCount,
int rowCount,
HorizontalAlignment defaultColumnAlignment = HorizontalAlignment.Center,
VerticalAlignment defaultRowAlignment = VerticalAlignment.Center,
VerticalAlignment defaultMatrixAlignment = VerticalAlignment.Center)
: base(boxes, GetPositions(columnCount, rowCount))
{
Contract.Requires(columnCount >= 1);
Contract.Requires(rowCount >= 1);
Contract.Requires(boxes.Count == columnCount * rowCount);
Contract.Requires(defaultColumnAlignment.IsValid());
Contract.Requires(defaultRowAlignment.IsValid());
columnAlignments = new List<HorizontalAlignment>();
ColumnAlignments = new ReadOnlyCollection<HorizontalAlignment>(columnAlignments);
rowAlignments = new List<VerticalAlignment>();
RowAlignments = new ReadOnlyCollection<VerticalAlignment>(rowAlignments);
VerticalInlineAlignment = defaultMatrixAlignment;
AlignmentProtocols = new AlignmentProtocolCollection(this);
for (int x = 0; x < columnCount; x++)
this.columnAlignments.Add(defaultColumnAlignment);
for (int y = 0; y < rowCount; y++)
this.rowAlignments.Add(defaultRowAlignment);
}
开发者ID:JeroenBos,项目名称:ASDE,代码行数:27,代码来源:MatrixViewModel.cs
示例7: Style
internal Style(Workbook wb, XfRecord xf) : base(wb)
{
if(xf.FontIdx > 0 && xf.FontIdx < wb.Fonts.Count)
_font = wb.Fonts[xf.FontIdx - 1];
_format = wb.Formats[xf.FormatIdx];
_typeAndProtection = xf.TypeAndProtection;
if(_typeAndProtection.IsCell)
_parentStyle = wb.Styles[xf.ParentIdx];
_horizontalAlignment = xf.HorizontalAlignment;
_wrapped = xf.Wrapped;
_verticalAlignment = xf.VerticalAlignment;
_rotation = xf.Rotation;
_indentLevel = xf.IndentLevel;
_shrinkContent = xf.ShrinkContent;
_parentStyleAttributes = xf.ParentStyle;
_leftLineStyle = xf.LeftLineStyle;
_rightLineStyle = xf.RightLineStyle;
_topLineStyle = xf.TopLineStyle;
_bottomLineStyle = xf.BottomLineStyle;
_leftLineColor = wb.Palette.GetColor(xf.LeftLineColor);
_rightLineColor = wb.Palette.GetColor(xf.RightLineColor);
_diagonalRightTopToLeftBottom = xf.DiagonalRightTopToLeftBottom;
_diagonalLeftBottomToTopRight = xf.DiagonalLeftBottomToTopRight;
_topLineColor = wb.Palette.GetColor(xf.TopLineColor);
_bottomLineColor = wb.Palette.GetColor(xf.BottomLineColor);
_diagonalLineColor = wb.Palette.GetColor(xf.DiagonalLineColor);
_diagonalLineStyle = xf.DiagonalLineStyle;
_fillPattern = xf.FillPattern;
_patternColor = wb.Palette.GetColor(xf.PatternColor);
_patternBackground = wb.Palette.GetColor(xf.PatternBackground);
}
开发者ID:nicknystrom,项目名称:AscendRewards,代码行数:31,代码来源:Style.cs
示例8: RenderText
public void RenderText(IRenderContext context, Vector2 position, string text, FontAsset font,
HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment verticalAlignment = VerticalAlignment.Top, Color? textColor = null, bool renderShadow = true,
Color? shadowColor = null)
{
throw new NotSupportedException();
}
开发者ID:RedpointGames,项目名称:Protogame,代码行数:7,代码来源:Null2DRenderUtilities.cs
示例9: RenderText
public void RenderText(IRenderContext context, IEffect effect, IEffectParameterSet effectParameterSet, Matrix matrix,
string text, FontAsset font, HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment verticalAlignment = VerticalAlignment.Top, Color? textColor = null, bool renderShadow = true,
Color? shadowColor = null)
{
throw new NotSupportedException();
}
开发者ID:RedpointGames,项目名称:Protogame,代码行数:7,代码来源:Null3DRenderUtilities.cs
示例10: GetPositionInLayout
public Vector2 GetPositionInLayout(Rectangle layout, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
{
var x = 0f;
switch (horizontalAlignment)
{
case HorizontalAlignment.Left:
x = layout.X;
break;
case HorizontalAlignment.Center:
x = layout.X + layout.Width / 2;
break;
case HorizontalAlignment.Right:
x = layout.X + layout.Width;
break;
}
var y = 0f;
switch (verticalAlignment)
{
case VerticalAlignment.Top:
y = layout.Y;
break;
case VerticalAlignment.Center:
y = layout.Y + layout.Height / 2;
break;
case VerticalAlignment.Bottom:
y = layout.Y + layout.Height;
break;
}
return new Vector2(x, y);
}
开发者ID:RedpointGames,项目名称:Protogame,代码行数:32,代码来源:DefaultLayoutPosition.cs
示例11: DrawGlyphRun
public static void DrawGlyphRun(this DrawingContext drawingContext, Brush foreground, GlyphRun glyphRun,
Point position, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
{
var boundingBox = glyphRun.ComputeInkBoundingBox();
switch (horizontalAlignment)
{
case HorizontalAlignment.Center:
position.X -= boundingBox.Width / 2d;
break;
case HorizontalAlignment.Right:
position.X -= boundingBox.Width;
break;
default:
break;
}
switch (verticalAlignment)
{
case VerticalAlignment.Center:
position.Y -= boundingBox.Height / 2d;
break;
case VerticalAlignment.Bottom:
position.Y -= boundingBox.Height;
break;
default:
break;
}
drawingContext.PushTransform(new TranslateTransform(position.X - boundingBox.X, position.Y - boundingBox.Y));
drawingContext.DrawGlyphRun(foreground, glyphRun);
drawingContext.Pop();
}
开发者ID:bhanu475,项目名称:XamlMapControl,代码行数:33,代码来源:GlyphRunText.cs
示例12: GetBounds
/// <summary>
/// Calculates the bounds with respect to rotation angle and horizontal/vertical alignment.
/// </summary>
/// <param name="bounds">The size of the object to calculate bounds for.</param>
/// <param name="angle">The rotation angle (degrees).</param>
/// <param name="horizontalAlignment">The horizontal alignment.</param>
/// <param name="verticalAlignment">The vertical alignment.</param>
/// <returns>A minimum bounding rectangle.</returns>
public static OxyRect GetBounds(this OxySize bounds, double angle, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
{
var u = horizontalAlignment == HorizontalAlignment.Left ? 0 : horizontalAlignment == HorizontalAlignment.Center ? 0.5 : 1;
var v = verticalAlignment == VerticalAlignment.Top ? 0 : verticalAlignment == VerticalAlignment.Middle ? 0.5 : 1;
var origin = new ScreenVector(u * bounds.Width, v * bounds.Height);
if (angle == 0)
{
return new OxyRect(-origin.X, -origin.Y, bounds.Width, bounds.Height);
}
// the corners of the rectangle
var p0 = new ScreenVector(0, 0) - origin;
var p1 = new ScreenVector(bounds.Width, 0) - origin;
var p2 = new ScreenVector(bounds.Width, bounds.Height) - origin;
var p3 = new ScreenVector(0, bounds.Height) - origin;
var theta = angle * Math.PI / 180.0;
var costh = Math.Cos(theta);
var sinth = Math.Sin(theta);
Func<ScreenVector, ScreenVector> rotate = p => new ScreenVector((costh * p.X) - (sinth * p.Y), (sinth * p.X) + (costh * p.Y));
var q0 = rotate(p0);
var q1 = rotate(p1);
var q2 = rotate(p2);
var q3 = rotate(p3);
var x = Math.Min(Math.Min(q0.X, q1.X), Math.Min(q2.X, q3.X));
var y = Math.Min(Math.Min(q0.Y, q1.Y), Math.Min(q2.Y, q3.Y));
var w = Math.Max(Math.Max(q0.X - x, q1.X - x), Math.Max(q2.X - x, q3.X - x));
var h = Math.Max(Math.Max(q0.Y - y, q1.Y - y), Math.Max(q2.Y - y, q3.Y - y));
return new OxyRect(x, y, w, h);
}
开发者ID:apmKrauser,项目名称:RCUModulTest,代码行数:43,代码来源:OxySizeExtensions.cs
示例13: DrawMathText
/// <summary>
/// Draws or measures text containing sub- and superscript.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="pt">The point.</param>
/// <param name="text">The text.</param>
/// <param name="textColor">Color of the text.</param>
/// <param name="fontFamily">The font family.</param>
/// <param name="fontSize">The font size.</param>
/// <param name="fontWeight">The font weight.</param>
/// <param name="angle">The angle.</param>
/// <param name="ha">The horizontal alignment.</param>
/// <param name="va">The vertical alignment.</param>
/// <param name="maxsize">The maximum size of the text.</param>
/// <param name="measure">Measure the size of the text if set to <c>true</c>.</param>
/// <returns>The size of the text.</returns>
/// <example>Subscript: H_{2}O
/// Superscript: E=mc^{2}
/// Both: A^{2}_{i,j}</example>
public static OxySize DrawMathText(
this IRenderContext rc,
ScreenPoint pt,
string text,
OxyColor textColor,
string fontFamily,
double fontSize,
double fontWeight,
double angle,
HorizontalAlignment ha,
VerticalAlignment va,
OxySize? maxsize,
bool measure)
{
if (string.IsNullOrEmpty(text))
{
return OxySize.Empty;
}
if (text.Contains("^{") || text.Contains("_{"))
{
double x = pt.X;
double y = pt.Y;
// Measure
var size = InternalDrawMathText(rc, x, y, text, textColor, fontFamily, fontSize, fontWeight, true, angle);
switch (ha)
{
case HorizontalAlignment.Right:
x -= size.Width;
break;
case HorizontalAlignment.Center:
x -= size.Width * 0.5;
break;
}
switch (va)
{
case VerticalAlignment.Bottom:
y -= size.Height;
break;
case VerticalAlignment.Middle:
y -= size.Height * 0.5;
break;
}
InternalDrawMathText(rc, x, y, text, textColor, fontFamily, fontSize, fontWeight, false, angle);
return measure ? size : OxySize.Empty;
}
rc.DrawText(pt, text, textColor, fontFamily, fontSize, fontWeight, angle, ha, va, maxsize);
if (measure)
{
return rc.MeasureText(text, fontFamily, fontSize, fontWeight);
}
return OxySize.Empty;
}
开发者ID:Celderon,项目名称:oxyplot,代码行数:78,代码来源:MathRenderingExtensions.cs
示例14: GridHeaderItem
public GridHeaderItem(HorizontalAlignment hAlign, VerticalAlignment vAlign, Brush foreBrush,
Font font, String text, SortOrder defaultSortOrder, int width, int minwidth, Brush hotbrush)
: base(text, hAlign, vAlign, false, false, foreBrush, font, hotbrush, font)
{
this.defaultSortOrder = defaultSortOrder;
this.width = width;
MinimumWidth = minwidth;
}
开发者ID:huizh,项目名称:xenadmin,代码行数:8,代码来源:GridHeaderItem.cs
示例15: SetAlignment
public void SetAlignment(HorizontalAlignment h, VerticalAlignment v)
{
if (!IsRunning) return;
Log.WriteLine($"Aligning notifications: {h}, {v}");
_overlay.StackNotifications.HorizontalAlignment = h;
_overlay.StackNotifications.VerticalAlignment = v;
}
开发者ID:topher-au,项目名称:WoWmapper,代码行数:8,代码来源:WMOverlay.cs
示例16: ColumnInfo
/// <summary>
/// Initializes a new instance of the <see cref="ColumnInfo"/> struct.
/// </summary>
/// <param name="width">The width of the column in (fixed-width) characters.</param>
/// <param name="content">The content of this column.</param>
/// <param name="alignment">The alignment to use for this column.</param>
/// <param name="verticalAlignment">The vertical alignment to use for this column</param>
/// <param name="method">The word wrapping method to use for this column</param>
public ColumnInfo(int width, string content, Alignment alignment, VerticalAlignment verticalAlignment, WordWrappingMethod method)
{
m_width = width;
m_content = content;
m_alignment = alignment;
m_verticalAlignment = verticalAlignment;
m_workdWrappingMethod = method;
}
开发者ID:logikonline,项目名称:AlphaVSS,代码行数:16,代码来源:StringFormatter.cs
示例17: Create
public Text Create(string fontName, int fontSize, string content, Vector2I size, Color color,
HorizontalAlignment horizontalAligment, VerticalAlignment verticalAlignment, Padding padding)
{
string fontKey = fontName + "-" + size;
if (!_fontDictionary.ContainsKey(fontKey))
_fontDictionary.Add(fontKey, new Font(_context, fontName, fontSize));
return new Text(_context, content, _fontDictionary[fontKey], size, color, horizontalAligment, verticalAlignment, padding);
}
开发者ID:ndech,项目名称:Alpha,代码行数:8,代码来源:TextManager.cs
示例18: AddTextBlockExternal
internal static void AddTextBlockExternal(int col, int row, string text, Grid grid, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment)
{
var textBlock = new TextBlock();
AddTextBlockAux(col, row, text, textBlock, horizontalAlignment, verticalAlignment);
grid.Children.Add(textBlock);
}
开发者ID:idan573,项目名称:projectArduinoFirstTry,代码行数:8,代码来源:RowAdder.cs
示例19: HierarchyLayout
public HierarchyLayout() :
base()
{
this.LayoutStyle = LayoutStyle.Hierarchy;
this.ConnectorStyle = ConnectorStyle.OrganizationChart;
this.HorizontalAlignment = HorizontalAlignment.Center;
this.VerticalAlignment = VerticalAlignment.Middle;
}
开发者ID:shekharssorot2002,项目名称:VisioAutomation2.0,代码行数:8,代码来源:HierarchyLayout.cs
示例20: ColumnInfo
/// <summary>
/// Initializes a new instance of the <see cref="ColumnInfo"/> struct.
/// </summary>
/// <param name="width">The width of the column in (fixed-width) characters.</param>
/// <param name="content">The content of this column.</param>
/// <param name="alignment">The alignment to use for this column.</param>
/// <param name="verticalAlignment">The vertical alignment to use for this column</param>
/// <param name="method">The word wrapping method to use for this column</param>
public ColumnInfo(int width, string content, Alignment alignment, VerticalAlignment verticalAlignment, WordWrappingMethod method)
{
mWidth = width;
mContent = content;
mAlignment = alignment;
mVerticalAlignment = verticalAlignment;
mWordWrappingMethod = method;
}
开发者ID:Arakis,项目名称:TamaniChess,代码行数:16,代码来源:ColumnInfo.cs
注:本文中的VerticalAlignment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论