コード例 #1
0
        public void loadXamlTest()
        {
            var root    = Path.GetDirectoryName(typeof(XamlLoadTests).Assembly.Location);
            var dir     = Path.Combine(root, "test_files/xaml");
            var context = XamlReader.GetWpfSchemaContext();

            foreach (var q in Directory.EnumerateFiles(dir))
            {
                Logger.Info($"Loading XAML file {q}");
                var result      = XamlReader.Load(new FileStream(q, FileMode.Open));
                var xt          = context.GetXamlType(result.GetType());
                var logXamlType = new XamlTypeLogger(Logger);
            }
        }
コード例 #2
0
ファイル: App.xaml.cs プロジェクト: rz7d/SmartHunterTest
        void LoadSkin()
        {
            if (ConfigHelper.Main.Values.Debug.UseInternalSkin)
            {
                return;
            }

            var skinFileName = ConfigHelper.Main.Values.SkinFileName;

            if (!File.Exists(FileContainer.GetFullPathFileName(skinFileName)))
            {
                Log.WriteLine($"Failed to load skin file '{skinFileName}'");
                return;
            }

            m_SkinFile.TryChangeFileName(skinFileName);

            try
            {
                ResourceDictionary resourceDictionary = null;

                using (var streamReader = new StreamReader(m_SkinFile.FullPathFileName, Encoding.UTF8))
                {
                    var xmlReaderSettings = new XamlXmlReaderSettings
                    {
                        LocalAssembly = Assembly.GetExecutingAssembly()
                    };

                    using (var xamlReader = new XamlXmlReader(streamReader.BaseStream, XamlReader.GetWpfSchemaContext(), xmlReaderSettings))
                    {
                        resourceDictionary = XamlReader.Load(xamlReader) as ResourceDictionary;
                    }
                }

                if (resourceDictionary != null)
                {
                    Resources.MergedDictionaries.Clear();
                    Resources.MergedDictionaries.Add(resourceDictionary);

                    if (m_Overlay != null)
                    {
                        m_Overlay.RefreshWidgetsLayout();
                    }

                    Log.WriteLine($"{m_SkinFile.FileName} loaded");
                }
            }
            catch (Exception ex)
            {
                Log.WriteException(ex);
            }

            m_LastSkinFileName = skinFileName;
        }