private DUILayoutTitleInfo(DUILayoutTitleInfo layoutTitleInfo)
 {
     this._iconSourceName  = layoutTitleInfo._iconSourceName;
     this._showIcon        = layoutTitleInfo._showIcon;
     this._text            = layoutTitleInfo._text;
     this._titleAreaHeight = layoutTitleInfo._titleAreaHeight;
     this._titleAreaOffset = layoutTitleInfo._titleAreaOffset;
     this._fontName        = layoutTitleInfo._fontName;
 }
예제 #2
0
        /// <summary>
        /// 供克隆函数调用的私有构造函数
        /// </summary>
        /// <param name="name"></param>
        /// <param name="transparentKey"></param>
        /// <param name="captionHeight"></param>
        /// <param name="normalBackgroundInfo"></param>
        /// <param name="maximizedbackgroundInfo"></param>
        /// <param name="imageManager"></param>
        /// <param name="buttonManager"></param>
        private DUILayout(string name, Color transparentKey, int captionHeight, DUILayoutTitleInfo titleInfo,
                          DUIBackgroundInfo normalBackgroundInfo, DUIBackgroundInfo maximizedbackgroundInfo,
                          DUIImageManager imageManager, DUIButtonManager buttonManager)
        {
            this._name                    = name;
            this._transparentKey          = transparentKey;
            this._captionHeight           = captionHeight;
            this._titleInfo               = (DUILayoutTitleInfo)titleInfo.Clone();
            this._normalBackgroundInfo    = (DUIBackgroundInfo)normalBackgroundInfo.Clone();
            this._maximizedbackgroundInfo = (DUIBackgroundInfo)maximizedbackgroundInfo.Clone();

            this._imageManager             = (DUIImageManager)imageManager.Clone();
            this._imageManager.OwnerLayout = this;

            this._buttonManager             = (DUIButtonManager)buttonManager.Clone();
            this._buttonManager.OwnerLayout = this;
        }
예제 #3
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="layoutFileName">布局文件全名称</param>
        public DUILayout(string layoutFileName)
        {
            FileInfo fileInfo = new FileInfo(layoutFileName);

            this._name = fileInfo.Name;

            XmlDocument xmlDoc = new XmlDocument();

            xmlDoc.Load(layoutFileName);

            XmlElement layoutElement = xmlDoc.DocumentElement;

            //--------------------------------------------------
            //读取窗口贴图透明色设置
            string transparentKeyString = layoutElement.Attributes["transparentKey"] != null ? layoutElement.Attributes["transparentKey"].Value : null;

            if (string.IsNullOrEmpty(transparentKeyString))
            {
                throw new Exception("当前皮肤布局" + this._name + "未指定透明色!");
            }
            else
            {
                string[] tempSplitString = transparentKeyString.Split(new char[] { ',' });
                if (tempSplitString.Length != 3)
                {
                    throw new Exception("当前皮肤布局" + this._name + "透明色配置信息不合法!");
                }
                else
                {
                    this._transparentKey = Color.FromArgb(
                        Convert.ToInt32(tempSplitString[0]), Convert.ToInt32(tempSplitString[1]), Convert.ToInt32(tempSplitString[2]));
                }
            }
            //--------------------------------------------------
            //读取窗口从上边框开始,可以点击移动窗口的区域高度
            string captionHeightString = layoutElement.Attributes["captionHeight"] != null ? layoutElement.Attributes["captionHeight"].Value : null;

            if (string.IsNullOrEmpty(captionHeightString))
            {
                this._captionHeight = 0;
            }
            else
            {
                try
                {
                    this._captionHeight = Convert.ToInt32(captionHeightString);
                }
                catch
                {
                    this._captionHeight = 0;
                }
            }
            //--------------------------------------------------
            //读取布局标题区配置
            XmlNodeList titleInfoList = layoutElement.GetElementsByTagName("title");

            if (titleInfoList == null || titleInfoList.Count == 0)
            {
                _titleInfo = new DUILayoutTitleInfo(null);
            }
            else
            {
                if (titleInfoList.Count != 1)
                {
                    //存在多个title节点,创建DUILayoutTitleInfo对象失败
                    throw new Exception("当前皮肤布局" + this._name + "中,title配置不存在或不唯一!");
                }
                else
                {
                    _titleInfo = new DUILayoutTitleInfo(titleInfoList[0]);
                }
            }

            //--------------------------------------------------
            //读取布局普通尺寸背景信息
            XmlNodeList normalBackgroundList = layoutElement.GetElementsByTagName("background-normal");

            if (normalBackgroundList == null || normalBackgroundList.Count != 1)
            {
                //存在多个background-normal,创建Layout对象失败
                throw new Exception("当前皮肤布局" + this._name + "中,background-normal配置不存在或不唯一!");
            }
            _normalBackgroundInfo = new DUIBackgroundInfo(
                normalBackgroundList[0].Attributes["sourceName"] != null ? normalBackgroundList[0].Attributes["sourceName"].Value : null,
                normalBackgroundList[0].Attributes["topLeftPoint"] != null ? normalBackgroundList[0].Attributes["topLeftPoint"].Value : null,
                normalBackgroundList[0].Attributes["topRightPoint"] != null ? normalBackgroundList[0].Attributes["topRightPoint"].Value : null,
                normalBackgroundList[0].Attributes["bottomLeftPoint"] != null ? normalBackgroundList[0].Attributes["bottomLeftPoint"].Value : null,
                normalBackgroundList[0].Attributes["bottomRightPoint"] != null ? normalBackgroundList[0].Attributes["bottomRightPoint"].Value : null);
            //--------------------------------------------------
            //读取布局最大化尺寸背景信息
            XmlNodeList maximizedBackgroundList = layoutElement.GetElementsByTagName("background-maximized");

            if (maximizedBackgroundList == null || maximizedBackgroundList.Count != 1)
            {
                //存在多个background-normal,创建Layout对象失败
                throw new Exception("当前皮肤布局" + this._name + "中,background-maximized配置不存在或不唯一!");
            }
            _maximizedbackgroundInfo = new DUIBackgroundInfo(
                maximizedBackgroundList[0].Attributes["sourceName"] != null ? maximizedBackgroundList[0].Attributes["sourceName"].Value : null,
                maximizedBackgroundList[0].Attributes["topLeftPoint"] != null ? maximizedBackgroundList[0].Attributes["topLeftPoint"].Value : null,
                maximizedBackgroundList[0].Attributes["topRightPoint"] != null ? maximizedBackgroundList[0].Attributes["topRightPoint"].Value : null,
                maximizedBackgroundList[0].Attributes["bottomLeftPoint"] != null ? maximizedBackgroundList[0].Attributes["bottomLeftPoint"].Value : null,
                maximizedBackgroundList[0].Attributes["bottomRightPoint"] != null ? maximizedBackgroundList[0].Attributes["bottomRightPoint"].Value : null);
            //--------------------------------------------------
            //初始化背景图片管理器对象
            _imageManager = new DUIImageManager(this);
            _imageManager.LoadDUIImageFromXml(xmlDoc);

            //--------------------------------------------------
            //初始化按钮管理器对象
            _buttonManager = new DUIButtonManager(this);
            _buttonManager.LoadButtonFromXml(xmlDoc);
        }
        /// <summary>
        /// 克隆函数
        /// </summary>
        /// <returns>克隆后的新DUILayoutTitleInfo对象</returns>
        public object Clone()
        {
            DUILayoutTitleInfo newLayoutTitleInfo = new DUILayoutTitleInfo(this);

            return(newLayoutTitleInfo);
        }