Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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;
- namespace WindowsFormsApplication2
- {
- public partial class Form1 : Form
- {
- private MojPanel mp1, mp2;
- private void rysuj_Click(object sender, EventArgs e)
- {
- Graphics g = CreateGraphics();
- try
- {
- int szer = ClientRectangle.Width;
- int wys = ClientRectangle.Height;
- int r = 40;
- g.DrawEllipse(Pens.Red, szer / 2 - r, wys / 2 - r, 2 * r, 2 * r);
- }
- finally
- {
- g.Dispose();
- }
- }
- public Form1()
- {
- //OnClick += new EventHandler(rysuj_Click);
- mp1 = new MojPanel(this, 50, 50, 100, 100, Color.Blue);
- mp2 = new MojPanel(this, 400, 400, 200, 200, Color.LightGray);
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void rysuj2_Click(object sender, EventArgs e)
- {
- using (Graphics g = CreateGraphics())
- {
- int szer = ClientRectangle.Width;
- int wys = ClientRectangle.Height;
- int bok = 50;
- g.DrawRectangle(Pens.Blue, szer / 2, wys / 2, bok, bok);
- }
- }
- private void Form1_Paint(object sender, PaintEventArgs e)
- {
- Graphics g = e.Graphics;
- int szer = ClientRectangle.Width;
- int wys = ClientRectangle.Height;
- int oczko = 10;
- int marg = 20;
- for (int i = marg; i <= wys - marg; i += 10)
- {
- for (int j = marg; j <= szer - marg; j += 10)
- {
- SolidBrush b = new SolidBrush(Color.FromArgb(i % 256, j % 256, 200));
- g.DrawRectangle(Pens.Black, j, i, oczko, oczko);
- g.FillRectangle(b, j, i, oczko, oczko);
- }
- }
- }
- private void Form1_Resize(object sender, EventArgs e)
- {
- Invalidate();
- }
- }
- public class MojPanel : Panel
- {
- public MojPanel(Form aparent, int x, int y, int szer, int wys, Color k)
- {
- Parent = aparent;
- Left = x;
- Top = y;
- Width = szer;
- Height = wys;
- BackColor = k;
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- int szer = ClientRectangle.Width;
- int wys = ClientRectangle.Height;
- Graphics g = e.Graphics;
- g.DrawLine(Pens.Azure, 0, wys, szer, 0);
- }
- }
- }
- /* =================
- http://www9.zippyshare.com/v/18094249/file.html
- ================= */
Advertisement
Add Comment
Please, Sign In to add comment