Fontstyle umkehren

  • VB.NET

    Fontstyle umkehren

    Hi
    ich habe momentan Probleme mit einer Umkehrung der Fontstyles:

    VB.NET-Quellcode

    1. Public Function InverseFontStyle(ByVal DefaultFontStyle As FontStyle, ByVal ParamArray FontStylesToInverse() As FontStyle) As Integer
    2. 'Regular = 0
    3. 'Bold = 1
    4. 'Italic = 2
    5. 'Underline = 4
    6. 'Strikeout = 8
    7. Dim fontstyle As Integer = DefaultFontStyle
    8. For Each Style As FontStyle In FontStylesToInverse
    9. If Style = Drawing.FontStyle.Bold Then
    10. If DefaultFontStyle = Drawing.FontStyle.Bold Then
    11. fontstyle -= 1
    12. Else
    13. fontstyle += 1
    14. End If
    15. ElseIf Style = Drawing.FontStyle.Italic Then
    16. If DefaultFontStyle = Drawing.FontStyle.Italic Then
    17. fontstyle -= 2
    18. Else
    19. fontstyle += 2
    20. End If
    21. ElseIf Style = Drawing.FontStyle.Underline Then
    22. If DefaultFontStyle = Drawing.FontStyle.Underline Then
    23. fontstyle -= 4
    24. Else
    25. fontstyle += 4
    26. End If
    27. ElseIf Style = Drawing.FontStyle.Strikeout Then
    28. If DefaultFontStyle = Drawing.FontStyle.Strikeout Then
    29. fontstyle -= 8
    30. Else
    31. fontstyle += 8
    32. End If
    33. ElseIf Style = Drawing.FontStyle.Regular Then
    34. If fontstyle = 15 Then
    35. fontstyle = 0
    36. Else
    37. fontstyle = 15
    38. End If
    39. End If
    40. Next
    41. Return fontstyle
    42. End Function


    Das funktioniert alles wunderbar, wenn mans einschaltet. Aber wenn mans wieder abschalten will, wird der Font einfach ganz umgekehrt... :cursing: (ist nicht Regular)
    Kann mir irgendwer voneuch sagen was ich falsch mache? ^^

    Gruß
    ~blaze~