마우스를 사용하여 영역을 선택하는 시스템을 만들었습니다. 내가 선택했을 때처럼 그러나이 지역은 같습니다, 나는 브라질 해요펜 C의 오류 #
죄송합니다 내 영어 ...
내 코드 :
private void ResizeSelection()
{
if (CurrentAction == ClickAction.LeftSizing)
{
if (Cursor.Position.X < CurrentBottomRight.X - 10)
{
//Erase the previous rectangle
g.DrawRectangle(EraserPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
CurrentTopLeft.X = Cursor.Position.X;
RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X;
g.DrawRectangle(MyPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
}
}
if (CurrentAction == ClickAction.TopLeftSizing)
{
if (Cursor.Position.X < CurrentBottomRight.X - 10 && Cursor.Position.Y < CurrentBottomRight.Y - 10)
{
//Erase the previous rectangle
g.DrawRectangle(EraserPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
CurrentTopLeft.X = Cursor.Position.X;
CurrentTopLeft.Y = Cursor.Position.Y;
RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X;
RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y;
g.DrawRectangle(MyPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
}
}
if (CurrentAction == ClickAction.BottomLeftSizing)
{
if (Cursor.Position.X < CurrentBottomRight.X - 10 && Cursor.Position.Y > CurrentTopLeft.Y + 10)
{
//Erase the previous rectangle
g.DrawRectangle(EraserPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
CurrentTopLeft.X = Cursor.Position.X;
CurrentBottomRight.Y = Cursor.Position.Y;
RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X;
RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y;
g.DrawRectangle(MyPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
}
}
if (CurrentAction == ClickAction.RightSizing)
{
if (Cursor.Position.X > CurrentTopLeft.X + 10)
{
//Erase the previous rectangle
g.DrawRectangle(EraserPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
CurrentBottomRight.X = Cursor.Position.X;
RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X;
g.DrawRectangle(MyPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
}
}
if (CurrentAction == ClickAction.TopRightSizing)
{
if (Cursor.Position.X > CurrentTopLeft.X + 10 && Cursor.Position.Y < CurrentBottomRight.Y - 10)
{
//Erase the previous rectangle
g.DrawRectangle(EraserPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
CurrentBottomRight.X = Cursor.Position.X;
CurrentTopLeft.Y = Cursor.Position.Y;
RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X;
RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y;
g.DrawRectangle(MyPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
}
}
if (CurrentAction == ClickAction.BottomRightSizing)
{
if (Cursor.Position.X > CurrentTopLeft.X + 10 && Cursor.Position.Y > CurrentTopLeft.Y + 10)
{
//Erase the previous rectangle
g.DrawRectangle(EraserPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
CurrentBottomRight.X = Cursor.Position.X;
CurrentBottomRight.Y = Cursor.Position.Y;
RectangleWidth = CurrentBottomRight.X - CurrentTopLeft.X;
RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y;
g.DrawRectangle(MyPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
}
}
if (CurrentAction == ClickAction.TopSizing)
{
if (Cursor.Position.Y < CurrentBottomRight.Y - 10)
{
//Erase the previous rectangle
g.DrawRectangle(EraserPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
CurrentTopLeft.Y = Cursor.Position.Y;
RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y;
g.DrawRectangle(MyPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
}
}
if (CurrentAction == ClickAction.BottomSizing)
{
if (Cursor.Position.Y > CurrentTopLeft.Y + 10)
{
//Erase the previous rectangle
g.DrawRectangle(EraserPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
CurrentBottomRight.Y = Cursor.Position.Y;
RectangleHeight = CurrentBottomRight.Y - CurrentTopLeft.Y;
g.DrawRectangle(MyPen, CurrentTopLeft.X, CurrentTopLeft.Y, RectangleWidth, RectangleHeight);
}
}
}
가 궁금 이 문제를 해결하거나 사각형의 가장자리 만 보이도록 투명하게 만드는 방법. 감사합니다.
'g.Clear()'함수는 현재 직사각형이 다시 그려지기 전에 직사각형 화면을 지울 수 있습니까? – gwin003
아니요, 테스트했습니다. 그것은 Color.Transparent를 사용하여 검은 색의 전체 화면을 남겨 둡니다. –