質問編集履歴
1
書式の改善
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
C#
|
1
|
+
C#
|
body
CHANGED
@@ -1,86 +1,1 @@
|
|
1
|
-
<質問内容>
|
2
|
-
C#
|
1
|
+
C#について解決いたしました。本当に助かりました。またどうぞ宜しくお願いいたします。
|
3
|
-
|
4
|
-
|
5
|
-
<現状>
|
6
|
-
何度も申し訳ないです、
|
7
|
-
どうしてもわからない為投稿させて頂きました。
|
8
|
-
|
9
|
-
無数の四角形の青枠。そして1つだけ赤の図形作成。
|
10
|
-
(マウスが触れるたびに赤色枠に変更したい)
|
11
|
-
|
12
|
-
上記の件に関してはこちらのようにコードを転記しており、
|
13
|
-
現状ではエラーは特に出てないですが、
|
14
|
-
|
15
|
-
|
16
|
-
四角形の青枠にマウスが近づくと赤枠に変更するような
|
17
|
-
仕様にはあとどのように変更したらよいのか
|
18
|
-
教えて頂けると嬉しいです。
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
現在コード
|
24
|
-
|
25
|
-
”namespace C_Level_1
|
26
|
-
{
|
27
|
-
public partial class Form1 : Form
|
28
|
-
{
|
29
|
-
private object recst;
|
30
|
-
Rectangle Rects;
|
31
|
-
|
32
|
-
public Form1()
|
33
|
-
{
|
34
|
-
InitializeComponent();
|
35
|
-
Rects = new Rectangle(3, 12, 100, 100);
|
36
|
-
|
37
|
-
}
|
38
|
-
|
39
|
-
public object Contains { get; private set; }
|
40
|
-
|
41
|
-
private void Form1_Load(object sender, EventArgs e)
|
42
|
-
{
|
43
|
-
Bitmap canvas = new Bitmap(pictureBox1.Width, pictureBox1.Height);
|
44
|
-
//ImageオブジェクトのGraphicsオブジェクトを作成する
|
45
|
-
Graphics g = Graphics.FromImage(canvas);
|
46
|
-
|
47
|
-
//Penオブジェクトの作成(幅1の黒色)
|
48
|
-
//(この場合はPenを作成せずに、Pens.Blackを使っても良い)
|
49
|
-
Pen p = new Pen(Color.Blue, 1);
|
50
|
-
//3つの長方形の位置と大きさを配列に入れる
|
51
|
-
for (int i = 20; i < 400; i++)
|
52
|
-
{
|
53
|
-
Rectangl recst =
|
54
|
-
new Rectangle(2,2,100,100),
|
55
|
-
new Rectangle(4,4,100,100);
|
56
|
-
|
57
|
-
Rectangle PointClick = default(Rectangle);
|
58
|
-
if (recst.Contains(PointClick) == true)
|
59
|
-
{
|
60
|
-
MessageBox.Show("クリックしたポイントはRect内です。");
|
61
|
-
}
|
62
|
-
else
|
63
|
-
{
|
64
|
-
g.FillRectangle(Brushes.Red, Rects);
|
65
|
-
}
|
66
|
-
|
67
|
-
Rectangle MouseMove = default(Rectangle);
|
68
|
-
|
69
|
-
//3つの長方形を描く
|
70
|
-
g.DrawRectangles(p, recst);
|
71
|
-
Console.WriteLine("recst" + i);
|
72
|
-
}
|
73
|
-
|
74
|
-
//リソースを解放する
|
75
|
-
p.Dispose();
|
76
|
-
g.Dispose();
|
77
|
-
|
78
|
-
//PictureBox1に表示する
|
79
|
-
pictureBox1.Image = canvas;
|
80
|
-
Console.WriteLine();
|
81
|
-
|
82
|
-
}
|
83
|
-
|
84
|
-
}
|
85
|
-
|
86
|
-
}
|