private void Surface_Paint(object sender, PaintEventArgs e) { Color warningColor = maxWarn ? Color.FromArgb(243, 0, 0) : Color.FromArgb(223, 223, 223); Color warningColorShadow = maxWarn ? Colors.Black : Color.FromArgb(67, 67, 67); e.Graphics.DrawImage(Images.ExtractBitmap(DLLs.Tiles, "taxRateWallpaper").CropImage(new Rectangle(0, 0, 600, 385)), new Rectangle(11, 38, 600, 385)); var font1 = new Font("Times New Roman", 18); Draw.Text(e.Graphics, $"Government: {Game.GetActiveCiv.Government}", font1, warningColor, new Point(17, 47), false, false, warningColorShadow, 1, 1); Draw.Text(e.Graphics, $"Maximum Rate: {maxRate}%", font1, warningColor, new Point(327, 47), false, false, warningColorShadow, 1, 1); int totalIncome = Game.GetActiveCiv.Cities.Sum(c => c.Tax); Draw.Text(e.Graphics, $"Total Income: {totalIncome}", font1, Color.FromArgb(223, 223, 223), new Point(91, 101), false, false, Color.FromArgb(67, 67, 67), 1, 1); int totalCost = Game.GetActiveCiv.Cities.Sum(c => c.Improvements.Sum(i => i.Upkeep)); Draw.Text(e.Graphics, $"Total Cost: {totalCost}", font1, Color.FromArgb(223, 223, 223), new Point(295, 101), false, false, Color.FromArgb(67, 67, 67), 1, 1); int discoveries = 0; // TODO: determine discoveries Draw.Text(e.Graphics, $"Discoveries: {discoveries}", font1, Color.FromArgb(223, 223, 223), new Point(278, 128), true, false, Color.FromArgb(67, 67, 67), 1, 1); Draw.Text(e.Graphics, "0%", font1, Color.FromArgb(223, 223, 223), new Point(22, 182), false, false, Color.FromArgb(67, 67, 67), 1, 1); Draw.Text(e.Graphics, "0%", font1, Color.FromArgb(223, 223, 223), new Point(22, 243), false, false, Color.FromArgb(67, 67, 67), 1, 1); Draw.Text(e.Graphics, "0%", font1, Color.FromArgb(223, 223, 223), new Point(22, 304), false, false, Color.FromArgb(67, 67, 67), 1, 1); Draw.Text(e.Graphics, $"Taxes: {taxRate}%", font1, Color.FromArgb(223, 223, 223), new Point(278, 182), true, false, Color.FromArgb(67, 67, 67), 1, 1); Draw.Text(e.Graphics, $"Science: {sciRate}%", font1, Color.FromArgb(223, 223, 223), new Point(278, 243), true, false, Color.FromArgb(67, 67, 67), 1, 1); Draw.Text(e.Graphics, $"Luxuries: {luxRate}%", font1, Color.FromArgb(223, 223, 223), new Point(278, 304), true, false, Color.FromArgb(67, 67, 67), 1, 1); Draw.Text(e.Graphics, "100%", font1, Color.FromArgb(223, 223, 223), new Point(472, 182), false, false, Color.FromArgb(67, 67, 67), 1, 1); Draw.Text(e.Graphics, "100%", font1, Color.FromArgb(223, 223, 223), new Point(472, 243), false, false, Color.FromArgb(67, 67, 67), 1, 1); Draw.Text(e.Graphics, "100%", font1, Color.FromArgb(223, 223, 223), new Point(472, 304), false, false, Color.FromArgb(67, 67, 67), 1, 1); Draw.Text(e.Graphics, "Lock", font1, Color.FromArgb(223, 223, 223), new Point(573, 182), true, false, Color.FromArgb(67, 67, 67), 1, 1); Draw.Checkbox(e.Graphics, taxCheckbox.Checked == true, new Point(563, 209)); Draw.Checkbox(e.Graphics, sciCheckbox.Checked == true, new Point(563, 270)); Draw.Checkbox(e.Graphics, luxCheckbox.Checked == true, new Point(563, 331)); }
public CheckboxPanel(Main parent, int width, int height, string title, string[] checkboxNames, string[] buttonTexts) : base(parent, width, height, 38, 46, title) { // Define formatted texts var _font1 = new Font("Times New Roman", 18); var _brush1 = new SolidBrush(Color.FromArgb(51, 51, 51)); FormattedText[] formattedText = new FormattedText[checkboxNames.Length]; for (int i = 0; i < checkboxNames.Length; i++) { formattedText[i] = new FormattedText() { Font = _font1, ForegroundBrush = _brush1, Text = checkboxNames[i] }; } CheckBox = new CheckBox[checkboxNames.Length]; for (int row = 0; row < checkboxNames.Length; row++) { CheckBox[row] = new CheckBox() { Text = checkboxNames[row], Font = new Font("Times New Roman", 18), TextColor = Color.FromArgb(51, 51, 51), BackgroundColor = Colors.Transparent }; CheckBox[row].CheckedChanged += (sender, e) => innerPanel.Invalidate(); CheckBox[row].GotFocus += (sender, e) => innerPanel.Invalidate(); Layout.Add(CheckBox[row], 11 + 10, 40 + 32 * row); } innerPanel = new Drawable() { Size = new Size(width - 2 * 11, height - 38 - 46), BackgroundColor = Colors.Black }; innerPanel.Paint += (sender, e) => { // Background var imgSize = MapImages.PanelInnerWallpaper.Size; for (int row = 0; row < this.Height / imgSize.Height + 1; row++) { for (int col = 0; col < this.Width / imgSize.Width + 1; col++) { e.Graphics.DrawImage(MapImages.PanelInnerWallpaper, col * imgSize.Width, row * imgSize.Height); } } // Draw checkbox, text, text outline for (int row = 0; row < checkboxNames.Length; row++) { Draw.Checkbox(e.Graphics, CheckBox[row].Checked == true, new Point(9, 5 + 32 * row)); e.Graphics.DrawText(formattedText[row], new Point(36, 32 * row + 4)); using var _pen = new Pen(Color.FromArgb(64, 64, 64)); var textSize = formattedText[row].Measure(); if (CheckBox[row].HasFocus) { e.Graphics.DrawRectangle(_pen, new Rectangle(36, 32 * row + 4, (int)textSize.Width, (int)textSize.Height)); } } }; innerPanel.MouseDown += (sender, e) => { for (int row = 0; row < checkboxNames.Length; row++) { // Update if checkbox is clicked if (e.Location.X > 7 && e.Location.X < 33 && e.Location.Y > 3 + 32 * row && e.Location.Y < 28 + 32 * row) { CheckBox[row].Checked = !CheckBox[row].Checked; innerPanel.Invalidate(); } // Update if text is clicked if (e.Location.X > 36 && e.Location.X < 36 + (int)formattedText[row].Measure().Width&& e.Location.Y > 32 * row + 4 && e.Location.Y < 32 * row + 4 + (int)formattedText[row].Measure().Height) { CheckBox[row].Checked = !CheckBox[row].Checked; CheckBox[row].Focus(); innerPanel.Invalidate(); } } }; Layout.Add(innerPanel, 11, 38); // Buttons Button = new Civ2button[buttonTexts.Length]; int btnW = (this.Width - 2 * 9 - 3 * (buttonTexts.Length - 1)) / buttonTexts.Length; // Determine width of one button for (int i = 0; i < buttonTexts.Length; i++) { Button[i] = new Civ2button(buttonTexts[i], btnW, 36, new Font("Times new roman", 11)); Layout.Add(Button[i], 9 + btnW * i + 3 * i, Height - 46); } Content = Layout; }