/// <summary>
        /// 获取所有皮肤信息列表
        /// </summary>
        /// <param name="refreshCache">是否根据磁盘目录重新刷新皮肤信息列表</param>
        /// <returns>皮肤信息列表</returns>
        public static IList <DUISkinInfo> GetSkinInfoList(bool refreshCache)
        {
            if (_skinInfoList == null || refreshCache)
            {
                lock (_lockObj)
                {
                    if (_skinInfoList == null || refreshCache)
                    {
                        _skinInfoList = new List <DUISkinInfo>();

                        string tempAppBaseDirectory = CommonFunctions.GetAppBaseDirectory();

                        string tempSkinBaseDirectory = tempAppBaseDirectory.TrimEnd(new char[] { '\\' }) + "\\Skins";
                        foreach (string subDirectoryFullName in Directory.GetDirectories(tempSkinBaseDirectory))
                        {
                            string      subDirectoryName = new DirectoryInfo(subDirectoryFullName).Name;
                            DUISkinInfo newSkinInfo      = new DUISkinInfo(tempAppBaseDirectory, subDirectoryName);
                            if (newSkinInfo.CreateOK)
                            {
                                _skinInfoList.Add(newSkinInfo);
                            }
                        }
                    }
                }
            }
            return(_skinInfoList);
        }
        /// <summary>
        /// 创建指定皮肤唯一名的皮肤管理器,此方法调用后,新皮肤资源将载入,就皮肤资源将被释放
        /// </summary>
        /// <param name="skinName">皮肤唯一名(皮肤根目录名)</param>
        /// <param name="recreate">是否强制重新创建</param>
        /// <returns>皮肤管理器</returns>
        public static DUISkinManager CreateSkinManager(DUISkinInfo skinInfo, bool recreate)
        {
            if (recreate || _instance == null || _instance.CurrentSkinInfo == null ||
                !_instance.CurrentSkinInfo.SkinName.Equals(skinInfo.SkinName))
            {
                lock (_lockObj)
                {
                    //二次判断,以支持多线程
                    if (recreate || _instance == null || _instance.CurrentSkinInfo == null ||
                        !_instance.CurrentSkinInfo.SkinName.Equals(skinInfo.SkinName))
                    {
                        try
                        {
                            DUIForm.FlushBackgroundBitmapDict();
                            _instance = new DUISkinManager(skinInfo);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("换肤时产生异常:" + ex.Message);
                        }

                        BroadCastSkinChangeEvent();
                    }
                }
            }
            return(_instance);
        }
        /// <summary>
        /// 读取皮肤图片资源
        /// </summary>
        /// <param name="skinName">皮肤唯一名(皮肤根目录名)</param>
        /// <param name="xmlDoc">皮肤配置文件XML文档对象</param>
        /// <param name="imageDict">图片资源字典</param>
        private void LoadSkinImageSources(DUISkinInfo skinInfo, XmlDocument xmlDoc, IDictionary <string, Image> imageDict)
        {
            if (xmlDoc == null || imageDict == null)
            {
                return;
            }
            XmlElement skinSettingElement = xmlDoc.DocumentElement;

            if (skinSettingElement.Name != "skinSetting")
            {
                throw new Exception("加载皮肤目录" + skinInfo.SkinName + "中的皮肤配置文件出错,根标签不合法!");
            }


            if (!Directory.Exists(skinInfo.SkinImagesDirectory))
            {
                throw new Exception("皮肤目录" + skinInfo.SkinName + "\\images不存在,无法加载皮肤资源!");
            }

            foreach (XmlNode childNode in skinSettingElement.ChildNodes)
            {
                if (childNode.Name == "imageSources")
                {
                    foreach (XmlNode imageNode in childNode.ChildNodes)
                    {
                        if (imageNode.Name == "image")
                        {
                            string imageName     = imageNode.Attributes["name"] != null?imageNode.Attributes["name"].Value:null;
                            string imageFileName = imageNode.Attributes["fileName"] != null ? imageNode.Attributes["fileName"].Value : null;
                            if (string.IsNullOrEmpty(imageName) || string.IsNullOrEmpty(imageFileName))
                            {
                                continue;
                            }

                            string imageFileFullName = skinInfo.SkinImagesDirectory + "\\" + imageFileName;
                            if (!File.Exists(imageFileFullName))
                            {
                                throw new Exception("加载皮肤资源时找不到文件" + imageFileFullName + "!");
                            }

                            Image imageSource = CommonFunctions.LoadImageFromFile(imageFileFullName);
                            if (!imageDict.ContainsKey(imageName))
                            {
                                imageDict.Add(imageName, imageSource);
                            }
                            else
                            {
                                imageDict[imageName] = imageSource;
                            }
                        }
                    }
                }
            }
        }
        private DUISkinManager(DUISkinInfo skinInfo)
        {
            if (!Directory.Exists(skinInfo.SkinBaseDirectory))
            {
                throw new Exception("未能找到皮肤根目录Skins[" + skinInfo.SkinBaseDirectory + "],不能加载皮肤资源,请重新安装程序!");
            }
            if (!Directory.Exists(skinInfo.SkinDirectory))
            {
                throw new Exception("未能找到皮肤目录" + skinInfo.SkinName + ",不能加载皮肤资源,请重新安装程序!");
            }
            if (!File.Exists(skinInfo.SkinSettingFileName))
            {
                throw new Exception("未能找到皮肤目录" + skinInfo.SkinName + "下的皮肤配置文件SkinSettings.config,不能加载皮肤资源,请重新安装程序!");
            }


            //载入皮肤配置文件
            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(skinInfo.SkinSettingFileName);

            //读取皮肤图片资源
            IDictionary <string, Image> tempSkinImageDict = new Dictionary <string, Image>();

            LoadSkinImageSources(skinInfo, xmlDoc, tempSkinImageDict);

            //读取皮肤参数配置
            IDictionary <string, string> tempSkinParametersDict = new Dictionary <string, string>();

            LoadSkinParamters(skinInfo, xmlDoc, tempSkinParametersDict);

            Dictionary <string, DUIFont> tempFontsDict = new Dictionary <string, DUIFont>();
            IDictionary <Type, IDictionary <string, IDUIStyle> > tempSkinStylesDict
                = new Dictionary <Type, IDictionary <string, IDUIStyle> >();

            LoadSkinStyles(skinInfo, xmlDoc, tempFontsDict, tempSkinStylesDict);

            IDictionary <string, DUILayout> tempSkinLayoutsDict = new Dictionary <string, DUILayout>();

            LoadSkinLayouts(skinInfo, tempSkinLayoutsDict);

            //---------------------------------------
            //刷新当前皮肤基础参数值
            this._currentSkinInfo = skinInfo;

            this._imageSources = tempSkinImageDict;
            this._parameters   = tempSkinParametersDict;
            this._fonts        = tempFontsDict;
            this._styles       = tempSkinStylesDict;
            this._layouts      = tempSkinLayoutsDict;
            this._formLayouts  = new Dictionary <Guid, IDictionary <string, DUILayout> >();
        }
        /// <summary>
        /// 读取皮肤参数配置
        /// </summary>
        /// <param name="skinName">皮肤唯一名(皮肤根目录名)</param>
        /// <param name="parameterDict">皮肤参数字典</param>
        private void LoadSkinLayouts(DUISkinInfo skinInfo, IDictionary <string, DUILayout> layoutDict)
        {
            if (layoutDict == null)
            {
                return;
            }
            foreach (string layoutFileName in Directory.GetFiles(skinInfo.SkinLayoutDirectory))
            {
                FileInfo fileInfo = new FileInfo(layoutFileName);
                if (fileInfo.Extension.ToLower().Equals(".layout"))
                {
                    DUILayout newLayout = new DUILayout(layoutFileName);

                    layoutDict.Add(newLayout.Name, newLayout);
                }
            }
        }
        /// <summary>
        /// 读取皮肤参数配置
        /// </summary>
        /// <param name="skinName">皮肤唯一名(皮肤根目录名)</param>
        /// <param name="xmlDoc">皮肤配置文件XML文档对象</param>
        /// <param name="parameterDict">皮肤参数字典</param>
        private void LoadSkinParamters(DUISkinInfo skinInfo, XmlDocument xmlDoc, IDictionary <string, string> parameterDict)
        {
            if (xmlDoc == null || parameterDict == null)
            {
                return;
            }
            XmlElement skinSettingElement = xmlDoc.DocumentElement;

            if (skinSettingElement.Name != "skinSetting")
            {
                throw new Exception("加载皮肤目录" + skinInfo.SkinName + "中的皮肤配置文件出错,根标签不合法!");
            }

            foreach (XmlNode childNode in skinSettingElement.ChildNodes)
            {
                if (childNode.Name == "skinParameters")
                {
                    foreach (XmlNode imageNode in childNode.ChildNodes)
                    {
                        if (imageNode.Name == "parameter")
                        {
                            string parameterName  = imageNode.Attributes["name"] != null ? imageNode.Attributes["name"].Value : null;
                            string parameterValue = imageNode.Attributes["value"] != null ? imageNode.Attributes["value"].Value : null;
                            if (string.IsNullOrEmpty(parameterName) || string.IsNullOrEmpty(parameterValue))
                            {
                                continue;
                            }

                            if (!parameterDict.ContainsKey(parameterName))
                            {
                                parameterDict.Add(parameterName, parameterValue);
                            }
                            else
                            {
                                parameterDict[parameterName] = parameterValue;
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// 读取皮肤控件样式配置
        /// </summary>
        /// <param name="skinName">当前皮肤信息对象</param>
        /// <param name="xmlDoc">皮肤配置文件XML文档对象</param>
        /// <param name="parameterDict">皮肤控件样式字典</param>
        private void LoadSkinStyles(DUISkinInfo skinInfo, XmlDocument xmlDoc,
                                    IDictionary <string, DUIFont> fontDict, IDictionary <Type, IDictionary <string, IDUIStyle> > styleDict)
        {
            if (xmlDoc == null || fontDict == null || styleDict == null)
            {
                return;
            }
            XmlElement skinSettingElement = xmlDoc.DocumentElement;

            if (skinSettingElement.Name != "skinSetting")
            {
                throw new Exception("加载皮肤目录" + skinInfo.SkinName + "中的皮肤配置文件出错,根标签不合法!");
            }

            //遍历所有二级节点
            foreach (XmlNode childNode in skinSettingElement.ChildNodes)
            {
                //处理样式节点
                if (childNode.Name == "styles")
                {
                    foreach (XmlNode typeStyleNode in childNode.ChildNodes)
                    {
                        //全局Font
                        if (typeStyleNode.Name == "fonts")
                        {
                            #region 全局Font处理
                            foreach (XmlNode fontNode in typeStyleNode.ChildNodes)
                            {
                                if (fontNode.Name == "font")
                                {
                                    DUIFont newFont = new DUIFont(fontNode);


                                    if (fontDict.ContainsKey(newFont.Name))
                                    {
                                        fontDict[newFont.Name] = newFont;
                                    }
                                    else
                                    {
                                        fontDict.Add(newFont.Name, newFont);
                                    }
                                }
                            }
                            #endregion
                        }
                        //Label样式
                        else if (typeStyleNode.Name == "labelStyles")
                        {
                            #region labelStyles处理
                            foreach (XmlNode lableStyleNode in typeStyleNode.ChildNodes)
                            {
                                if (lableStyleNode.Name == "labelStyle")
                                {
                                    LabelDUIStyle labelDUIStyle = new LabelDUIStyle(lableStyleNode);

                                    IDictionary <string, IDUIStyle> tmpDUIStyleDict = null;
                                    if (styleDict.ContainsKey(typeof(DUIStyleLabel)))
                                    {
                                        tmpDUIStyleDict = styleDict[typeof(DUIStyleLabel)];
                                    }
                                    else
                                    {
                                        tmpDUIStyleDict = new Dictionary <string, IDUIStyle>();
                                        styleDict.Add(typeof(DUIStyleLabel), tmpDUIStyleDict);
                                    }

                                    if (tmpDUIStyleDict.ContainsKey(labelDUIStyle.Name))
                                    {
                                        tmpDUIStyleDict[labelDUIStyle.Name] = labelDUIStyle;
                                    }
                                    else
                                    {
                                        tmpDUIStyleDict.Add(labelDUIStyle.Name, labelDUIStyle);
                                    }
                                }
                            }
                            #endregion
                        }
                        //TextBox样式
                        else if (typeStyleNode.Name == "textboxStyles")
                        {
                            #region textboxStyles处理
                            foreach (XmlNode textboxStyleNode in typeStyleNode.ChildNodes)
                            {
                                if (textboxStyleNode.Name == "textboxStyle")
                                {
                                    TextBoxDUIStyle txtboxDUIStyle = new TextBoxDUIStyle(textboxStyleNode);

                                    IDictionary <string, IDUIStyle> tmpDUIStyleDict = null;
                                    if (styleDict.ContainsKey(typeof(DUIStyleTextBox)))
                                    {
                                        tmpDUIStyleDict = styleDict[typeof(DUIStyleTextBox)];
                                    }
                                    else
                                    {
                                        tmpDUIStyleDict = new Dictionary <string, IDUIStyle>();
                                        styleDict.Add(typeof(DUIStyleTextBox), tmpDUIStyleDict);
                                    }

                                    if (tmpDUIStyleDict.ContainsKey(txtboxDUIStyle.Name))
                                    {
                                        tmpDUIStyleDict[txtboxDUIStyle.Name] = txtboxDUIStyle;
                                    }
                                    else
                                    {
                                        tmpDUIStyleDict.Add(txtboxDUIStyle.Name, txtboxDUIStyle);
                                    }
                                }
                            }
                            #endregion
                        }
                        else if (typeStyleNode.Name == "buttonStyles")
                        {
                            #region buttonStyles处理
                            foreach (XmlNode buttonStyleNode in typeStyleNode.ChildNodes)
                            {
                                if (buttonStyleNode.Name == "buttonStyle")
                                {
                                    ButtonDUIStyle buttonDUIStyle = new ButtonDUIStyle(buttonStyleNode);

                                    IDictionary <string, IDUIStyle> tmpDUIStyleDict = null;
                                    if (styleDict.ContainsKey(typeof(DUIStyleButton)))
                                    {
                                        tmpDUIStyleDict = styleDict[typeof(DUIStyleButton)];
                                    }
                                    else
                                    {
                                        tmpDUIStyleDict = new Dictionary <string, IDUIStyle>();
                                        styleDict.Add(typeof(DUIStyleButton), tmpDUIStyleDict);
                                    }

                                    if (tmpDUIStyleDict.ContainsKey(buttonDUIStyle.Name))
                                    {
                                        tmpDUIStyleDict[buttonDUIStyle.Name] = buttonDUIStyle;
                                    }
                                    else
                                    {
                                        tmpDUIStyleDict.Add(buttonDUIStyle.Name, buttonDUIStyle);
                                    }
                                }
                            }
                            #endregion
                        }
                        else
                        {
                        }
                    }
                }
            }
        }