private void PositionElements() { Body.Position = new Point(Background.Graphic.LeftBorderThickness, Background.Graphic.TopBorderThickness); // Figure out width Body.Width = ToggleBag.Width; TopRow.Width = Body.Width; // Width = Body.Width + Background.Graphic.LeftBorderThickness + Background.Graphic.RightBorderThickness + Padding * 2; // Build the top row var longestCat = Categories.OrderByDescending(s => s.Length).First(); var headerWidth = (int)HeaderFont.MeasureString(longestCat).X; NextButton.X = TopRow.Width / 2 + headerWidth / 2; PrevButton.X = TopRow.Width / 2 - PrevButton.Width - headerWidth / 2; SelectAllButton.X = Padding; CategoryLabel.Text = ActiveCategory; CategoryLabel.CenterHorizontally(); TopRow.Height = TopRow.Children.Max(c => c.Height); foreach (var child in TopRow.Children) { child.Y = TopRow.Height / 2 - child.Height / 2; } // Figure out height and vertical positioning ToggleBag.Y = TopRow.Y + TopRow.Height + Padding; Body.Height = ToggleBag.Y + ToggleBag.Height; Height = TopRow.Height + Game1.tileSize * MaxItemRows + Padding * (MaxItemRows - 1) + Background.Graphic.TopBorderThickness + Background.Graphic.BottomBorderThickness + Padding * 2; Background.Width = Width; Background.Height = Height; CloseButton.Position = new Point(Width - CloseButton.Width, 0); ScrollBar.Position = new Point(Width - 64 - 3 * 4, CloseButton.Height); ScrollBar.Height = Height - CloseButton.Height - 16; ScrollBar.Visible = NumItems > MaxItemsPage; ScrollBar.ScrollPosition = 0; ScrollBar.ScrollMax = NumItems; ScrollBar.Step = MaxItemsPage; }
private void PositionElements() { Body.Position = new Point(Background.Graphic.LeftBorderThickness, Background.Graphic.RightBorderThickness); // Figure out width Body.Width = ToggleBag.Width; TopRow.Width = Body.Width; Width = Body.Width + Background.Graphic.LeftBorderThickness + Background.Graphic.RightBorderThickness + Padding * 2; // Build the top row var HeaderWidth = (int)HeaderFont.MeasureString(" Animal Product ").X; // TODO NextButton.X = TopRow.Width / 2 + HeaderWidth / 2; PrevButton.X = TopRow.Width / 2 - HeaderWidth / 2 - PrevButton.Width; SelectAllButton.X = Padding; CategoryLabel.CenterHorizontally(); TopRow.Height = TopRow.Children.Max(c => c.Height); foreach (var child in TopRow.Children) { child.Y = TopRow.Height / 2 - child.Height / 2; } // Figure out height and vertical positioning ToggleBag.Y = TopRow.Y + TopRow.Height + Padding; Body.Height = ToggleBag.Y + ToggleBag.Height; Height = Body.Height + Background.Graphic.TopBorderThickness + Background.Graphic.BottomBorderThickness + Padding * 2; Background.Width = Width; Background.Height = Height; CloseButton.Position = new Point(Width - CloseButton.Width, 0); }
private void PositionElements() { Body.Position = new Point(Background.Graphic.LeftBorderThickness, Background.Graphic.RightBorderThickness); // Figure out width Body.Width = ToggleBag.Width; TopRow.Width = Body.Width; Width = Body.Width + Background.Graphic.LeftBorderThickness + Background.Graphic.RightBorderThickness + Padding * 2; // Build the top row var longestCat = Categories.OrderByDescending(s => s.Length).First(); var headerWidth = (int)HeaderFont.MeasureString(longestCat).X; NextButton.X = TopRow.Width / 2 + headerWidth / 2; PrevButton.X = TopRow.Width / 2 - PrevButton.Width - headerWidth / 2; SelectAllButton.X = Padding; CategoryLabel.CenterHorizontally(); TopRow.Height = TopRow.Children.Max(c => c.Height); foreach (var child in TopRow.Children) { child.Y = TopRow.Height / 2 - child.Height / 2; } // Figure out height and vertical positioning ToggleBag.Y = TopRow.Y + TopRow.Height + Padding; Body.Height = ToggleBag.Y + ToggleBag.Height; Height = (Body.Height + Background.Graphic.TopBorderThickness + Background.Graphic.BottomBorderThickness + Padding * 2); Background.Width = Width; Background.Height = Height; CloseButton.Position = new Point(Width - CloseButton.Width, 0); }