質問編集履歴

1

書式の改善

2016/10/07 01:17

投稿

seep0619
seep0619

スコア25

test CHANGED
@@ -1 +1 @@
1
- C#_無数の四角形の青色枠をマウスに触れるたびに赤色枠に変えたい。
1
+ C#
test CHANGED
@@ -1,171 +1 @@
1
- <質問内容>
2
-
3
- C#_無数の四角形の青色枠をマウス触れる赤色枠に変えたい。
1
+ C#について解決いしました。本当助かりまし。またどうぞ宜しくお願いたします
4
-
5
-
6
-
7
-
8
-
9
- <現状>
10
-
11
- 何度も申し訳ないです、
12
-
13
- どうしてもわからない為投稿させて頂きました。
14
-
15
-
16
-
17
- 無数の四角形の青枠。そして1つだけ赤の図形作成。
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
- ”namespace C_Level_1
50
-
51
- {
52
-
53
- public partial class Form1 : Form
54
-
55
- {
56
-
57
- private object recst;
58
-
59
- Rectangle Rects;
60
-
61
-
62
-
63
- public Form1()
64
-
65
- {
66
-
67
- InitializeComponent();
68
-
69
- Rects = new Rectangle(3, 12, 100, 100);
70
-
71
-
72
-
73
- }
74
-
75
-
76
-
77
- public object Contains { get; private set; }
78
-
79
-
80
-
81
- private void Form1_Load(object sender, EventArgs e)
82
-
83
- {
84
-
85
- Bitmap canvas = new Bitmap(pictureBox1.Width, pictureBox1.Height);
86
-
87
- //ImageオブジェクトのGraphicsオブジェクトを作成する
88
-
89
- Graphics g = Graphics.FromImage(canvas);
90
-
91
-
92
-
93
- //Penオブジェクトの作成(幅1の黒色)
94
-
95
- //(この場合はPenを作成せずに、Pens.Blackを使っても良い)
96
-
97
- Pen p = new Pen(Color.Blue, 1);
98
-
99
- //3つの長方形の位置と大きさを配列に入れる
100
-
101
- for (int i = 20; i < 400; i++)
102
-
103
- {
104
-
105
- Rectangl recst =
106
-
107
- new Rectangle(2,2,100,100),
108
-
109
- new Rectangle(4,4,100,100);
110
-
111
-
112
-
113
- Rectangle PointClick = default(Rectangle);
114
-
115
- if (recst.Contains(PointClick) == true)
116
-
117
- {
118
-
119
- MessageBox.Show("クリックしたポイントはRect内です。");
120
-
121
- }
122
-
123
- else
124
-
125
- {
126
-
127
- g.FillRectangle(Brushes.Red, Rects);
128
-
129
- }
130
-
131
-
132
-
133
- Rectangle MouseMove = default(Rectangle);
134
-
135
-
136
-
137
- //3つの長方形を描く
138
-
139
- g.DrawRectangles(p, recst);
140
-
141
- Console.WriteLine("recst" + i);
142
-
143
- }
144
-
145
-
146
-
147
- //リソースを解放する
148
-
149
- p.Dispose();
150
-
151
- g.Dispose();
152
-
153
-
154
-
155
- //PictureBox1に表示する
156
-
157
- pictureBox1.Image = canvas;
158
-
159
- Console.WriteLine();
160
-
161
-
162
-
163
- }
164
-
165
-
166
-
167
- }
168
-
169
-
170
-
171
- }