private void load() { anchorPosition = Anchor; float xPositionBox = anchorPosition != Anchor.Centre ? anchorPosition == Anchor.CentreLeft ? -1 * (800 / 2) : (800 / 2) : 0; float xSize = 801 / 3; AddInternal( ItemBox = new Box { Size = new osuTK.Vector2(x: xSize, y: 111), Anchor = Anchor.Centre, Origin = anchorPosition, Position = new osuTK.Vector2(x: xPositionBox, y: 0), Colour = DisplayColour, } ); AddInternal( PackSpriteText = new SpriteText { Text = DisplayName.ToUpper(), Font = TCCFont.GetFont(weight: FontWeight.Medium, size: 49), Anchor = anchorPosition, Origin = Anchor.Centre, } ); AddInternal( PackSizeSpriteText = new SpriteText { Text = SizeConvert.SizeSuffix(PackSize), Font = TCCFont.GetFont(weight: FontWeight.Thin, size: 49), Anchor = anchorPosition, Origin = Anchor.Centre, } ); // Positions, since the only way to make sure it's in the middle of the box, // is to calculate the draw width, which is after the entire shape is loaded. PackSpriteText.Position = new osuTK.Vector2( x: (ItemBox.DrawWidth / 2) * (anchorPosition == Anchor.Centre ? 0 : anchorPosition == Anchor.CentreLeft ? 1 : -1), y: PackSizeSpriteText.DrawHeight / 2 * -1); PackSizeSpriteText.Position = new osuTK.Vector2( x: (ItemBox.DrawWidth / 2) * (anchorPosition == Anchor.Centre ? 0 : anchorPosition == Anchor.CentreLeft ? 1 : -1), y: PackSpriteText.DrawHeight / 2); }
private void load(LargeTextureStore textureStore) { Texture folderButton = textureStore.Get("Folder Button"); Size = folderButton.Size; sizeText = new SpriteText { Text = $"Free Size: {SizeConvert.SizeSuffix(driveInfoBindable.Value.AvailableFreeSpace)}", Origin = Anchor.CentreRight, Anchor = Anchor.CentreRight, Font = TCCFont.GetFont(Typeface.Ageo, size: 22, weight: FontWeight.Thin), Position = new Vector2(-1 * (20 + (folderButton.Size.X / 2)), 0) }; AddInternal(sizeText); driveInfoBindable.ValueChanged += DriveInfoBindable_ValueChanged; }
private void DriveInfoBindable_ValueChanged(ValueChangedEvent <DriveInfo> obj) { sizeText.Text = $"Free Size: {SizeConvert.SizeSuffix(driveInfoBindable.Value.AvailableFreeSpace)}"; }