質問編集履歴

2

書式の改善

2016/10/07 01:26

投稿

seep0619
seep0619

スコア25

test CHANGED
@@ -1 +1 @@
1
- C#_無数の四角形をマウスと重なるたびに色の変更をしたい。
1
+ C#
test CHANGED
@@ -1,199 +1,5 @@
1
1
  はじめまして。
2
2
 
3
- 不明点がありどうしてもわからないので投稿させていただきました
3
+ 不明点がありどうしてもわからないので投稿させていただきました
4
4
 
5
-
6
-
7
- <質問内容>
8
-
9
-
10
-
11
- 現段階では、青色の四角形が400個並んでおります。
12
-
13
- マウスがその四角形上に乗るたびにその四角形を””赤色に””
14
-
15
- 変更したいと考えております。
16
-
17
-
18
-
19
- 今は背景が赤色になってしまってる状態です。
5
+ 解決いたしました。有難うござました。感謝です。
20
-
21
- どうしても””backcolor””を””foreoclor””にすると
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
- "namespace C_Level_1
54
-
55
- {
56
-
57
- public partial class Form1 : Form
58
-
59
- {
60
-
61
- private object recst;
62
-
63
- Rectangle Rects;
64
-
65
-
66
-
67
- public Form1()
68
-
69
- {
70
-
71
- InitializeComponent();
72
-
73
- Rects = new Rectangle(3, 12, 100, 100);
74
-
75
- }
76
-
77
-
78
-
79
- public object Contains { get; private set; }
80
-
81
-
82
-
83
- private void Form1_Load(object sender, EventArgs e)
84
-
85
- {
86
-
87
- }
88
-
89
- private void pictureBox1_Click(object sender, EventArgs e)
90
-
91
- {
92
-
93
-
94
-
95
- Class1 person = new Class1();
96
-
97
- //using System.Drawing;44555
98
-
99
- //描画先とするImageオブジェクトを作成する
100
-
101
- Bitmap canvas = new Bitmap(pictureBox1.Width, pictureBox1.Height);
102
-
103
- //ImageオブジェクトのGraphicsオブジェクトを作成する
104
-
105
- Graphics g = Graphics.FromImage(canvas);
106
-
107
-
108
-
109
- //Penオブジェクトの作成(幅1の黒色)
110
-
111
- //(この場合はPenを作成せずに、Pens.Blackを使っても良い)
112
-
113
- Pen p = new Pen(Color.Blue, 1);
114
-
115
- //3つの長方形の位置と大きさを配列に入れる
116
-
117
- for (int i = 20; i < 400; i++)
118
-
119
- {
120
-
121
- Rectangle[] recst = {
122
-
123
- new Rectangle(i,i,100,100)};
124
-
125
-
126
-
127
- Rectangle PointClick = default(Rectangle);
128
-
129
- if (recst.Contains(PointClick) == true)
130
-
131
- {
132
-
133
- MessageBox.Show("クリックしたポイントはRect内です。");
134
-
135
- }
136
-
137
- else
138
-
139
- {
140
-
141
- this.BackColor = System.Drawing.Color.Red;
142
-
143
- }
144
-
145
-
146
-
147
-
148
-
149
- Rectangle MouseMove = default(Rectangle);
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
- //3つの長方形を描く
158
-
159
- g.DrawRectangles(p, recst);
160
-
161
- Console.WriteLine("recst" + i);
162
-
163
- }
164
-
165
-
166
-
167
- //リソースを解放する
168
-
169
- p.Dispose();
170
-
171
- g.Dispose();
172
-
173
-
174
-
175
- //PictureBox1に表示する
176
-
177
- pictureBox1.Image = canvas;
178
-
179
- Console.WriteLine();
180
-
181
-
182
-
183
- }
184
-
185
- public void pictureBox1_MouseM(object sender, PaintEventArgs e)
186
-
187
- {
188
-
189
- Pen p = new Pen(Color.Red);
190
-
191
- e.Graphics.DrawRectangle(p, Rects);
192
-
193
- Console.WriteLine();
194
-
195
- }
196
-
197
- }
198
-
199
- }"

1

2016/10/07 01:26

投稿

seep0619
seep0619

スコア25

test CHANGED
File without changes
test CHANGED
@@ -46,7 +46,11 @@
46
46
 
47
47
 
48
48
 
49
+
50
+
51
+
52
+
49
- namespace C_Level_1
53
+ "namespace C_Level_1
50
54
 
51
55
  {
52
56
 
@@ -192,4 +196,4 @@
192
196
 
193
197
  }
194
198
 
195
- }
199
+ }"