Hola amigos.
Aquí les comparto una manera (no se si es la mejor) de usar iconos SVG en los formularios claros y oscuros.
Por supuesto no hay que hacer dos iconos distintos para modo claro y oscuro sino alterar el color intrínseco del SVG y luego cargarlo al control.
En este caso le voy a reemplazar el color
"#0066b3" por uno antagónico al tema de escritorio.
Código:
' Gambas class file
Private aIcons As String[]
Public Sub Form_Open()
Dim sFile As String
Dim tob As ToolButton
Dim z As Integer = 40
aIcons = RDir("./var/svg", "*.svg")
pIcons.Children.Clear
For Each sFile In aIcons
tob = New ToolButton(pIcons) As "Tincho"
tob.Tag = File.BaseName(sFile)
tob.h = z
tob.w = z
tob.Picture = Image.FromString(Contrary("./var/svg" &/ sFile, "#0066b3", -1)).Stretch(z, z).Picture
Next
End
'' Replace a color in an svg file with one that contrasts with the background of the desktop theme
Public Function Contrary(sFile As String, sColor As String, iBackground As Integer) As String
Dim sVector As String
Dim iContrast As Integer
Dim sReplace As String
If iBackground = -1 Then
If Application.DarkTheme Then
sVector = Replace(File.Load(sFile), sColor, "#eeeeee")
Else
sVector = Replace(File.Load(sFile), sColor, "#000000")
Endif
Else
iContrast = Color.Invert(iBackground)
sReplace = "#" & CStr(Hex(iContrast, 6))
sVector = Replace(File.Load(sFile), sColor, sReplace)
Endif
Return sVector
End