88 lines
2.2 KiB
C#
88 lines
2.2 KiB
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
using System.Linq.Expressions;
|
|
|
|
namespace Graphics
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
Color background = Color.FromArgb(0, 39, 104);
|
|
Color stripes = Color.FromArgb(250, 204, 8);
|
|
|
|
float size = 20;
|
|
int startX = 100;
|
|
int startY = 100;
|
|
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
numericUpDown1.Value = (decimal)size; // init size
|
|
}
|
|
|
|
protected override void OnPaint(PaintEventArgs e)
|
|
{
|
|
base.OnPaint(e);
|
|
var g = e.Graphics;
|
|
|
|
SolidBrush solidBrush = new SolidBrush(background);
|
|
|
|
// background
|
|
g.FillRectangle(
|
|
solidBrush,
|
|
startX,
|
|
startY,
|
|
16 * size, // x size
|
|
10 * size // y size
|
|
);
|
|
|
|
solidBrush.Color = stripes;
|
|
|
|
// horizontal stripe
|
|
g.FillRectangle(
|
|
solidBrush,
|
|
startX,
|
|
startY + 4 * size, // y offset
|
|
16 * size, // x size
|
|
2 * size // y size
|
|
);
|
|
|
|
// vertical stripe
|
|
g.FillRectangle(
|
|
solidBrush,
|
|
startX + 5 * size, // x offset
|
|
startY,
|
|
2 * size, // x size
|
|
10 * size // y size
|
|
);
|
|
}
|
|
|
|
private void btn_sverige_Click(object sender, EventArgs e)
|
|
{
|
|
background = Color.FromArgb(0, 39, 104);
|
|
stripes = Color.FromArgb(250, 204, 8);
|
|
Invalidate();
|
|
}
|
|
|
|
private void btn_danmark_Click(object sender, EventArgs e)
|
|
{
|
|
background = Color.FromArgb(198, 12, 48);
|
|
stripes = Color.FromArgb(255, 255, 255);
|
|
Invalidate();
|
|
}
|
|
|
|
private void btn_finland_Click(object sender, EventArgs e)
|
|
{
|
|
background = Color.FromArgb(255, 255, 255);
|
|
stripes = Color.FromArgb(0, 53, 128);
|
|
Invalidate();
|
|
}
|
|
|
|
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
|
|
{
|
|
size = ((float)numericUpDown1.Value);
|
|
Invalidate();
|
|
}
|
|
}
|
|
}
|