60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Diagnostics;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Windows;
|
|||
|
|
using NeuWPF;
|
|||
|
|
|
|||
|
|
namespace NeuWPFTest
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Interaction logic for App.xaml
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class App : Application
|
|||
|
|
{
|
|||
|
|
//protected override void OnStartup(StartupEventArgs e)
|
|||
|
|
//{
|
|||
|
|
// base.OnStartup(e);
|
|||
|
|
|
|||
|
|
// // 在应用启动时,调用方法打印所有已加载的资源字典
|
|||
|
|
// Debug.WriteLine("==========================================================");
|
|||
|
|
// Debug.WriteLine(" Dumping All Loaded Application Resource Dictionaries... ");
|
|||
|
|
// Debug.WriteLine("==========================================================");
|
|||
|
|
|
|||
|
|
// // 从最顶层的 Application.Resources 开始遍历
|
|||
|
|
// DumpResourceDictionaries(Application.Current.Resources, 0);
|
|||
|
|
|
|||
|
|
// Debug.WriteLine("====================== End of Dump =======================");
|
|||
|
|
|
|||
|
|
//}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 递归打印资源字典及其合并的子字典。
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="dictionary">要检查的资源字典。</param>
|
|||
|
|
/// <param name="indentationLevel">缩进级别,用于格式化输出。</param>
|
|||
|
|
private void DumpResourceDictionaries(ResourceDictionary dictionary, int indentationLevel)
|
|||
|
|
{
|
|||
|
|
// 创建缩进字符串,使输出更具可读性
|
|||
|
|
var indent = new string(' ', indentationLevel * 4);
|
|||
|
|
|
|||
|
|
// 打印当前字典的来源(Source URI)
|
|||
|
|
// App.xaml 中直接定义的根 ResourceDictionary 没有 Source,所以需要判断
|
|||
|
|
if (dictionary.Source != null)
|
|||
|
|
{
|
|||
|
|
Debug.WriteLine($"{indent}-> Source: {dictionary.Source}");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
// 这是根字典或一个内联定义的字典
|
|||
|
|
Debug.WriteLine($"{indent}[Root or Inline Dictionary]");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 递归遍历所有合并的字典
|
|||
|
|
foreach (var mergedDict in dictionary.MergedDictionaries)
|
|||
|
|
{
|
|||
|
|
DumpResourceDictionaries(mergedDict, indentationLevel + 1);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|