• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# HorizontalAlignment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中HorizontalAlignment的典型用法代码示例。如果您正苦于以下问题:C# HorizontalAlignment类的具体用法?C# HorizontalAlignment怎么用?C# HorizontalAlignment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HorizontalAlignment类属于命名空间,在下文中一共展示了HorizontalAlignment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: 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


示例2: DrawText

 private static void DrawText(FixedContentEditor editor, string text, double width = double.PositiveInfinity, HorizontalAlignment alignment = HorizontalAlignment.Left)
 {
     Block block = CreateBlock(editor);
     block.HorizontalAlignment = alignment;
     block.InsertText(text);
     editor.DrawBlock(block, new Size(width, double.PositiveInfinity));
 }
开发者ID:netintellect,项目名称:PluralsightSpaJumpStartFinal,代码行数:7,代码来源:ExampleViewModel.cs


示例3: LabelAndImage

        public LabelAndImage(ImageSource ImageSource, string LabelContent,
            HorizontalAlignment ControlHorizontalAlignment = HorizontalAlignment.Left,
            double PanelHeight = 0, double PanelWidth = 0, double LabelFont = 0)
        {
            InitializeComponent();

            this.ImageSource = ImageSource;
            this.LabelContent = LabelContent;
            this.ControlHorizontalAlignment = ControlHorizontalAlignment;

            if (PanelHeight == 0)
            {
                this.PanelHeight = (double)Application.Current.Resources["SmallButtonHeight"];
            }
            else
            {
                this.PanelHeight = PanelHeight;
            }
            if (PanelWidth == 0)
            {
                this.PanelWidth = (double)Application.Current.Resources["SmallButtonWidth"];
            }
            else
            {
                this.PanelWidth = PanelWidth;
            }
            if (LabelFont == 0)
            {
                this.LabelFont = (double)Application.Current.Resources["SmallButtonFont"];
            }
            else
            {
                this.LabelFont = LabelFont;
            }
        }
开发者ID:drrobson,项目名称:Group42_FYDP,代码行数:35,代码来源:LabelAndImage.xaml.cs


示例4: 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


示例5: 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


示例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: 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


示例8: 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


示例9: CustomButton

                public CustomButton(string content, double width, double height, System.Windows.Thickness margin, System.Windows.Thickness padding, HorizontalAlignment hAlign)
                {
                        _block = new TextBlock();
                        _block.Text = content;

                        this.Width = width;
                        this.Height = height;
                        this.Margin = margin;
                        this.Background = ThemeSelector.GetButtonColor();
                        
                        
                        this.HorizontalAlignment = hAlign;

                        _block.Padding = padding;
                        _block.FontSize = Responsive.GetButtonTextSize();
                        _block.FontFamily = FontProvider._lato;
                        _block.Foreground = ThemeSelector.GetButtonContentColor();
                        _block.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;


                        this.Children.Add(_block);

                        this.MouseLeave += CustomButton_MouseLeave;
                        this.MouseEnter += CustomButton_MouseEnter;
                    

                        //this.SetColor();
                }
开发者ID:RemyKaloustian,项目名称:Epic-Projects,代码行数:28,代码来源:CustomButton.cs


示例10: 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


示例11: ODGridColumn

		///<summary>Creates a new ODGridcolumn with the given heading and width. Alignment left</summary>
		public ODGridColumn(string heading,int colWidth){
			this.heading=heading;
			this.colWidth=colWidth;
			this.textAlign=HorizontalAlignment.Left;
			imageList=null;
			sortingStrategy=GridSortingStrategy.StringCompare;
		}
开发者ID:romeroyonatan,项目名称:opendental,代码行数:8,代码来源:ODGridColumn.cs


示例12: 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


示例13: StyleInfo

		public StyleInfo(Color BackColor, Color ForeColor, Font Font, HorizontalAlignment Alignment)
		{
			this.BackColor2 = this.BackColor = BackColor;
			this.ForeColor2 = this.ForeColor = ForeColor;
			this.Font = Font;
			this.Algnment = Alignment;
		}
开发者ID:rsdn,项目名称:janus,代码行数:7,代码来源:StyleInfo.cs


示例14: AppendAlign

 public static void AppendAlign(StringBuilder style, HorizontalAlignment alignment)
 {
     switch (alignment)
     {
         case HorizontalAlignment.Center:
             style.Append("text-align: center; ");
             break;
         case HorizontalAlignment.CenterSelection:
             style.Append("text-align: center; ");
             break;
         case HorizontalAlignment.Fill:
             // XXX: shall we support fill?
             break;
         case HorizontalAlignment.General:
             break;
         case HorizontalAlignment.Justify:
             style.Append("text-align: justify; ");
             break;
         case HorizontalAlignment.Left:
             style.Append("text-align: left; ");
             break;
         case HorizontalAlignment.Right:
             style.Append("text-align: right; ");
             break;
     }
 }
开发者ID:89sos98,项目名称:npoi,代码行数:26,代码来源:ExcelToHtmlUtils.cs


示例15: TableCell

 public TableCell(string text, XFont font, int columnSpan, HorizontalAlignment alignment)
 {
     Text = text;
       Font = font;
       Alignment = alignment;
       ColumnSpan = columnSpan;
 }
开发者ID:dbrgn,项目名称:pi-vote,代码行数:7,代码来源:TableCell.cs


示例16: 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


示例17: CustomGrid_Style

        /// <summary> Constructor for a new instance of the CustomGrid_Style class </summary>
        /// <param name="Data_Source"> DataTable for which to atuomatically build the style for </param>
        public CustomGrid_Style( DataTable Data_Source )
        {
            // Declare collection of columns
            columns = new List<CustomGrid_ColumnStyle>();
            visibleColumns = new CustomGrid_VisibleColumns( columns );

            // Set some defaults
            default_columnWidth = 100;
            headerHeight = 23;
            rowHeight = 20;
            default_textAlignment = HorizontalAlignment.Center;
            default_backColor = System.Drawing.Color.White;
            default_foreColor = System.Drawing.Color.Black;
            alternating_print_backColor = System.Drawing.Color.Honeydew;
            gridLineColor = System.Drawing.Color.Black;
            headerForeColor = System.Drawing.SystemColors.WindowText;
            headerBackColor = System.Drawing.SystemColors.Control;
            rowSelectForeColor = System.Drawing.SystemColors.WindowText;
            rowSelectBackColor = System.Drawing.SystemColors.Control;
            noMatchesTextColor = System.Drawing.Color.MediumBlue;
            selectedColor = System.Drawing.Color.Yellow;
            sortable = true;
            column_resizable = true;
            primaryKey = -1;
            double_click_delay = 1000;

            // Set this data source
            this.Data_Source = Data_Source;
        }
开发者ID:randomyed,项目名称:SobekCM-Web-Application,代码行数:31,代码来源:CustomGrid_Style.cs


示例18: 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


示例19: AppendAlign

 public static void AppendAlign(StringBuilder style, HorizontalAlignment alignment)
 {
     switch (alignment)
     {
         case HorizontalAlignment.CENTER:
             style.Append("text-align: center; ");
             break;
         case HorizontalAlignment.CENTER_SELECTION:
             style.Append("text-align: center; ");
             break;
         case HorizontalAlignment.FILL:
             // XXX: shall we support fill?
             break;
         case HorizontalAlignment.GENERAL:
             break;
         case HorizontalAlignment.JUSTIFY:
             style.Append("text-align: justify; ");
             break;
         case HorizontalAlignment.LEFT:
             style.Append("text-align: left; ");
             break;
         case HorizontalAlignment.RIGHT:
             style.Append("text-align: right; ");
             break;
     }
 }
开发者ID:ctddjyds,项目名称:npoi,代码行数:26,代码来源:ExcelToHtmlUtils.cs


示例20: 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



注:本文中的HorizontalAlignment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Host类代码示例发布时间:2022-05-24
下一篇:
C# HookType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap