0
키오스크 응용 프로그램을 만들고 있습니다. 나는 그것을 전체 화면을하고 난 양식에 직접 그리기 오전 :이미지 및 winforms에 관한 질문
Private Function CreateHeader(ByVal headerText As String) As Boolean
Try
Dim oGFX As Graphics = Graphics.FromHwnd(hwnd:=_oP.Handle)
Dim oRect As Rectangle = New Rectangle(x:=0, y:=0, Width:=_screenSize.X, Height:=150)
Dim oBMP As New Bitmap(GetEmbeddedResourceStream("Kiosk.logo.jpg"))
Dim oBrush As Brush = New SolidBrush(Color.FromArgb(red:=0, green:=0, blue:=153))
oGFX.FillRectangle(brush:=oBrush, rect:=oRect)
oGFX.DrawImage(image:=oBMP, _
x:=0, _
y:=0, _
width:=oBMP.Width, _
height:=oBMP.Height)
If Not String.IsNullOrEmpty(headerText) Then
Dim oFont As New Font("Impact", 48, FontStyle.Regular)
Dim g As Graphics = Me.CreateGraphics()
Dim oStringSize As SizeF = g.MeasureString(headerText, oFont)
g = Nothing
oGFX.DrawString(s:=headerText, _
font:=oFont, _
brush:=Brushes.White, _
x:=(oRect.Width - Math.Round(oStringSize.Width, 0))/2, _
y:=(oRect.Height - Math.Round(oStringSize.Height, 0))/2)
End If
Return True
Catch ex As Exception
Return False
End Try
End Function
모든 것이 잘립니다 만, 두 번째는 내가 사각형 내가 사라를 그린 (임의의 순서로, 개별적으로 또는 함께) Alt 키 또는 탭을 누릅니다. 이 함수를 다시 호출하면 어떤 버튼을 누르더라도 다시 그려지고 그대로 유지됩니다. 한 번 호출해야 할 드로잉 함수를 호출해야하는 일종의 .NET 함수가 있습니까?
감사합니다.
좋아요, 메소드를 오버라이드로 옮겼습니다. headerText 변수를 어떻게 전달해야합니까? 전역 변수? – Anders
나는 여전히 동일한 동작을 얻고 있습니다. 원래 계획대로 가서 직사각형을 그리는 대신 패널을 만들 것이라고 생각합니다. 어쨌든이 방법으로 최종 구현에 대한 더 많은 제어권을 갖게 될 것입니다. 그래도 도와 줘서 고마워. – Anders
죄송합니다. 저는 다른 곳에 있었으므로 텍스트 변수를 사용해야합니다. 매우 놀랐습니다. 해야한다! –