增加摄像头中控台项目

This commit is contained in:
2025-12-30 10:53:02 +08:00
parent 471b8c50b6
commit de3adf0339
31 changed files with 2736 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace SHH.CameraDashboard
{
public enum ThemeType { Dark, Light }
public static class ThemeManager
{
public static void ChangeTheme(ThemeType theme)
{
var appResources = Application.Current.Resources;
// 1. 找到旧的颜色字典并移除
// 我们通过检查 Source 路径来识别它
ResourceDictionary oldDict = null;
foreach (var dict in appResources.MergedDictionaries)
{
// 只要路径里包含 "Colors." 说明它是我们的皮肤文件
if (dict.Source != null && dict.Source.OriginalString.Contains("Themes/Colors."))
{
oldDict = dict;
break;
}
}
if (oldDict != null)
{
appResources.MergedDictionaries.Remove(oldDict);
}
// 2. 加载新字典
string dictName = theme switch
{
ThemeType.Light => "/Style/Themes/Colors.Light.xaml",
ThemeType.Dark => "/Style/Themes/Colors.Dark.xaml",
_ => "/Style/Themes/Colors.Dark.xaml" // 默认
};
var newDict = new ResourceDictionary
{
Source = new Uri(dictName, UriKind.Relative)
};
// 3. 添加到集合中 (建议加在最前面,或者根据索引位置)
appResources.MergedDictionaries.Add(newDict);
}
}
}