いつも大変お世話になっております。
フォーム内にPicturebox1~Picturebox4があります。
以下のプログラムですとpicturebox1に線が書き込まれると思います。
これを「ハンドル(番号)」を使用し、線を描くpicctureboxを選択・切り替えしたいのですが、
そのような設定などありますでしょうか?
また、別に方法などあるようでしたらアドバイスいただけないでしょうか?
どなた様かご指導ご鞭撻の程よろしくお願い致します。
以下プログラムとなります。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Collections;
using System.Drawing.Drawing2D;
namespace graph
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void pictureBox1_Paint(object sender, PaintEventArgs e) { // e.Graphics.ScaleTransform(1, -1); //Y軸方向の反転 // e.Graphics.TranslateTransform(0, pictureBox1.Height); float Sx=0; float Sy=0; float Ex=0; float Ey=0; Syokiti(ref Sx,ref Sy,ref Ex,ref Ey); graph.Gline(e, (float)Sx, (float)Sy, (float)Ex, (float)Ey); } private void Syokiti( ref float _Sx, ref float _Sy, ref float _Ex, ref float _Ey) { _Sx = 10; _Sy = 10; _Ex = 100; _Ey = 100; } } class global { public static Pen PenData = new Pen(Color.White, 1); } class graph { public static void Gline(PaintEventArgs e, float PtX1, float PtY1, float PtX2, float PtY2) { PointF[] LinePoint = new PointF[2]; LinePoint[0] = new PointF(PtX1, PtY1); LinePoint[1] = new PointF(PtX2, PtY2); e.Graphics.DrawLine(global.PenData, LinePoint[0], LinePoint[1]); } }
}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。