[TuT] Eigenes Paint Programm erstellen

    • VB.NET

    Es gibt 11 Antworten in diesem Thema. Der letzte Beitrag () ist von ErfinderDesRades.

      [TuT] Eigenes Paint Programm erstellen

      Hallo Programmierer!

      Ich habe mich heute mal rangesetzt um ein etwas schwereres Tutorial zu machen.

      In diesem Tutorial zeige ich euch wie man sein Eigenes Paint in VB.08 / VB.10 erstellt.
      Es ist gut möglich das es mehrere Teile braucht.

      Dann fangen wir mal an:

      ====================================================
      Die Form
      ====================================================
      Spoiler anzeigen

      Ihr benötigt:
      - 14 RadioButtons (Schaut euch auf dem Bild an wie ihr sie nennen müsst(ich hab sie Englisch bennant( RadiererRadiBotton = EraserRadioButton)))
      - 3 Buttons [Namen: ColorButton, Color2Button und FontButton]
      - 1 PictureBox
      - 1 Textbox [Name: TextDrawTextBox]
      - 1 ColorDialog
      - 1 FontDialog
      - 1 SaveFileDialog
      - 1 Trackbar


      Vollansicht: Hier!

      So Nun erstellen wir mal Variablen:

      VB.NET-Quellcode

      1. Dim g As Graphics
      2. Dim PenWidth As Single = 1.0F
      3. Dim PenPoint As Pen
      4. Dim SavedFileAddress As String = ""
      5. Dim CurrentFont As Font
      6. Dim startLocation As Point
      7. Dim endLocation As Point
      8. Dim TempLocation As New Point(-1, -1)
      9. Dim TempLocation2 As New Point(-1, -1)
      10. Dim NumberOfAngle As Integer = 0
      11. Dim drawing As Boolean = False
      12. Dim CurrentColor As Color = Color.Blue
      13. Dim CurrentColor2 As Color = Color.LightSkyBlue
      14. Dim LastImage As New Bitmap(501, 501)
      15. Dim M1 As New Bitmap(501, 501)
      16. Dim M2 As New Bitmap(501, 501)
      17. Dim M3 As New Bitmap(501, 501)
      18. Dim M4 As New Bitmap(501, 501)


      Jetzt kommen wir mal zum Form1_Load Code. Hier wird die Schrift, die Farbe und das Bild gelade [...]:

      VB.NET-Quellcode

      1. Private Sub PaintForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      2. CurrentFont = Me.Font
      3. FontButton.Text = CurrentFont.ToString
      4. Me.ColorButton.BackColor = Color.Blue
      5. Me.Color2Button.BackColor = Color.DeepSkyBlue
      6. g = Graphics.FromImage(LastImage)
      7. g.Clear(Color.White)
      8. UpdateImage()
      9. ReloadPen(PenWidth, CurrentColor)
      10. End Sub



      ====================================================
      Funktionen für den Stift, die Füllfunktion und mehr
      ====================================================
      Spoiler anzeigen

      Hier müssen wir mehrere Functions und Subs erstellen.
      Beginnen wir mal mit den Stift funktionen. Der stift mit dem ihr malt ergibt ein + das müssen wir nun Coden.

      VB.NET-Quellcode

      1. Function UpPixelHaseSameColor(ByVal X As Integer, ByVal Y As Integer, ByVal Col As Color) As Boolean
      2. Dim result As Boolean = False
      3. If (Y > 0) Then
      4. If (LastImage.GetPixel(X, Y - 1) = Col) Then
      5. result = True
      6. End If
      7. End If
      8. Return result
      9. End Function
      10. Function DownPixelHaseSameColor(ByVal X As Integer, ByVal Y As Integer, ByVal Col As Color) As Boolean
      11. Dim result As Boolean = False
      12. If (Y < LastImage.Height - 1) Then
      13. If (LastImage.GetPixel(X, Y + 1) = Col) Then
      14. result = True
      15. End If
      16. End If
      17. Return result
      18. End Function
      19. Function RightPixelHaseSameColor(ByVal X As Integer, ByVal Y As Integer, ByVal Col As Color) As Boolean
      20. Dim result As Boolean = False
      21. If (X < LastImage.Width - 1) Then
      22. If (LastImage.GetPixel(X + 1, Y) = Col) Then
      23. result = True
      24. End If
      25. End If
      26. Return result
      27. End Function
      28. Function LeftPixelHaseSameColor(ByVal X As Integer, ByVal Y As Integer, ByVal Col As Color) As Boolean
      29. Dim result As Boolean = False
      30. If (X > 0) Then
      31. If (LastImage.GetPixel(X - 1, Y) = Col) Then
      32. result = True
      33. End If
      34. End If
      35. Return result
      36. End Function


      Jetzt gehen wir weiter zu der Füll-funktion.
      Dazu erstellt ihr wieder eine eigene Function:

      VB.NET-Quellcode

      1. Function FillRegion(ByVal X As Integer, ByVal Y As Integer, ByVal FillCol As Color) As Boolean
      2. If X < 0 Or X > LastImage.Width Or Y < 0 Or Y > LastImage.Height Then
      3. Return False
      4. End If
      5. Application.DoEvents()
      6. Dim points As Stack = New Stack
      7. points.Push(New Point(X, Y))
      8. Dim Pointcolor As Color = LastImage.GetPixel(X, Y)
      9. Do
      10. Dim p As Point = CType(points.Pop(), Point)
      11. LastImage.SetPixel(p.X, p.Y, FillCol)
      12. If UpPixelHaseSameColor(p.X, p.Y, Pointcolor) Then
      13. points.Push(New Point(p.X, p.Y - 1))
      14. End If
      15. If DownPixelHaseSameColor(p.X, p.Y, Pointcolor) Then
      16. points.Push(New Point(p.X, p.Y + 1))
      17. End If
      18. If RightPixelHaseSameColor(p.X, p.Y, Pointcolor) Then
      19. points.Push(New Point(p.X + 1, p.Y))
      20. End If
      21. If LeftPixelHaseSameColor(p.X, p.Y, Pointcolor) Then
      22. points.Push(New Point(p.X - 1, p.Y))
      23. End If
      24. Loop While points.Count > 0
      25. Return True
      26. End Function


      Nun erstellen wir 2 Subs.
      Die eine ist dazu da, dass sie dem Stift lädt und die andere, dass sie unser Bild "updated":

      VB.NET-Quellcode

      1. Sub UpdateImage()
      2. g = Graphics.FromImage(LastImage)
      3. Me.PictureBox1.Image = LastImage
      4. End Sub
      5. Sub ReloadPen(ByVal PenWd As Single, ByVal CurColor As Color)
      6. PenPoint = New Pen(CurColor, PenWd)
      7. End Sub


      ====================================================
      Die "Mal-Funktion"
      ====================================================
      Spoiler anzeigen

      Die "Mal-Funktion" ist der längste Teil, da er sehr viele If Sätze beinhaltet. Doch diese Funktion ist natürlich auch die wichtigste.
      Ohne ihr könnte man nicht malen.

      Dann fangen wir mal hiermit an:

      Zuerst kümmern wir uns um den PictureBox1_MouseDown Code:
      Hier wird z.B. das Vieleck und das Dreieck gecoded.

      VB.NET-Quellcode

      1. Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
      2. If e.Button = Windows.Forms.MouseButtons.Left Then
      3. If drawing = False Then
      4. startLocation = e.Location
      5. drawing = True
      6. If MultiAngleRadioButton.Checked Then
      7. If TempLocation.X = -1 Then
      8. TempLocation = startLocation
      9. TempLocation2 = startLocation
      10. End If
      11. endLocation = e.Location
      12. g.DrawLine(PenPoint, TempLocation, endLocation)
      13. TempLocation = endLocation
      14. ElseIf TriangleRadioButton.Checked Then
      15. If TempLocation.X = -1 Then
      16. TempLocation = startLocation
      17. TempLocation2 = startLocation
      18. End If
      19. If NumberOfAngle <= 2 Then
      20. endLocation = e.Location
      21. g.DrawLine(PenPoint, TempLocation, endLocation)
      22. TempLocation = endLocation
      23. If NumberOfAngle = 2 Then
      24. g.DrawLine(PenPoint, TempLocation, TempLocation2)
      25. TempLocation = New Point(-1, -1)
      26. NumberOfAngle = 0
      27. Else
      28. NumberOfAngle += 1
      29. End If
      30. End If
      31. End If
      32. End If
      33. ElseIf e.Button = Windows.Forms.MouseButtons.Right Then
      34. If MultiAngleRadioButton.Checked Then
      35. If TempLocation.X <> -1 Then
      36. endLocation = e.Location
      37. g.DrawLine(PenPoint, TempLocation, TempLocation2)
      38. TempLocation = New Point(-1, -1)
      39. End If
      40. End If
      41. End If
      42. End Sub


      Jetzt geht es weiter zum Mouse_move Code:
      Hier wird der Radierer und der Bleistift gecoded.

      VB.NET-Quellcode

      1. Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
      2. If drawing = True Then
      3. If LineRadioButton.Checked Then
      4. g.DrawLine(PenPoint, startLocation.X, startLocation.Y, e.X, e.Y)
      5. startLocation = e.Location
      6. UpdateImage()
      7. ElseIf EraserRadioButton.Checked Then
      8. Dim p As New Pen(Color.White, PenWidth)
      9. g.DrawLine(p, startLocation.X, startLocation.Y, e.X, e.Y)
      10. startLocation = e.Location
      11. UpdateImage()
      12. End If
      13. End If
      14. End Sub


      Jetzt kommen wir zu der längsten Sub(Picturebox1_MouseUp).
      Diese beeinhaltet:
      Das Rechteck
      Den Kreis
      Den Halbkreis
      Nochmal die Füllfunktion
      Die Textfunktion
      [...]

      VB.NET-Quellcode

      1. Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
      2. If drawing Then
      3. If RectangleRadioButton.Checked Then
      4. endLocation = e.Location
      5. Dim s As Point
      6. s.X = endLocation.X - startLocation.X
      7. If s.X < 0 Then
      8. startLocation.X = endLocation.X
      9. End If
      10. s.Y = endLocation.Y - startLocation.Y
      11. If s.Y < 0 Then
      12. startLocation.Y = endLocation.Y
      13. End If
      14. s.X = Math.Abs(s.X)
      15. s.Y = Math.Abs(s.Y)
      16. g.DrawRectangle(PenPoint, New Rectangle(startLocation, s))
      17. ElseIf CircleRadioButton.Checked Then
      18. endLocation = e.Location
      19. Dim s As Point
      20. s.X = endLocation.X - startLocation.X
      21. If s.X < 0 Then
      22. startLocation.X = endLocation.X
      23. End If
      24. s.Y = endLocation.Y - startLocation.Y
      25. If s.Y < 0 Then
      26. startLocation.Y = endLocation.Y
      27. End If
      28. s.X = Math.Abs(s.X)
      29. s.Y = Math.Abs(s.Y)
      30. If s.X > s.Y Then
      31. s.Y = s.X
      32. Else
      33. s.X = s.Y
      34. End If
      35. g.DrawEllipse(PenPoint, New Rectangle(startLocation, s))
      36. ElseIf ArcRadioButton.Checked Then
      37. endLocation = e.Location
      38. Dim s As Point
      39. s.X = endLocation.X - startLocation.X
      40. If s.X < 0 Then
      41. startLocation.X = endLocation.X
      42. End If
      43. s.Y = endLocation.Y - startLocation.Y
      44. If s.Y < 0 Then
      45. startLocation.Y = endLocation.Y
      46. End If
      47. s.X = Math.Abs(s.X)
      48. s.Y = Math.Abs(s.Y)
      49. If s.X > s.Y Then
      50. s.Y = s.X
      51. Else
      52. s.X = s.Y
      53. End If
      54. g.DrawArc(PenPoint, New Rectangle(startLocation, s), 0, -180)
      55. ElseIf ParallelepipedRadioButton.Checked Then
      56. endLocation = e.Location
      57. Dim s As Point
      58. s.X = endLocation.X - startLocation.X
      59. If s.X < 0 Then
      60. Dim tmp As Integer = startLocation.X
      61. startLocation.X = endLocation.X
      62. endLocation.X = tmp
      63. End If
      64. s.Y = endLocation.Y - startLocation.Y
      65. If s.Y < 0 Then
      66. Dim tmp As Integer = startLocation.Y
      67. startLocation.Y = endLocation.Y
      68. endLocation.Y = tmp
      69. End If
      70. s.X = Math.Abs(s.X)
      71. s.Y = Math.Abs(s.Y)
      72. Dim p(3) As Point
      73. p(0) = New Point(startLocation.X + s.X / 5, startLocation.Y)
      74. p(1) = New Point(startLocation.X + s.X, startLocation.Y)
      75. p(2) = New Point(endLocation.X - s.X / 5, endLocation.Y)
      76. p(3) = New Point(endLocation.X - s.X, endLocation.Y)
      77. g.DrawPolygon(PenPoint, p)
      78. ElseIf FillRadioButton.Checked Then
      79. FillRegion(e.X, e.Y, CurrentColor)
      80. ElseIf TextRadioButton.Checked Then
      81. Dim txt As String = TextDrawTextBox.Text
      82. g.DrawString(txt, CurrentFont, New Drawing2D.HatchBrush(Drawing2D.HatchStyle.BackwardDiagonal, CurrentColor), e.X, e.Y)
      83. End If
      84. End If
      85. drawing = False
      86. UpdateImage()
      87. End Sub

      Wichtig ist noch das ihr diesen Code noch hinzufügt, damit das Dreieck funktioniert:

      VB.NET-Quellcode

      1. Private Sub TriangleRadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
      2. TempLocation = New Point(-1, -1)
      3. End Sub


      Teil 2 Folgt.....

      mfg: Gather
      Mfg: Gather
      Private Nachrichten bezüglich VB-Fragen werden Ignoriert!


      Teil 2

      ====================================================
      Stifte + Farben
      ====================================================
      Spoiler anzeigen

      Hier Coden wir die Verschiedenen Stiftartein und die Farben.
      Natürlich kann man noch mehr Stifte hinzufügen ich habe hier als Beispiel aber nur ein paar gemacht.

      Zuerst programmieren wir die 2 ColorButtons. Diese öffnen einfach nur einen ColorDialog und speichern die Farbe dann ab:

      VB.NET-Quellcode

      1. Private Sub ColorButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ColorButton.Click
      2. If ColorDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
      3. CurrentColor = ColorDialog1.Color
      4. Me.ColorButton.BackColor = CurrentColor
      5. ReloadPen(PenWidth, CurrentColor)
      6. End If
      7. End Sub
      8. Private Sub Color2Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Color2Button.Click
      9. If ColorDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
      10. CurrentColor2 = ColorDialog1.Color
      11. Me.Color2Button.BackColor = CurrentColor2
      12. End If
      13. End Sub


      Nun kommen wir zu den 4 verschiedenen Stiftarten.
      3 Stiftarten sind vorgegeben. Mit der 4. kann man die Dicke selber einstellen.

      VB.NET-Quellcode

      1. Private Sub P1RadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles P1RadioButton.CheckedChanged
      2. PenWidth = 1.0F
      3. ReloadPen(PenWidth, CurrentColor)
      4. End Sub
      5. Private Sub P2RadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles P2RadioButton.CheckedChanged
      6. PenWidth = 5.0F
      7. ReloadPen(PenWidth, CurrentColor)
      8. End Sub
      9. Private Sub P3RadioButton_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles P3RadioButton.CheckedChanged
      10. PenWidth = 10.0F
      11. ReloadPen(PenWidth, CurrentColor)
      12. End Sub


      Jetzt kommen wir noch zu unserer eigenen Stiftart:

      VB.NET-Quellcode

      1. Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
      2. If P4RadioButton.Checked = True Then
      3. PenWidth = TrackBar1.Value
      4. ReloadPen(PenWidth, CurrentColor)
      5. End If
      6. End Sub


      ====================================================
      Sonstige Funktionen
      ====================================================
      Spoiler anzeigen

      Für die Sonstigen Funktionen added ein Menu Strip.
      Dort erstellt ihr mal Datei und Image
      Bei Datei erstellt ihr dann noch:
      Löschen
      Neu
      Speichern
      Speichern als...
      Schließen

      Und bei Image Added ihr:
      M1
      M2
      M3
      M4
      S1
      S2
      S3
      S4

      Für das Löschen erstellen wir Wieder einen Neue Sub:

      VB.NET-Quellcode

      1. Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click
      2. ClearScreen()
      3. End Sub
      4. Sub ClearScreen()
      5. g = Graphics.FromImage(LastImage)
      6. g.Clear(Color.White)
      7. UpdateImage()
      8. End Sub


      Nun coden wir den Neu "button":
      Hier wird auch abgefragt ob das Bild zuerst gespeichert werden soll.

      VB.NET-Quellcode

      1. If SavedFileAddress = "" Then
      2. Dim result As Integer = MsgBox("Wollen sie dieses Bild speichern?", MsgBoxStyle.YesNo)
      3. If result = MsgBoxResult.Yes Then
      4. SaveFileDialog1.Filter = "Bitmap File (*.bmp)|*.bmp"
      5. If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
      6. SavedFileAddress = SaveFileDialog1.FileName
      7. LastImage.Save(SavedFileAddress)
      8. Me.Text = SaveFileDialog1.FileName
      9. End If
      10. End If
      11. End If
      12. g.Clear(Color.White)
      13. UpdateImage()
      14. SavedFileAddress = ""


      Also kommen wir gleich weiter zum Speichern:

      VB.NET-Quellcode

      1. If SavedFileAddress = "" Then
      2. SaveFileDialog1.Filter = "Bitmap File (*.bmp)|*.bmp"
      3. If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
      4. SavedFileAddress = SaveFileDialog1.FileName
      5. LastImage.Save(SavedFileAddress)
      6. Me.Text = SaveFileDialog1.FileName
      7. End If
      8. Else
      9. LastImage.Save(SavedFileAddress)
      10. Me.Text = SaveFileDialog1.FileName
      11. End If


      Speichern als...:

      VB.NET-Quellcode

      1. SaveFileDialog1.Filter = "Bitmap File (*.bmp)|*.bmp"
      2. If SaveFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
      3. SavedFileAddress = SaveFileDialog1.FileName
      4. LastImage.Save(SavedFileAddress)
      5. Me.Text = SaveFileDialog1.FileName
      6. End If


      Beim verlassen könnte man wieder eine Abfrage einbaun die Fragt ob das Bild gespeichert werden soll (Wenn man will)

      Zu guter Letzt kommen wir zum Image
      Mit M1-M4 könnt ihr 4 Bilder speichern. Und diese mit S1-S4 laden:
      Der Code dazu ist sehr simpel:

      VB.NET-Quellcode

      1. Private Sub M1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles M1ToolStripMenuItem.Click
      2. M1 = LastImage.Clone()
      3. End Sub
      4. Private Sub M2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles M2ToolStripMenuItem.Click
      5. M2 = LastImage.Clone()
      6. End Sub
      7. Private Sub M3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles M3ToolStripMenuItem.Click
      8. M3 = LastImage.Clone()
      9. End Sub
      10. Private Sub M4ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles M4ToolStripMenuItem.Click
      11. M4 = LastImage.Clone()
      12. End Sub
      13. Private Sub S1ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S1ToolStripMenuItem.Click
      14. LastImage = M1.Clone
      15. UpdateImage()
      16. End Sub
      17. Private Sub S2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S2ToolStripMenuItem.Click
      18. LastImage = M2.Clone
      19. UpdateImage()
      20. End Sub
      21. Private Sub S3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S3ToolStripMenuItem.Click
      22. LastImage = M3.Clone
      23. UpdateImage()
      24. End Sub
      25. Private Sub S4ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles S4ToolStripMenuItem.Click
      26. LastImage = M4.Clone
      27. UpdateImage()
      28. End Sub



      Das wars!^^

      Bei fragen oder Sonstigem Interresse einfach Antworten oder eine PN senden. Ich versuche diese So schnell wie möglich zu beantworten.

      PS: Bedanken nicht vergessen ;D

      Update:
      Beispielprojekt hinzugefügt!
      Dateien
      • Paint-Prog.rar

        (167,89 kB, 991 mal heruntergeladen, zuletzt: )
      Mfg: Gather
      Private Nachrichten bezüglich VB-Fragen werden Ignoriert!


      Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Gather“ ()

      Hast du eh die Subs erstellt? :

      VB.NET-Quellcode

      1. Sub UpdateImage()
      2. g = Graphics.FromImage(LastImage)
      3. Me.PictureBox1.Image = LastImage
      4. End Sub
      5. Sub ReloadPen(ByVal PenWd As Single, ByVal CurColor As Color)
      6. PenPoint = New Pen(CurColor, PenWd)
      7. End Sub
      Mfg: Gather
      Private Nachrichten bezüglich VB-Fragen werden Ignoriert!


      Eigentlich sollte dieses Tutorial alles erklären und man Braucht keinen Beispielcode.

      Weil sonst wird ja nur der Code gedownloadet und man lernt dabei ja nichts. Es geht ja darum dass IHR versteht und lernt wie man ein eigenes "Paint" erstellt.

      ABER: Ich habs jetzt trotzdem noch als Anhang hinzugefügt.
      (Post 2)

      PS: Bedanken nicht vergessen ;D
      Mfg: Gather
      Private Nachrichten bezüglich VB-Fragen werden Ignoriert!


      Update:



      GradientRectAngle

      Dazu benötigt ihr einen RadioButton Namens: GradientRectAngleRadioButton
      (Beim Beispielprojekt ist dieser schon hinzugefügt, er ist nur unten versteckt (+ visible false) also um ihn zu finden müsst ihr einfach die Form ein bisschen größer machen.)

      Nun fügt ihr diesen Code zu MouseUp hinzu:

      VB.NET-Quellcode

      1. ElseIf GradientRectAngleRadioButton.Checked Then
      2. endLocation = e.Location
      3. Dim s As Point
      4. If s.X < 0 Then
      5. startLocation.X = endLocation.X
      6. ElseIf s.X = 0 Then
      7. s.X = 1
      8. End If
      9. s.Y = endLocation.Y - startLocation.Y
      10. If s.Y < 0 Then
      11. startLocation.Y = endLocation.Y
      12. ElseIf s.Y = 0 Then
      13. s.Y = 1
      14. End If
      15. s.X = Math.Abs(s.X)
      16. s.Y = Math.Abs(s.Y)
      17. Dim b As Brush
      18. b = New Drawing2D.LinearGradientBrush(New Rectangle(startLocation, s), CurrentColor, CurrentColor2, Drawing2D.LinearGradientMode.BackwardDiagonal)
      19. g.FillRectangle(b, New Rectangle(startLocation, s))
      Mfg: Gather
      Private Nachrichten bezüglich VB-Fragen werden Ignoriert!


      Würde mir eine weitere Fortsetzung wünschen

      Dieses Tutorial ist echt sehr hilfreich!!! Auch unter VB2013.NET ging es ohne Probleme. Ich würde mir jedoch noch eine Fortsetzung wünschen, da z.B. der Farbeimer stink langsam ist. Außerdem dass man das Rechteck schon sieht, bevor man es loßlässt. Aber das Tutorial ist echt gut gemacht!!!!!!!!!!!!!!!!! :thumbsup: :thumbsup: :thumbsup: :thumbsup: :thumbsup: :thumbsup: :thumbsup: :thumbsup: :thumbsup:
      Ich habe hier leider ein Problem, ich habe es genauso gemacht wie im Tutorial, jedoch wird beim Bleistift die Linie nicht direkt beim Mauszeiger gezeichnet, sondern weiter in Richtung (0;0). Leider bekomme ich das nicht geloest. Bitte helft mir.
      Ich bitte hierbei um geduld, ich werde das Tutorial komplett überarbeiten. Habe aber nicht viel Zeit da ich gerade noch vor meiner mündlichen Matura stehe, danach sollte aber alles verständlicher sein :)
      Mfg: Gather
      Private Nachrichten bezüglich VB-Fragen werden Ignoriert!


      Jo, zu bemängeln wäre zunächst, dass Strict Off geproggt ist, da schleichen sich immer Fehler ein, etwa, dass Points als Sizes verwendet werden und sowas.
      Und der Microsoft.Visualbasic-General-Import gehört imo auch deaktiviert: Grundeinstellungen für Vb.net

      An Useability ist zu bemängeln, dass der User während einer Eingabe oft gar kein Feedback erhält, wie's denn aussehen wird.
      Etwa wenn er ein Rechteck aufzieht, dass dieses zunächst mal der Maus folgt, und erst beim Loslassen in die Bitmap fixiert wird.
      Aber sowas müsste auf OwnerDrawing basieren, also eine ganz andere Grafik-Programmierung als die hiesigen Bitmap-Manipulationen.

      Und minimal sollte man mit [Esc] eine Eingabe auch abbrechen können.
      Schicker wäre natürlich eine Undo-Taste.
      High-End wäre, wenn man Figuren selektieren könnte, und dann verschieben, klonen, färben, löschen etc.. Aber das ist mit Bitmap-Operationen technisch nicht machbar, da müsste man komplett umstellen auf OwnerDrawing - nicht nur die Eingabe.