📄 thememanagertemp.cs
字号:
namespace Imps.Client.Pc
{
using Imps.Client.Pc.Theme;
using Imps.Client.Utils;
using System;
using System.Collections.Generic;
using System.Xml;
public class ThemeManagerTemp
{
private static EForm _eform_window;
public static void ApplyTheme(string themeName)
{
string defaultThemeName = themeName;
if (string.IsNullOrEmpty(defaultThemeName))
{
defaultThemeName = ThemeManager.DefaultThemeName;
}
bool flag = false;
Dictionary<string, string>.ValueCollection.Enumerator enumerator = ThemeManager.Themes.get_Values().GetEnumerator();
try
{
while (enumerator.MoveNext())
{
string text2 = enumerator.get_Current();
if (defaultThemeName == text2)
{
flag = true;
goto Label_0053;
}
}
}
finally
{
enumerator.Dispose();
}
Label_0053:
if (!flag)
{
defaultThemeName = ThemeManager.DefaultThemeName;
}
try
{
ThemeManager.ApplyTheme(defaultThemeName);
if (EFormWindow != null)
{
EFormWindow.Clear();
LoadTheme();
EFormWindow.Reset();
}
}
catch (Exception exception)
{
if (defaultThemeName != ThemeManager.DefaultThemeName)
{
ApplyTheme(ThemeManager.DefaultThemeName);
((MainForm) EFormWindow).ShowExceptionMessage(exception.Message + "\n使用默认皮肤");
}
else
{
((MainForm) EFormWindow).ShowExceptionMessage(exception.Message);
ShellHelper.ApplicationExit();
}
}
}
public static bool CanHideAdv(string themeName)
{
ElementPanel panel = new ElementPanel();
panel.NameID = "GroupPanel";
XmlElement elem = FindElementConfig(themeName, "GroupPanel");
if (elem == null)
{
return false;
}
try
{
panel.Style.SetStyle(elem);
}
catch
{
}
return panel.Style.Positions.ContainsKey("HideAdvertisement");
}
public static bool CanHideChanel(string themeName)
{
ElementPanel panel = new ElementPanel();
panel.NameID = "GroupPanel";
XmlElement elem = FindElementConfig(themeName, "GroupPanel");
if (elem == null)
{
return false;
}
try
{
panel.Style.SetStyle(elem);
}
catch
{
}
return panel.Style.Positions.ContainsKey("HideChanel");
}
public static XmlElement FindElementConfig(string id)
{
return FindElementConfig(ThemeManager.ThemeName, id);
}
public static XmlElement FindElementConfig(string themName, string id)
{
try
{
string filename = ThemeManager.GetCfgFullPath(themName);
XmlDocument document = new XmlDocument();
document.Load(filename);
foreach (XmlNode node in document.DocumentElement.ChildNodes)
{
XmlElement element = node as XmlElement;
if (element.Name == "MainWindow")
{
XmlNodeList childNodes = element.ChildNodes;
XmlElement element2 = null;
foreach (XmlNode node2 in childNodes)
{
element2 = node2 as XmlElement;
if ((element2 != null) && (element2.GetAttribute("id") == id))
{
return element2;
}
}
}
}
}
catch
{
}
return null;
}
public static HSL GetHSLFromColorString(string color)
{
switch (color)
{
case "海洋之心":
return new HSL(-17, -1.62, 6.6);
case "玫瑰之吻":
return new HSL(0x91, -7.8, 0.39);
case "粉可爱":
return new HSL(0x79, 1.9, 12.16);
case "动感之橙":
return new HSL(-190, 16.39, 6.27);
case "紫罗兰":
return new HSL(0x38, -43.31, 0.196);
case "森林探险":
return new HSL(-109, 7.98, -7.84);
case "青涩年代":
return new HSL(-35, 0.91, 0);
case "纯黑本色":
return new HSL(0, -100, -20);
}
return new HSL(0, 0, 0);
}
public static void HideChanelAndAdvertisement(bool hideChanel, bool hideAdvertisement)
{
if (EFormWindow != null)
{
((MainForm) EFormWindow).HideChanelAndAdvertisement(hideChanel, hideAdvertisement);
}
}
public static void LoadTheme()
{
string filename = ThemeManager.GetCfgFullPath(ThemeManager.ThemeName);
XmlDocument document = new XmlDocument();
document.Load(filename);
foreach (XmlNode node in document.DocumentElement.ChildNodes)
{
XmlElement elem = node as XmlElement;
if (elem.Name == "MainWindow")
{
EFormWindow.SetTheme(elem);
}
}
}
public static bool CanChangeColor
{
get
{
return ((MainForm) EFormWindow).CanChangeColor;
}
}
public static EForm EFormWindow
{
get
{
return _eform_window;
}
set
{
_eform_window = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -