반응형
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
 
namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int x = 0, y = 0;
 
        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawRectangle(Pens.Orange, x, y, 100100); // 네모칸을 그린다.
            e.Graphics.FillRectangle(Brushes.Red, 100100100100); // 채워진 네모칸을 그린다.
            
        } // 그려주는함수
 
        private void Form1_MouseDown(object sender, MouseEventArgs e)
        {
            x = x + 10;
            y = y + 10;
            this.Invalidate(); // refresh 새로고침.
        }// 클릭할 경우 이벤트
    }
}
 
cs

 //마우스를 클릭 할 경우 네모칸이 움직 인다.

//e.Graphics.FillEllipse(Brushes.Purple, 200, 200, 100, 100); // 원을 그린다.
//e.Graphics.DrawString("hello", new Font("Arial", 16), Brushes.Blue, 300, 100); // 문자를 입력한다.

 

반응형

'Study > C#' 카테고리의 다른 글

C# - 닷지 게임 만들기  (0) 2018.08.30
C# - 비행기 자유롭게 움직이기  (0) 2018.08.30
C# - 공튀기기 (particles.js)  (0) 2018.08.30
C# - 계산기 만들기2  (0) 2018.08.30
C# - WinForm 계산기 만들기1  (0) 2018.08.29

+ Recent posts