本文整理汇总了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);
}
示例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;
}
}
示例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;
}
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
示例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 );
}
示例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)));
}
示例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 );
}
示例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;
}
示例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;
}
示例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; }
));
}
示例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 );
}
示例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;
}