1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace Exercice2
{
public partial class Form1 : Form
{
SolidBrush brosse = new SolidBrush(Color.Blue);
SolidBrush brosse2 = new SolidBrush(Color.Black);
public Form1()
{
InitializeComponent();
}
private void btnCarre_Click(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
g.TranslateTransform(this.ClientSize.Width / 2, ClientSize.Height / 2);
for (int i = 0; i < 12; i++)
{
g.RotateTransform(30);
g.FillRectangle(brosse2, 100, -5, 10, 10);
}
}
private void btnChiffre_Click(object sender, EventArgs e)
{
Graphics h = this.CreateGraphics();
h.TranslateTransform(this.ClientSize.Width / 2, ClientSize.Height / 2);
double x, y;
for (int i = 1; i <= 12; i++)
{
int angle = i * 30 - 90;
x = Math.Cos(angle * Math.PI / 180) * 100;
y = Math.Sin(angle * Math.PI / 180) * 100;
FontFamily ff = new FontFamily("Times New Roman");
Font fnt = new Font(ff, .30f, GraphicsUnit.Inch);
h.DrawString(i + "", fnt, brosse, (float)x, (float)y);
}
}
}
} |
Partager