Public function fixColor(i As String) as Color
dim cl As Color
If i.Contains(";") AndAlso Char.IsDigit(i(0)) Then
'传入文本包含":"和首个字符是数字
'颜色文本是RGB值
Dim rgbValues As String() = i.Split(";"c)
Dim r As Integer = Integer.Parse(rgbValues(0).Trim())
Dim g As Integer = Integer.Parse(rgbValues(1).Trim())
Dim b As Integer = Integer.Parse(rgbValues(2).Trim())
cl = Color.FromArgb(r, g, b)
Output.Show(cl.Name)
Else
' 不是包含数字
'颜色文本是英文单词类似Red 处理
cl = Color.FromName(i)
Output.Show(cl.Name)
'Output.Show("fixColor颜色是 " & cl.Name, "颜色信息")
End If
return cl
End function
调用
……
If GetConfigValue(k , colorNames(k)) <> colorNames(k) Then
output.Show(k & "颜色修改前是:" & colors(i).Name)
'修改颜色Sub
colors(i) = fixColor(GetConfigValue(k , colorNames(k)) )
output.Show(k & "颜色修改后是:" & colors(i).Name)
output.Show(i)
End If
……