Exemple #1
0
 private void OnLoad(string skinConfigFile)
 {
     try
     {
         SkinConfig skin = XmlHelper.ReadConfig <SkinConfig>(skinConfigFile);
         _formBorder  = new ControlPaintHelper(PaintHelperData.Read(skin.Border, skin, "FormBorder"));
         _formCaption = new ControlPaintHelper(PaintHelperData.Read(skin.Caption.Backgroud, skin, "FormCaption"));
         Size imageSize = PaintHelperData.StringToSize(skin.Caption.NormalButton.IconSize);
         _formCloseIcon          = new ImageStrip(true, imageSize, new Bitmap(skin.Images["CloseIcon"]));
         _formRestoreIcon        = new ImageStrip(true, imageSize, new Bitmap(skin.Images["RestoreIcon"]));
         _formMaximizeIcon       = new ImageStrip(true, imageSize, new Bitmap(skin.Images["MaximizeIcon"]));
         _formMinimizeIcon       = new ImageStrip(true, imageSize, new Bitmap(skin.Images["MinimizeIcon"]));
         _formCaptionButton      = new ControlPaintHelper(PaintHelperData.Read(skin.Caption.NormalButton, skin, "FormCaptionButton"));
         imageSize               = PaintHelperData.StringToSize(skin.Caption.SmallButton.IconSize);
         _formCloseIconSmall     = new ImageStrip(true, imageSize, new Bitmap(skin.Images["CloseIconSmall"]));
         _formRestoreIconSmall   = new ImageStrip(true, imageSize, new Bitmap(skin.Images["RestoreIconSmall"]));
         _formMaximizeIconSmall  = new ImageStrip(true, imageSize, new Bitmap(skin.Images["MaximizeIconSmall"]));
         _formMinimizeIconSmall  = new ImageStrip(true, imageSize, new Bitmap(skin.Images["MinimizeIconSmall"]));
         _formCaptionButtonSmall = new ControlPaintHelper(PaintHelperData.Read(skin.Caption.SmallButton, skin, "FormCaptionButton"));
         _formActiveTitleColor   = PaintHelperData.StringToColor(skin.ActiveCaption);
         _formInactiveTitleColor = PaintHelperData.StringToColor(skin.InactiveCation);
         _formIsTextCentered     = skin.CenterCaption;
     }
     catch (System.Exception ex)
     {
         throw new ApplicationException("Invalid SkinConfig XML", ex);
     }
     _cornerSize = new Size(9, 9);
 }
        //jxz
        public static PaintHelperData Read(ISkinConfig skinConfig, SkinConfig skin, string imageName)
        {
            PaintHelperData data = new PaintHelperData();

            data.Image        = new Bitmap(skin.Images[imageName]);
            data.ImageSize    = StringToSize(skinConfig.ImageSize);
            data.ImagePadding = StringToPadding(skinConfig.ImagePadding);
            return(data);
        }
Exemple #3
0
        /// <summary>
        /// Called when the skin is loaded.
        /// </summary>
        private void OnLoad()
        {
            if (_resourceManager == null)
            {
                return;
            }

            try
            {
                XmlDocument skinDef = new XmlDocument();
                skinDef.LoadXml(_resourceManager.GetString("SkinDefinition"));

                XmlElement elm          = skinDef.DocumentElement;
                XmlNode    form         = elm["Form"];
                XmlNode    captionNode  = form["Caption"];
                XmlNode    normalButton = captionNode["NormalButton"];
                XmlNode    smallButton  = captionNode["SmallButton"];

                //Background
                _formBorder  = new ControlPaintHelper(PaintHelperData.Read(form["Border"], _resourceManager, "FormBorder"));
                _formCaption = new ControlPaintHelper(PaintHelperData.Read(captionNode["Background"], _resourceManager, "FormCaption"));

                //Big Buttons
                Size imageSize = PaintHelperData.StringToSize(normalButton["IconSize"].InnerText);

                _formCloseIcon     = new ImageStrip(true, imageSize, (Bitmap)_resourceManager.GetObject("CloseIcon"));
                _formRestoreIcon   = new ImageStrip(true, imageSize, (Bitmap)_resourceManager.GetObject("RestoreIcon"));
                _formMaximizeIcon  = new ImageStrip(true, imageSize, (Bitmap)_resourceManager.GetObject("MaximizeIcon"));
                _formMinimizeIcon  = new ImageStrip(true, imageSize, (Bitmap)_resourceManager.GetObject("MinimizeIcon"));
                _formCaptionButton = new ControlPaintHelper(PaintHelperData.Read(normalButton, _resourceManager, "FormCaptionButton"));

                //Small Buttons
                imageSize = PaintHelperData.StringToSize(smallButton["IconSize"].InnerText);

                _formCloseIconSmall     = new ImageStrip(true, imageSize, (Bitmap)_resourceManager.GetObject("CloseIconSmall"));
                _formRestoreIconSmall   = new ImageStrip(true, imageSize, (Bitmap)_resourceManager.GetObject("RestoreIconSmall"));
                _formMaximizeIconSmall  = new ImageStrip(true, imageSize, (Bitmap)_resourceManager.GetObject("MaximizeIconSmall"));
                _formMinimizeIconSmall  = new ImageStrip(true, imageSize, (Bitmap)_resourceManager.GetObject("MinimizeIconSmall"));
                _formCaptionButtonSmall = new ControlPaintHelper(PaintHelperData.Read(smallButton, _resourceManager, "FormCaptionButton"));

                //General Infos
                _formActiveTitleColor   = PaintHelperData.StringToColor(form["ActiveCaption"].InnerText);
                _formInactiveTitleColor = PaintHelperData.StringToColor(form["InactiveCaption"].InnerText);
                _formIsTextCentered     = PaintHelperData.StringToBool(form["CenterCaption"].InnerText);
            }
            catch (Exception e)
            {
                throw new ApplicationException("Invalid SkinDefinition XML", e);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ControlPaintHelper"/> class.
        /// </summary>
        /// <param name="data">The data container for this ControlPaintHelper.</param>
        public ControlPaintHelper(PaintHelperData data)
        {
            _data = data;

            Images = new ImageStrip {
                Image = _data.Image, ImageSize = _data.ImageSize
            };


            if (!_data.ContentBounds.IsEmpty)
            {
                return;
            }

            Rectangle rect = new Rectangle(Point.Empty, _data.ImageSize);

            rect.X             += _data.ImagePadding.Left;
            rect.Y             += _data.ImagePadding.Top;
            rect.Width         -= _data.ImagePadding.Horizontal;
            rect.Height        -= _data.ImagePadding.Vertical;
            _data.ContentBounds = rect;
        }
        public static PaintHelperData Read(XmlNode node, ResourceManager resManager, string imageName)
        {
            PaintHelperData data = new PaintHelperData {
                Image = (Bitmap)resManager.GetObject(imageName)
            };

            XmlNode child = node.FirstChild;

            while (child != null)
            {
                switch (child.Name)
                {
                case "ImageSize":
                    data.ImageSize = StringToSize(child.InnerText);
                    break;

                case "ImagePadding":
                    data.ImagePadding = StringToPadding(child.InnerText);
                    break;
                }
                child = child.NextSibling;
            }
            return(data);
        }