In Schaubild zoomen

  • VB.NET

Es gibt 2 Antworten in diesem Thema. Der letzte Beitrag () ist von Streamfighter.

    In Schaubild zoomen

    Hallo Leute,

    Ich hab eine Picturebox in die ich Achsen und einen Graphen zeichne.
    Jetzt wollte ich noch hinzufügen, dass immer an die Stelle gezoomt wird, über der sich der Mauszeiger befindet.

    Ich hab den Code geschrieben, funktioniert auch recht gut, nur leider wird immer nur der punkt ganz oben links angezoom.

    Hier ist mal der Code im Mouse_Wheel-Event:


    VB.NET-Quellcode

    1. Dim koordx% = MousePosition.X - Me.Location.X 'Mauskoordinate für Zoom
    2. Dim koordy% = MousePosition.Y - Me.Location.Y
    3. Dim xmaxa# = xmax 'RESET-Werte
    4. Dim xmina# = xmin 'Das ist das Zoomfenster
    5. Dim ymaxa# = ymax
    6. Dim ymina# = ymin
    7. x = xmax - xmin 'Achsenlänge
    8. y = ymax - ymin
    9. If e.Delta > 0 Then 'REIN-zoomen
    10. xmax = x * 0.5 * 0.75 + koordx '0.75 = Zoomfaktor
    11. xmin = -x * 0.5 * 0.75 + koordx
    12. ymax = y * 0.5 * 0.75 + koordy
    13. ymin = -y * 0.5 * 0.75 + koordy
    14. Else 'RAUS-zoomen
    15. xmax = x * 0.75 + koordx '0.75 = beliebiger
    16. ' Faktor
    17. xmin = -x * 0.75 + koordx
    18. ymax = y * 0.75 + koordy
    19. ymin = -y * 0.75 + koordy
    20. End If


    Wäre echt toll wenn ihr mir helfen könntet.