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


C# Anchor类代码示例

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


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

示例1: MultiOptionSelector

        public MultiOptionSelector(AssetManager assets, string themeName, Vector2 position, Anchor anchor, List<Option> options, MultiOptionArrangement arrangement, Cursor cursor, int initialValue)
            : base(themeName, position, initialValue)
        {
            //process arrangement
            if (arrangement == MultiOptionArrangement.ListX)
                arrangement = new MultiOptionArrangement(options.Count, 1);
            if (arrangement == MultiOptionArrangement.ListY)
                arrangement = new MultiOptionArrangement(1, options.Count);
            this.arrangement = arrangement;

            TextDictionary assetDictionary = new TextDictionary(assets.GetText("selector"));
            //load themes
            string cursorTheme = assetDictionary.LookupString(themeName, "cursorTheme");
            string optionTheme = assetDictionary.LookupString(themeName, "optionTheme");
            Anchor justify = Anchor.Center;
            bool justifySuccess = assetDictionary.CheckPropertyExists(themeName, "justify");
            if (justifySuccess)
            {
                string justifyString = assetDictionary.LookupString(themeName, "justify");
                if (justifyString == "Left")
                    justify = Anchor.CenterLeft;
                else if (justifyString == "Right")
                    justify = Anchor.CenterRight;
            }
            //position components
            cursor.Initialize(options, assets, cursorTheme);
            Vector2 individualSize = Vector2.Zero;
            for (int i = 0; i < options.Count; i++)
            {
                options[i].Initialize(assets, optionTheme);
                if (options[i].Dimensions.X > individualSize.X)
                    individualSize.X = options[i].Dimensions.X;
                if (options[i].Dimensions.Y > individualSize.Y)
                    individualSize.Y = options[i].Dimensions.Y;
            }
            for (int i = 0; i < options.Count; i++)
                options[i].Position = (individualSize + cursor.Spacing * Vector2.One) * arrangement.GetPosition(i);
            Vector2 overallSize = new Vector2(arrangement.Columns * (individualSize.X + cursor.Spacing) - cursor.Spacing, arrangement.Rows * (individualSize.Y + cursor.Spacing) - cursor.Spacing);
            for (int i = 0; i < options.Count; i++)
            {
                Vector2 p = options[i].Position;
                if (justify == Anchor.TopCenter || justify == Anchor.Center || justify == Anchor.BottomCenter)
                    p.X += (individualSize.X - options[i].Dimensions.X) / 2;
                else if (justify == Anchor.TopRight || justify == Anchor.CenterRight || justify == Anchor.BottomRight)
                    p.X += individualSize.X - options[i].Dimensions.X;
                if (justify == Anchor.CenterLeft || justify == Anchor.Center || justify == Anchor.CenterRight)
                    p.Y += (individualSize.Y - options[i].Dimensions.Y) / 2;
                else if (justify == Anchor.BottomLeft || justify == Anchor.BottomCenter || justify == Anchor.BottomRight)
                    p.Y += individualSize.Y - options[i].Dimensions.Y;
                options[i].Position = p;
            }
            this.Position -= GraphicsHelper.ComputeAnchorOrigin(anchor, overallSize / GraphicsConstants.VIEWPORT_DIMENSIONS);
            this.options = options;
            this.cursor = cursor;
            //initialize position
            Vector2 initialPosition = arrangement.GetPosition(IntValue);
            x = (int)initialPosition.X;
            y = (int)initialPosition.Y;
            cursor.Update(IntValue);
        }
开发者ID:kjin,项目名称:TubeRacer,代码行数:60,代码来源:MultiOptionSelector.cs

示例2: AnimatedSprite

        public AnimatedSprite(Animation animation, Vector2 position, Anchor anchor)
        {
            this.animation = animation;
            int width = animation.FrameWidth;
            int height = animation.FrameHeight;

            switch (anchor)
            {
                case Anchor.TOPLEFT:
                    this.mCenter.X = position.X + width / 2;
                    this.mCenter.Y = position.Y + height / 2;
                    break;
                case Anchor.TOPRIGHT:
                    this.mCenter.X = position.X - width / 2;
                    this.mCenter.Y = position.Y + height / 2;
                    break;
                case Anchor.CENTER:
                    this.mCenter = position;
                    break;
                case Anchor.BOTTOMLEFT:
                    this.mCenter.X = position.X + width / 2;
                    this.mCenter.Y = position.Y - height / 2;
                    break;
                case Anchor.BOTTOMRIGHT:
                    this.mCenter.X = position.X - width / 2;
                    this.mCenter.Y = position.Y - height / 2;
                    break;
            }
        }
开发者ID:nguyendinhnien,项目名称:AmazingCup2013-Game-UET,代码行数:29,代码来源:AnimatedSprite.cs

示例3: GetScreenPointFromAnchor

	// ************************************************************************
	public static Vector2 GetScreenPointFromAnchor(Anchor anchor)
	{
		switch (anchor)
		{

		case Anchor.TOP_LEFT :
			return new Vector2 ( 0.0f,				Screen.height );
		case Anchor.TOP :
			return new Vector2 ( Screen.width / 2,	Screen.height );
		case Anchor.TOP_RIGHT :
			return new Vector2 ( Screen.width,		Screen.height );

		case Anchor.LEFT :
			return new Vector2 ( 0.0f,				Screen.height / 2 );
		case Anchor.CENTER :
			return new Vector2 ( Screen.width / 2,	Screen.height / 2 );
		case Anchor.RIGHT :
			return new Vector2 ( Screen.width,		Screen.height / 2 );

		case Anchor.BOTTOM_LEFT :
			return new Vector2 ( 0.0f,				0 );
		case Anchor.BOTTOM :
			return new Vector2 ( Screen.width / 2,	0 );
		case Anchor.BOTTOM_RIGHT :
			return new Vector2 ( Screen.width,		0 );

		default :

			return Vector2.zero;
		}
	}
开发者ID:Jiyambi,项目名称:Global-Game-Jam-2016,代码行数:32,代码来源:ScreenHelper.cs

示例4: Button

        //----------------------------------------------------------------------
        public Button( Screen _screen, ButtonStyle _style, string _strText = "", Texture2D _iconTex = null, Anchor _anchor = Anchor.Center, string _strTooltipText="", object _tag=null )
            : base(_screen)
        {
            Style = _style;

            mPadding    = new Box(5, 0);
            mMargin     = new Box(0);

            mLabel          = new Label( _screen );

            mIcon           = new Image( _screen );
            mIcon.Texture   = _iconTex;
            mIcon.Padding   = new Box( Style.VerticalPadding, 0, Style.VerticalPadding, Style.HorizontalPadding );

            Text            = _strText;
            TextColor       = Screen.Style.DefaultTextColor;

            Anchor          = _anchor;

            mPressedAnim    = new SmoothValue( 1f, 0f, 0.2f );
            mPressedAnim.SetTime( mPressedAnim.Duration );

            mTooltip        = new Tooltip( Screen, "" );

            TooltipText     = _strTooltipText;
            Tag             = _tag;

            UpdateContentSize();
        }
开发者ID:ViGor-Thinktank,项目名称:GCML,代码行数:30,代码来源:Button.cs

示例5: Sprite

 public Sprite(Texture2D texture, Vector2 position, Anchor anchor)
 {
     this.mTexture = texture;
     switch (anchor)
     {
         case Anchor.TOPLEFT:
             this.mCenter.X = position.X + texture.Width / 2;
             this.mCenter.Y = position.Y + texture.Height / 2;
             break;
         case Anchor.TOPRIGHT:
             this.mCenter.X = position.X - texture.Width / 2;
             this.mCenter.Y = position.Y + texture.Height / 2;
             break;
         case Anchor.CENTER:
             this.mCenter = position;
             break;
         case Anchor.BOTTOMLEFT:
             this.mCenter.X = position.X + texture.Width / 2;
             this.mCenter.Y = position.Y - texture.Height / 2;
             break;
         case Anchor.BOTTOMRIGHT:
             this.mCenter.X = position.X - texture.Width / 2;
             this.mCenter.Y = position.Y - texture.Height / 2;
             break;
     }
     this.mPosition.X = mCenter.X - mTexture.Width / 2;
     this.mPosition.Y = mCenter.Y - mTexture.Height / 2;
 }
开发者ID:nguyendinhnien,项目名称:AmazingCup2013-Game-UET,代码行数:28,代码来源:Sprite.cs

示例6: Widget

        /// <summary>
        /// Creates a new widget with desired background texture.
        /// </summary>
        public Widget(SpriteBatch spriteBatch, String background, int offsetX, int parentX, int offsetY, int parentY, Anchor anchor)
            : this(spriteBatch)
        {
            this.background = AssetManager.GetInstance().getAsset<Texture2D>(background);

            BuildBody(this.background.Width, this.background.Height, offsetX, parentX, offsetY, parentY, anchor);
        }
开发者ID:jmaley,项目名称:colonies,代码行数:10,代码来源:Widget.cs

示例7: AddAnchorName

 /// <summary>
 /// 添加链接点
 /// </summary>
 /// <param name="Content">链接文字</param>
 /// <param name="FontSize">字体大小</param>
 /// <param name="Name">链接点名</param>
 public void AddAnchorName(string Content, float FontSize, string Name)
 {
     SetFont(FontSize);
     Anchor auc = new Anchor(Content, font);
     auc.Name = Name;
     document.Add(auc);
 }
开发者ID:kcly3027,项目名称:knowledge,代码行数:13,代码来源:PDFOperation.cs

示例8: MakeButtonAt

 protected void MakeButtonAt( string text, int width, int height, Font font, Anchor horAnchor,
     Anchor verAnchor, int x, int y)
 {
     WidgetConstructors.MakeButtonAt( game, widgets, ref widgetIndex,
                                     text, width, height, font, horAnchor,
                                     verAnchor, x, y, null );
 }
开发者ID:Retatta,项目名称:ClassicalSharp,代码行数:7,代码来源:IView.cs

示例9: ModelDisplayWidget

        public ModelDisplayWidget(SpriteBatch spriteBatch, string bg, int p_3, int p_4, int p_5, int p_6, Anchor anchor_2)
            : base(spriteBatch, bg, p_3, p_4, p_5, p_6, anchor_2)
        {
            camera = new Camera();

            BoundingSphere sphere = new BoundingSphere();
            float scale;
            /*Debug.WriteLine("Hey" + (
                (body.Left - (SettingsManager.GetInstance().ResolutionX/2.0f))
                / SettingsManager.GetInstance().ResolutionX));*/
            //translationAndScale = Matrix.Multiply(Matrix.CreateTranslation(translation), Matrix.CreateScale(new Vector3(0.5f,0.5f,0.5f)));

            //BoundingSphere will give us the size of the model, so we can scale accordingly
            foreach (ModelMesh mesh in myModel.Meshes)
            {
                if (sphere.Radius == 0)
                    sphere = mesh.BoundingSphere;
                else
                    sphere = BoundingSphere.
                             CreateMerged(sphere, mesh.BoundingSphere);
            }
            Debug.WriteLine(sphere.Radius);
            scale = 2.0f / sphere.Radius;
            translationAndScale = Matrix.Multiply(Matrix.CreateTranslation(translation), Matrix.CreateScale(new Vector3(scale, scale, scale)));
        }
开发者ID:jmaley,项目名称:colonies,代码行数:25,代码来源:ModelDisplayWidget.cs

示例10: MakeBooleanAt

 protected void MakeBooleanAt( Anchor horAnchor, Anchor verAnchor, Font font, bool initValue,
     int width, int height, int x, int y)
 {
     WidgetConstructors.MakeBooleanAt( game, widgets, ref widgetIndex,
                                      horAnchor, verAnchor, font, initValue,
                                      width, height, x, y, null );
 }
开发者ID:Retatta,项目名称:ClassicalSharp,代码行数:7,代码来源:IView.cs

示例11: ToAbsolute

 public static Point ToAbsolute(Anchor anchor, Point point, Rectangle rect)
 {
     switch (anchor)
     {
         case Anchor.TopLeft:
             point.Offset(rect.Left, rect.Top);
             break;
         case Anchor.TopCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Top);
             break;
         case Anchor.TopRight:
             point.Offset(rect.Right, rect.Top);
             break;
         case Anchor.MiddleLeft:
             point.Offset(rect.Left, rect.Top + (rect.Height / 2));
             break;
         case Anchor.MiddleCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2));
             break;
         case Anchor.MiddleRight:
             point.Offset(rect.Right, rect.Top + (rect.Height / 2));
             break;
         case Anchor.BottomLeft:
             point.Offset(rect.Left, rect.Bottom);
             break;
         case Anchor.BottomCenter:
             point.Offset(rect.Left + (rect.Width / 2), rect.Bottom);
             break;
         case Anchor.BottomRight:
             point.Offset(rect.Right, rect.Bottom);
             break;
     }
     return point;
 }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:34,代码来源:RelativePoint.cs

示例12: Make

 ButtonWidget Make( int x, int y, string text, Anchor vDocking, Action<Game, ButtonWidget> onClick,
     Func<Game, string> getter, Action<Game, string> setter)
 {
     ButtonWidget widget = ButtonWidget.Create( game, x, y, 240, 35, text, Anchor.Centre, vDocking, titleFont, onClick );
     widget.GetValue = getter;
     widget.SetValue = setter;
     return widget;
 }
开发者ID:umby24,项目名称:ClassicalSharp,代码行数:8,代码来源:EnvSettingsScreen.cs

示例13: bind

 private void bind(PropertyItem propertyItem, RadioButton btnTopLeft, Anchor anchor)
 {
     BindingOperations.SetBinding(btnTopLeft, ToggleButton.IsCheckedProperty, LambdaBinding.New(
         new Binding("Value") { Source = propertyItem, Mode = propertyItem.IsReadOnly ? BindingMode.OneWay : BindingMode.TwoWay },
         (object source) => { return (Anchor) source == anchor; },
         (bool source) => { return source ? anchor : Binding.DoNothing; }
     ));
 }
开发者ID:rstarkov,项目名称:TankIconMaker,代码行数:8,代码来源:AnchorEditor.xaml.cs

示例14: DrawAt

 public void DrawAt( IDrawer2D drawer, string text, Font font,
     Anchor horAnchor, Anchor verAnchor, int width, int height, int x, int y)
 {
     ButtonWidth = width; ButtonHeight = height;
     Width = width; Height = height;
     CalculateOffset( x, y, horAnchor, verAnchor );
     Redraw( drawer, text, font );
 }
开发者ID:andrewphorn,项目名称:ClassicalSharp,代码行数:8,代码来源:LauncherInputWidget.cs

示例15: Page

 /// <summary>
 /// Initializes a new instance of <see cref="Page"/>.
 /// </summary>
 /// <param name="id">Initializes the required <see cref="Id"/>.</param>
 /// <param name="title">Initializes the required <see cref="Title"/>.</param>
 /// <param name="isHome">Initializes the required <see cref="IsHome"/>.</param>
 /// <param name="anchor">Initializes the required <see cref="Anchors"/>.</param>
 /// <param name="content">Initializes the required <see cref="Content"/>.</param>
 public Page(string id, string title, bool isHome, Anchor[] anchor, string content)
 {
     this.Id = id;
     this.Title = title;
     this.IsHome = isHome;
     this.Anchors = anchor;
     this.Content = content;
 }
开发者ID:GregMialon,项目名称:Projbook,代码行数:16,代码来源:Page.cs


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