C#의 Winform 프로젝트에로드 된 이미지가있는 그림 상자가 있습니다. Form을 초기화 할 때 Picturebox에로드하는 몇 개의 타원 (X 점, Y 점, 너비, 높이, ZoneID, ZoneDescription)을 포함하는 Struct을 정의했습니다.Picturebox 이미지의 영역을 정의합니다 - 툴팁 C#
2 가지를 시도하고 싶습니다. 1) 사용자가 그림 상자의 그림 위에 마우스로 움직일 수있게하십시오. 마우스가 구조체에서 식별 된 영역에 들어가 자마자 구조체의 ZoneDescription을 보여주는 툴팁을 표시해야합니다.
2) 사용자가 여러 구역 중 하나를 클릭하면 응답을 생성하여 ZoneID를 트랩 할 수 있습니다.이 구역은 이미 구조체에 정의되어 있습니다. 그런 다음이를 데이터 집합에 추가합니다. 내가 할 수있는이 부분.
나는 Pt1에 대해 어떻게 해야할지 모르겠다. 어딘가에서 모든 영역에 대해 MouseEnter 이벤트 핸들러와 MouseLeave EventHandler를 정의해야하지만, 어떻게해야할지 모르겠습니다. 이미 양식에 툴팁이 있습니다. 여기
구조체의 정의는 영역을 포함한다 :
public struct TreatmentZone
{
public int nZoneID;
public string sZoneCode;
public string sZoneDesc;
public Color sbPaintbrush;
public int nZonewidth;
public int nZoneheight;
public int nZoneX;
public int nZoneY;
public TreatmentZone(int _ZoneID, string _sZoneCode,string _ZoneDesc, Color _sbBrush, int _ZoneX, int _ZoneY, int _Zonewidth, int _Zoneheight)
{
this.nZoneID = _ZoneID;
this.sZoneCode = _sZoneCode;
this.sZoneDesc = _ZoneDesc;
this.sbPaintbrush = _sbBrush;
this.nZoneX = _ZoneX;
this.nZoneY = _ZoneY;
this.nZonewidth = _Zonewidth;
this.nZoneheight = _Zoneheight;
}
};
TreatmentZone[] tZone = {
new TreatmentZone(1,"R1","Brain", Color.AliceBlue,155,35,30,20),
new TreatmentZone(5,"R2", "Hypothalamus", Color.AliceBlue,184,55,12,12)
};
private void pic_TreatmentZones1_RightSole_Paint(object sender, PaintEventArgs e)
{
e.Graphics.FillEllipse(new System.Drawing.SolidBrush(tZone[0].sbPaintbrush), tZone[0].nZoneX, tZone[0].nZoneY, tZone[0].nZonewidth, tZone[0].nZoneheight);
e.Graphics.FillEllipse(new System.Drawing.SolidBrush(tZone[1].sbPaintbrush), tZone[1].nZoneX, tZone[1].nZoneY, tZone[1].nZonewidth, tZone[1].nZoneheight);
}
어떻게 PT1에 필요한 단계가 할 것인가? 누구나 내가 사용할 수있는 코드 샘플을 가지고 있습니까?
양식 : 내 PictureBox를 단지 pictureBox1
공공 부분 Form1 클래스에 주의라는 Excellent 친애하는 Feal! 이걸 도와 주셔서 정말 고마워요! 이것은 정말 도움이 될 것입니다! :-) – lenvdb
모두 안녕 많은 도움을 주셔서 감사합니다 - 나는 당신의 제안을 통합했고 완벽하게 작동하도록했습니다 - 또한 구조체가 아닌 List 개체를 사용합니다. 훨씬 낫다. – lenvdb