回答編集履歴

1

ソース修正

2019/05/28 02:14

投稿

YAmaGNZ
YAmaGNZ

スコア10268

test CHANGED
@@ -5,6 +5,12 @@
5
5
  public partial class Form1 : Form
6
6
 
7
7
  {
8
+
9
+ private Panel pnlScore, pnlKey;
10
+
11
+ private PictureBox picScore, picKeybord;
12
+
13
+
8
14
 
9
15
  public Form1()
10
16
 
@@ -14,39 +20,109 @@
14
20
 
15
21
 
16
22
 
17
- Panel p = new Panel() { Size = new Size(500, 100), Location = new Point(10, 10), AutoScroll = true };
23
+ //フォームの大きさ
18
24
 
19
- this.Controls.Add(p);
25
+ this.Size = new Size(800, 500);
20
26
 
21
27
 
22
28
 
23
- PictureBox pic = new PictureBox() { Size = new Size(4000, 200), Location = new Point(0, 0) };
29
+ //表示領域のパネル
24
30
 
25
- pic.Paint += Pic_Paint;
31
+ this.pnlScore = new Panel() { Location = new Point(130, 10), Size = new Size(640, 370), AutoScroll = true };
26
32
 
33
+ this.pnlKey = new Panel() { Location = new Point(10, 10), Size = new Size(120, 350) };
34
+
27
- p.Controls.Add(pic);
35
+ this.Controls.Add(pnlKey);
36
+
37
+ this.Controls.Add(pnlScore);
38
+
39
+
40
+
41
+ //描画するPictureBox
42
+
43
+ this.picKeybord = new PictureBox() { Location = new Point(0, 0), Size = new Size(120, 600) };
44
+
45
+ this.picScore = new PictureBox() { Location = new Point(0, 0), Size = new Size(5000, 600) };
46
+
47
+ pnlKey.Controls.Add(picKeybord);
48
+
49
+ pnlScore.Controls.Add(picScore);
50
+
51
+
52
+
53
+ this.picKeybord.Paint += new System.Windows.Forms.PaintEventHandler(this.picKeybord_Paint);
54
+
55
+ this.picScore.Paint += new System.Windows.Forms.PaintEventHandler(this.picScore_Paint);
56
+
57
+ this.pnlScore.Scroll += new System.Windows.Forms.ScrollEventHandler(this.pnlFumen_Scroll);
58
+
59
+
28
60
 
29
61
  }
30
62
 
31
63
 
32
64
 
33
- private void Pic_Paint(object sender, PaintEventArgs e)
65
+ private void pnlFumen_Scroll(object sender, ScrollEventArgs e)
34
66
 
35
67
  {
36
68
 
37
- //PictureBox全体描画
69
+ //譜面部分の縦スクロールにキーボード部分連動させる
38
70
 
39
- e.Graphics.Clear(Color.White);
40
-
41
- for (int x = 0; x < 4000; x += 100)
71
+ if (e.ScrollOrientation == ScrollOrientation.VerticalScroll)
42
72
 
43
73
  {
44
74
 
45
- e.Graphics.FillRectangle(Brushes.Red, new Rectangle(x, 0, 50, 100);
75
+ picKeybord.Top = -e.NewValue;
46
76
 
47
77
  }
48
78
 
49
79
  }
80
+
81
+
82
+
83
+ private void picKeybord_Paint(object sender, PaintEventArgs e)
84
+
85
+ {
86
+
87
+ for (int y = 0; y < picKeybord.Height; y += 50)
88
+
89
+ {
90
+
91
+ e.Graphics.FillRectangle(Brushes.Black, 0, y, picKeybord.Width, 30);
92
+
93
+ }
94
+
95
+ }
96
+
97
+
98
+
99
+ private void picScore_Paint(object sender, PaintEventArgs e)
100
+
101
+ {
102
+
103
+ for (int x = 0; x < picScore.Width; x += 50)
104
+
105
+ {
106
+
107
+ for (int y = 0; y < picScore.Height; y += 50)
108
+
109
+ {
110
+
111
+ if(x % 100 != 0 && y % 100 == 0)
112
+
113
+ {
114
+
115
+ e.Graphics.FillRectangle(Brushes.Black, x, y, 50, 50);
116
+
117
+ }
118
+
119
+ }
120
+
121
+ }
122
+
123
+ }
124
+
125
+
50
126
 
51
127
  }
52
128