4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

C#でレイヤー構造

Last updated at Posted at 2015-12-19

#c#でレイヤー構造
さっきまで、いろいろ試してました。要はparentを設定することです。

まず、3つのレイヤをpicturBoxで作成します。
その最下層はビットマップでその上にGraphics.DrawLineとかで絵を描くとしますと
次のような設定をFormのコンストラクタに書いておきます

 pictureBox3.Parent = pictureBox2;
 pictureBox2.Parent =pictureBox1
 pictureBox1.Backcolor = Color.transpareent;
 pictureBox2.BackColor = Color.TransParent;

これで、このpicturBoxに絵を描きます

 Graphics g = Graphics.FromImage(bmp1);
 Pen p = new Pen(Color.Red,4);
 g.DrawLine(p,new Point(10,10),new Point(40,30));
 g.Dispose();
 pictureBox1.Image = bmp1;

そうそう、on/offに備えて直接pictueBoxに書くのではなくbmpを事前に準備して書いておくということになります。
そしてこれをon/offしたい場合は
 picturBox1.Image=bmp1; //on
pictueBox1.Image=null; //off
という感じでできあがりです。

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?