diff --git a/src/OGFrp.Main/About/AboutBox.xaml.vb b/src/OGFrp.Main/About/AboutBox.xaml.vb index c42abfd..38ee918 100644 --- a/src/OGFrp.Main/About/AboutBox.xaml.vb +++ b/src/OGFrp.Main/About/AboutBox.xaml.vb @@ -1,4 +1,10 @@ Public Class AboutBox + + Public Sub SetTheme(Theme As Theme) + Me.Background = Theme.contentBackground + Me.Foreground = Theme.contentForeground + End Sub + Private Sub Lb_OpenSource_MouseDown(sender As Object, e As MouseButtonEventArgs) Handles Lb_OpenSource.MouseDown Process.Start("https://github.com/MarchStudio/OGFrp") End Sub diff --git a/src/OGFrp.Main/MainPanel.xaml.vb b/src/OGFrp.Main/MainPanel.xaml.vb index fb58033..3976af6 100644 --- a/src/OGFrp.Main/MainPanel.xaml.vb +++ b/src/OGFrp.Main/MainPanel.xaml.vb @@ -10,6 +10,7 @@ Public Class MainPanel Public Assets As AssetModel Public Config As Config + Public Theme As Theme Dim SelectedBg As Brush diff --git a/src/OGFrp.Main/MainWindow.xaml b/src/OGFrp.Main/MainWindow.xaml index 6534a53..54298c2 100644 --- a/src/OGFrp.Main/MainWindow.xaml +++ b/src/OGFrp.Main/MainWindow.xaml @@ -40,10 +40,10 @@ - + - + diff --git a/src/OGFrp.Main/MainWindow.xaml.vb b/src/OGFrp.Main/MainWindow.xaml.vb index 5e91a9c..b83d86a 100644 --- a/src/OGFrp.Main/MainWindow.xaml.vb +++ b/src/OGFrp.Main/MainWindow.xaml.vb @@ -42,18 +42,25 @@ Class MainWindow Dim ac As New Assets() 'Temp用ac Dim Assets As AssetModel Dim Config As New Config() + Dim Theme As New Theme() Private Sub _init_() Handles Me.Loaded + Me.Theme.GetSystemTheme() Config.ReadConfig() Me.Assets = ac.SearchAsset(Config.Lang.Val) Me.LoginBox.Assets = Me.Assets Me.LoginBox.Visibility = Visibility.Visible Me.LoginBox.Config = Me.Config Me.LoginBox._init_() - Me.txtTitle.Foreground = Brushes.Black + Me.txtTitle.Foreground = Me.Theme.titleActiveTextColor Me.txtTitle.Text = Assets.Welcome Me.MainPanel.Assets = Me.Assets Me.MainPanel.ctm_SettingsPage.Config = Me.Config + Me.MainPanel.Theme = Me.Theme + Me.bd_titlefillL.Background = Me.Theme.titleActiveColor + Me.bd_titlefillR.Background = Me.Theme.titleActiveColor + Me.Bt_Close.Foreground = Me.Theme.titleActiveTextColor + Me.Bt_Min.Foreground = Me.Theme.titleActiveTextColor End Sub Private Sub MainWindow_Closing(sender As Object, e As CancelEventArgs) Handles Me.Closing @@ -74,13 +81,21 @@ Class MainWindow Private Sub MainWindow_Activated(sender As Object, e As EventArgs) Handles Me.Activated If Me.bd_titlefillL.Visibility = Visibility.Visible Then - Me.txtTitle.Foreground = Brushes.Black + Me.txtTitle.Foreground = Me.Theme.titleActiveTextColor Else Me.txtTitle.Foreground = Brushes.White End If + Me.bd_titlefillL.Background = Me.Theme.titleActiveColor + Me.bd_titlefillR.Background = Me.Theme.titleActiveColor + Me.Bt_Close.Foreground = Me.Theme.titleActiveTextColor + Me.Bt_Min.Foreground = Me.Theme.titleActiveTextColor End Sub Private Sub MainWindow_Deactivated(sender As Object, e As EventArgs) Handles Me.Deactivated - Me.txtTitle.Foreground = Brushes.DarkGray + Me.txtTitle.Foreground = Me.Theme.titleInactiveTextColor + Me.bd_titlefillL.Background = Me.Theme.titleInactiveColor + Me.bd_titlefillR.Background = Me.Theme.titleInactiveColor + Me.Bt_Close.Foreground = Me.Theme.titleInactiveTextColor + Me.Bt_Min.Foreground = Me.Theme.titleInactiveTextColor End Sub End Class diff --git a/src/OGFrp.Main/OGFrp.Main.vbproj b/src/OGFrp.Main/OGFrp.Main.vbproj index 0f5dc30..23f7c07 100644 --- a/src/OGFrp.Main/OGFrp.Main.vbproj +++ b/src/OGFrp.Main/OGFrp.Main.vbproj @@ -136,6 +136,7 @@ SettingsPage.xaml + UserDisplay.xaml diff --git a/src/OGFrp.Main/Theme/Theme.vb b/src/OGFrp.Main/Theme/Theme.vb new file mode 100644 index 0000000..02fe944 --- /dev/null +++ b/src/OGFrp.Main/Theme/Theme.vb @@ -0,0 +1,50 @@ +Public Class Theme + + Public titleActiveColor As Brush + Public titleInactiveColor As Brush + Public titleActiveTextColor As Brush + Public titleInactiveTextColor As Brush + Public contentBackground As Brush + Public contentForeground As Brush + + Public Sub New() + titleActiveColor = New SolidColorBrush(Color.FromArgb(204, 255, 255, 255)) + titleInactiveColor = New SolidColorBrush(Color.FromArgb(255, 255, 255, 255)) + titleActiveTextColor = Brushes.Black + titleInactiveTextColor = Brushes.Gray + contentBackground = New SolidColorBrush(Color.FromArgb(204, 255, 255, 255)) + contentForeground = Brushes.Black + End Sub + + Public Sub CalcBorW(ByVal red As Integer, ByVal green As Integer, ByVal blue As Integer) + If (red * 0.299 + green * 0.587 + blue * 0.114) > 186 Then + Me.titleActiveTextColor = Brushes.Black + Else + Me.titleActiveTextColor = Brushes.White + End If + End Sub + + Public Sub GetSystemTheme() + If Environment.OSVersion.Version.Major = 6 Then + If Environment.OSVersion.Version.Minor = 1 Or Environment.OSVersion.Version.Minor = 0 Then '判断Windows 7或Vista + 'PASS + Else 'Windows 8及以上版本的Win系统 + Dim FormTitleColor As Boolean = My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorPrevalence", True) + Dim A As Integer = 204 + Dim R As Integer = 255 + Dim G As Integer = 255 + Dim B As Integer = 255 + If FormTitleColor Then + Dim FormColorSource As String = Hex(My.Computer.Registry.GetValue("HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM", "ColorizationColor", Int32.Parse("FF000000", Globalization.NumberStyles.HexNumber))) + A = 255 + R = Int32.Parse(FormColorSource.Substring(2, 2), Globalization.NumberStyles.HexNumber) + G = Int32.Parse(FormColorSource.Substring(4, 2), Globalization.NumberStyles.HexNumber) + B = Int32.Parse(FormColorSource.Substring(6, 2), Globalization.NumberStyles.HexNumber) + End If + Me.titleActiveColor = New SolidColorBrush(Color.FromArgb(A, R, G, B)) + CalcBorW(R, G, B) '设置标题栏字体颜色为黑色或白色 + End If + End If + End Sub + +End Class