Hi,
weiß jemand, wie man in WPF auch mit GDI zeichnen kann?
Ich habe hier einen Code ( WinForms )
So...nur leider gibts das in WPF nicht mehr...
wie kann ich das nun nach WPF umschreiben?
weiß jemand, wie man in WPF auch mit GDI zeichnen kann?
Ich habe hier einen Code ( WinForms )
VB.NET-Quellcode
- Public Class Form1
- Dim thread As New Threading.Thread(AddressOf drawing)
- Dim gebäudes As New List(Of Gebäude)
- Sub drawing()
- Dim xs As Integer = 0
- Do
- Select Case xs
- Case 0
- gebäudes.Add(New Gebäude(0, New Point(0, 0), Brushes.Red, "", New List(Of Point)({}), 0))
- xs += 1
- Case 1
- gebäudes.Add(New Gebäude(0, New Point(1, 0), Brushes.Red, "", New List(Of Point)({New Point(0, 0)}), 0))
- xs += 1
- Case 2
- gebäudes.Add(New Gebäude(0, New Point(0, 1), Brushes.Red, "", New List(Of Point)({New Point(0, 0), New Point(1, 0)}), 0))
- xs += 1
- Case 3
- gebäudes.Add(New Gebäude(0, New Point(1, 1), Brushes.Red, "", New List(Of Point)({New Point(0, 0), New Point(0, 1), New Point(1, 0)}), 0))
- xs += 1
- End Select
- Me.Invalidate()
- Threading.Thread.Sleep(250)
- Loop
- End Sub
- Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
- thread.Abort()
- End Sub
- Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
- thread.Start()
- End Sub
- Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
- Dim g = e.Graphics
- g.FillRectangle(Brushes.Gray, New Rectangle(0, 0, Me.Width, Me.Height))
- For x = 0 To gebäudes.Count - 1
- For Each item In gebäudes(x).requires
- g.DrawLine(Pens.Black, gebäudes(x).pos.X * 100 + 75, gebäudes(x).pos.Y * 100 + 75, item.X * 100 + 75, item.Y * 100 + 75)
- Next
- Next
- For x = 0 To gebäudes.Count - 1
- g.FillRectangle(gebäudes(x).color, gebäudes(x).pos.X * 100 + 50, gebäudes(x).pos.Y * 100 + 50, 50, 50)
- Next
- End Sub
- End Class
- Class Gebäude
- Dim _type As Integer
- Dim _pos As Point
- Dim _color As Brush
- Dim _text As String
- Dim _requires As New List(Of Point)
- Dim _level As Integer
- Public ReadOnly Property type As Integer
- Get
- Return _type
- End Get
- End Property
- Public ReadOnly Property pos As Point
- Get
- Return _pos
- End Get
- End Property
- Public ReadOnly Property color As Brush
- Get
- Return _color
- End Get
- End Property
- Public ReadOnly Property text As String
- Get
- Return _text
- End Get
- End Property
- Public ReadOnly Property requires As List(Of Point)
- Get
- Return _requires
- End Get
- End Property
- Public ReadOnly Property level As Integer
- Get
- Return _level
- End Get
- End Property
- Sub New(ByVal type As Integer, ByVal pos As Point, ByVal color As Brush, ByVal text As String, ByVal requires As List(Of Point), ByVal level As Integer)
- _type = type
- _pos = pos
- _color = color
- _text = text
- _requires = requires
- _level = level
- End Sub
- End Class
So...nur leider gibts das in WPF nicht mehr...
wie kann ich das nun nach WPF umschreiben?