当前位置: 首页>>代码示例>>C#>>正文


C# Alignment类代码示例

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


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

示例1: Table

 /// <summary>
 /// Construct a new <see cref="Table" />.
 /// </summary>
 /// <param name="tableName">
 /// The name of the <see cref="Table" />.
 /// </param>
 /// <param name="headerAlignment">
 /// The method to use to align the text in the table's header.
 /// Defaults to <see cref="StringFormatting.LeftJustified" />.
 /// </param>
 public Table(string tableName=null, Alignment headerAlignment=null)
 {
     Title = tableName ?? string.Empty;
     HeaderAlignment = headerAlignment ?? StringFormatting.LeftJustified;
     Columns = new ColumnCollection();
     Rows = new RowCollection(this);
 }
开发者ID:karldickman,项目名称:Utilities,代码行数:17,代码来源:Table.cs

示例2: Center

        public void Center(Rectangle theDisplayArea, Alignment theAlignment)
        {
            Vector2 theTextSize = mFont.MeasureString(mText);

            switch (theAlignment)
            {
                case Alignment.Horizonatal:
                    {
                        Position.X = theDisplayArea.X + (theDisplayArea.Width / 2 - theTextSize.X / 2);
                        break;
                    }

                case Alignment.Vertical:
                    {
                        Position.Y = theDisplayArea.Y + (theDisplayArea.Height / 2 - theTextSize.Y / 2);
                        break;
                    }

                case Alignment.Both:
                    {
                        Position.X = theDisplayArea.X + (theDisplayArea.Width / 2 - theTextSize.X / 2);
                        Position.Y = theDisplayArea.Y + (theDisplayArea.Height / 2 - theTextSize.Y / 2);
                        break;
                    }
            }
        }
开发者ID:Gevil,项目名称:Projects,代码行数:26,代码来源:Text.cs

示例3: AlignmentState

 public AlignmentState (Alignment alignment, float padding, uint[] numberOfItems)
     : this()
 {
     Alignment = alignment;
     Padding = padding;
     NumberOfItemsPer = numberOfItems;
 }
开发者ID:KevinHeyer,项目名称:CocosSharp,代码行数:7,代码来源:CCMenu.cs

示例4: ItemSelector

        //------------------------------------------------------------------------------
        // Function: ItemSelector
        // Author: nholmes
        // Summary: item constructor, allows user to specify the width of the button,
        //          the options that can be selected from, the vertical position, the
        //          alignment and the font
        //------------------------------------------------------------------------------
        public ItemSelector(Menu menu, Game game, string[] optionsText, int selectedOption, int y, int width, Alignment alignment, SpriteFont font, Color fontColor, int textOffset)
            : base(menu, game, textOffset)
        {
            // store the width of the button, options text, selected option and the font to use
            this.width = width;
            this.optionsText = optionsText;
            this.selectedOption = selectedOption;
            this.font = font;
            this.fontColor = fontColor;

            // set the vy position of this button item
            position.Y = y;

            // calculate position based on alignment provided
            switch (alignment)
            {
                case Alignment.left:
                    position.X = 0;
                    break;
                case Alignment.centre:
                    position.X = (menu.ItemArea.Width / 2) - (width / 2);
                    break;
                case Alignment.right:
                    position.X = width - (int)font.MeasureString(optionsText[selectedOption]).X;
                    break;
                default:
                    position.X = 0;
                    break;
            }

            // store the size of this button item
            size.X = width;
            size.Y = menu.ButtonTexture.Height;
        }
开发者ID:GunioRobot,项目名称:IndieCity-XBLIG-to-PC-XNA-helper-library,代码行数:41,代码来源:ItemSelector.cs

示例5: AlignmentButton

        public AlignmentButton()
        {
            InitializeComponent();

            m_alignment = Alignment.Centre;
            m_image = Resources.DefaultButtonImage;
        }
开发者ID:dekk7,项目名称:xEngine,代码行数:7,代码来源:AlignmentButton.cs

示例6: ItemSlider

        //------------------------------------------------------------------------------
        // Function: ItemSlider
        // Author: nholmes
        // Summary: item constructor, allows user to specify the width of the slider,
        //          the values that can be selected between, the vertical position, the
        //          alignment and the font
        //------------------------------------------------------------------------------
        public ItemSlider(Menu menu, Game game, int minValue, int maxValue, int initialValue, int y, int width, Alignment alignment, SpriteFont font, Color fontColor, int textOffset)
            : base(menu, game, textOffset)
        {
            // store the width of the button, options text, selected option and the font to use
            this.width = width;
            this.minValue = minValue;
            this.maxValue = maxValue;
            this.currentValue = initialValue;
            this.font = font;
            this.fontColor = fontColor;

            // set the vy position of this button item
            position.Y = y;

            // calculate position based on alignment provided
            switch (alignment)
            {
                case Alignment.left:
                    position.X = 0;
                    break;
                case Alignment.centre:
                    position.X = (menu.ItemArea.Width / 2) - (width / 2);
                    break;
                case Alignment.right:
                    position.X = width;
                    break;
                default:
                    position.X = 0;
                    break;
            }

            // store the size of this button item
            size.X = width;
            size.Y = menu.ButtonTexture.Height;
        }
开发者ID:GunioRobot,项目名称:IndieCity-XBLIG-to-PC-XNA-helper-library,代码行数:42,代码来源:ItemSlider.cs

示例7: AddComponent

 public void AddComponent(MSGUIUnclickable component, Alignment alignment)
 {
     switch (alignment)
     {
         case Alignment.TOP_LEFT:
             component.Position = boundedPosition;
             break;
         case Alignment.TOP_CENTER:
             component.Position = boundedPosition + new Vector2((boundedSize.X - component.Size.X) / 2, 0);
             break;
         case Alignment.TOP_RIGHT:
             component.Position = boundedPosition + new Vector2(boundedSize.X - component.Size.X, 0);
             break;
         case Alignment.MIDDLE_LEFT:
             component.Position = boundedPosition + new Vector2(0, (boundedSize.Y - component.Size.Y) / 2);
             break;
         case Alignment.MIDDLE_CENTER:
             component.Position = boundedPosition + (boundedSize - component.Size) / 2;
             break;
         case Alignment.MIDDLE_RIGHT:
             component.Position = boundedPosition + new Vector2(boundedSize.X - component.Size.X, (boundedSize.Y - component.Size.Y) / 2);
             break;
         case Alignment.BOTTOM_LEFT:
             component.Position = boundedPosition + new Vector2(0, boundedSize.Y - component.Size.Y);
             break;
         case Alignment.BOTTOM_CENTER:
             component.Position = boundedPosition + new Vector2((boundedSize.X - component.Size.X) / 2, boundedSize.Y - component.Size.Y);
             break;
         case Alignment.BOTTOM_RIGHT:
             component.Position = boundedPosition + new Vector2(boundedSize.X - component.Size.X, boundedSize.Y - component.Size.Y);
             break;
     }
     components.Add(component);
 }
开发者ID:verngutz,项目名称:MoodSwing,代码行数:34,代码来源:MSToolTip.cs

示例8: AlignmentCriterion

 public AlignmentCriterion(XmlJointType centerJoint, XmlJointType[] joints, float variance)
     : base(variance)
 {
     this.Alignment = Alignment.Point;
     this.CenterJoint = centerJoint;
     this.Joints = joints;
 }
开发者ID:slowbump,项目名称:KinectTherapyTest,代码行数:7,代码来源:AlignmentCriterion.cs

示例9: alignText

    static IEnumerable<string> alignText(IEnumerable<string> lines, Alignment alignment, int width)
    {
        switch (alignment)
        {
            case Alignment.LEFT:
                return lines;

            case Alignment.RIGHT:
                return lines.Select(t => new String(' ', width - t.Length) + t);

            case Alignment.CENTER:
                return lines.Select(t => new String(' ', (width - t.Length) / 2) + t);

            case Alignment.JUSTIFY:
                return lines.Select(t =>
                {
                    var words = t.Split();
                    var spaceRequired = width - t.Length;
                    var spacing = spaceRequired / (words.Length - 1) + 1;
                    return string.Join(new String(' ', spacing), words);
                });

            default:
                throw new NotImplementedException();
        }
    }
开发者ID:aquamoth,项目名称:CodeinGame,代码行数:26,代码来源:Program.cs

示例10: FindOffset

        /// <summary>
        /// Finds the <see cref="Vector2"/> that represents the position to align an object
        /// to another object based on the given <see cref="Alignment"/>. The object being aligned
        /// to is assumed to be at {0,0).
        /// </summary>
        /// <param name="alignment">The <see cref="Alignment"/> describing how to align the target
        /// to the source.</param>
        /// <param name="sourceSize">The object that is being aligned to the target.</param>
        /// <param name="targetSize">The size of the object being aligned to.</param>
        /// <returns>The <see cref="Vector2"/> that represents the position to align an object
        /// to another object based on the given <paramref name="alignment"/>.</returns>
        /// <exception cref="ArgumentException"><paramref name="alignment"/> is not a defined value of the <see cref="Alignment"/>
        /// enum.</exception>
        public static Vector2 FindOffset(Alignment alignment, Vector2 sourceSize, Vector2 targetSize)
        {
            switch (alignment)
            {
                case Alignment.TopLeft:
                    return new Vector2(0, 0);

                case Alignment.TopRight:
                    return new Vector2(targetSize.X - sourceSize.X, 0);

                case Alignment.BottomLeft:
                    return new Vector2(0, targetSize.Y - sourceSize.Y);

                case Alignment.BottomRight:
                    return targetSize - sourceSize;

                case Alignment.Top:
                    return new Vector2(targetSize.X / 2f - sourceSize.X / 2f, 0);

                case Alignment.Bottom:
                    return new Vector2(targetSize.X / 2f - sourceSize.X / 2f, targetSize.Y - sourceSize.Y);

                case Alignment.Left:
                    return new Vector2(0, targetSize.Y / 2f - sourceSize.Y / 2f);

                case Alignment.Right:
                    return new Vector2(targetSize.X - sourceSize.X, targetSize.Y / 2f - sourceSize.Y / 2f);

                case Alignment.Center:
                    return targetSize / 2f - sourceSize / 2f;

                default:
                    throw new ArgumentException("Unknown alignment value specified", "alignment");
            }
        }
开发者ID:mateuscezar,项目名称:netgore,代码行数:48,代码来源:AlignmentHelper.cs

示例11: Draw

        public static void Draw(SpriteBatch spriteBatch,int number, Alignment aligment ,Rectangle rect, int scale = 1)
        {
            var numbers = number.ToString ().ToCharArray ().Select (n => n.ToString ());
            var images = numbers.Select (n => textures [n]).ToList ();
            var width = images.Sum (n => n.Width* scale) + ((images.Count - 1) * padding*scale);

            int x = rect.Left;
            if (aligment == Alignment.Right)
                x = rect.Right - width;
            else if (aligment == Alignment.Center)
                x = (rect.Right / 2) - (width / 2);
            int y = rect.Top;
            var drawRect = new Rectangle (x, y, 0, 0);

            images.ForEach (i => {
                drawRect.X =x;
                drawRect.Width = i.Width*scale;
                drawRect.Height = i.Height*scale;
                spriteBatch.Draw (
                    i,
                    null,
                    drawRect,
                    null,
                    null,
                    0,
                    new Vector2(scale),
                    Color.White,
                    SpriteEffects.None,
                    0.0f);

                spriteBatch.Draw(i,drawRect,Color.White);
                x += i.Width * scale + padding*scale;
            });
        }
开发者ID:hungnm92,项目名称:FlappyMonkey,代码行数:34,代码来源:Number.cs

示例12: ApplyTextPositionAndAlignment

 public void ApplyTextPositionAndAlignment(Position pos, Alignment alignment)
 {
     new TextBoxes(Shapes.Range(), SlideWidth, SlideHeight)
         .SetPosition(pos)
         .SetAlignment(alignment)
         .StartBoxing();
 }
开发者ID:nus-fboa2016-PL,项目名称:PowerPointLabs,代码行数:7,代码来源:EffectsDesigner.Text.cs

示例13: TabWidgetModel

 public TabWidgetModel(String id, Alignment alignment, String href)
 {
     this.Id = "tab" + id;
     this.Alignment = alignment;
     this.TabImage = "~/Content/img/tabs/" + id + ".png";
     this.Href = href;
 }
开发者ID:supperslonic,项目名称:SupperSlonicWebSite,代码行数:7,代码来源:TabWidgetModel.cs

示例14: ItemText

        //------------------------------------------------------------------------------
        // Function: ItemText
        // Author: nholmes
        // Summary: item constructor, allows user to specify text, vertical position,
        //          alignment and font as well as whether the text is selectable
        //------------------------------------------------------------------------------
        public ItemText(Menu menu, Game game, string text, int y, Alignment alignment, SpriteFont font, Color fontColor, int textOffset, bool selectable)
            : base(menu, game, textOffset)
        {
            // store the text font and font color to use
            this.text = text;
            this.font = font;
            this.fontColor = fontColor;

            // store whether this item is selectable
            this.selectable = selectable;

            // set the vy position of this text item
            position.Y = y;

            // calculate position based on alignment provided
            switch (alignment)
            {
                case Alignment.left:
                    position.X = 0;
                    break;
                case Alignment.centre:
                    position.X = (int)((menu.ItemArea.Width - font.MeasureString(text).X) / 2);
                    break;
                case Alignment.right:
                    position.X = (int)(menu.ItemArea.Width - font.MeasureString(text).X);
                    break;
                default:
                    position.X = 0;
                    break;
            }

            // store the size of this text item
            size = font.MeasureString(text);
        }
开发者ID:GunioRobot,项目名称:IndieCity-XBLIG-to-PC-XNA-helper-library,代码行数:40,代码来源:ItemText.cs

示例15: OnButtonClicked

    protected void OnButtonClicked(object sender, EventArgs e)
    {
        if (sender == button1)
        {

            Gtk.FileChooserDialog dialog = new Gtk.FileChooserDialog ("Choose item...", this, FileChooserAction.Open, "Cancel",  ResponseType.Cancel, "Insert Spacer",  ResponseType.None, "Add", ResponseType.Accept);

            Gtk.Alignment align = new Alignment (1, 0, 0, 1);
            Gtk.Frame frame = new Frame ("Position");
            Gtk.HBox hbox = new HBox (false, 4);

            RadioButton rbRight;
            rbRight = new RadioButton ("Right");
            hbox.PackEnd(rbRight, false, false, 1);
            hbox.PackEnd(new RadioButton (rbRight, "Left"), false, false, 1);

            frame.Add (hbox);
            align.Add (frame);
            align.ShowAll ();
            dialog.ExtraWidget = align;

            ResponseType response = (ResponseType)dialog.Run ();
            if (response == ResponseType.Accept) {
                RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>" + dialog.Filename + "</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>' && /bin/sleep 1 &&/usr/bin/killall Dock");
            } else if (response == ResponseType.None) {
                RunCommand ("defaults write com.apple.dock " + GetAlign(dialog.ExtraWidget) + " -array-add '{tile-data={}; tile-type=\"spacer-tile\";}' && /bin/sleep 1 &&/usr/bin/killall Dock");
            }
            dialog.Destroy ();

        }
    }
开发者ID:Eun,项目名称:AddAnyDock,代码行数:31,代码来源:MainWindow.cs


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