Пример #1
0
        /// <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;
        }
Пример #2
0
        /// <summary>
        /// Called when the skin is loaded.
        /// </summary>
        public override void OnLoad()
        {
            try
            {
                LoadResourceManager();
                XmlDocument skinDef = new XmlDocument();
                skinDef.LoadXml(_currentManager.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"], _currentManager, "FormBorder"));
                _formCaption = new ControlPaintHelper(PaintHelperData.Read(captionNode["Background"], _currentManager, "FormCaption"));

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

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

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

                _formCloseIconSmall     = new ImageStrip(true, imageSize, (Bitmap)_currentManager.GetObject("CloseIconSmall"));
                _formRestoreIconSmall   = new ImageStrip(true, imageSize, (Bitmap)_currentManager.GetObject("RestoreIconSmall"));
                _formMaximizeIconSmall  = new ImageStrip(true, imageSize, (Bitmap)_currentManager.GetObject("MaximizeIconSmall"));
                _formMinimizeIconSmall  = new ImageStrip(true, imageSize, (Bitmap)_currentManager.GetObject("MinimizeIconSmall"));
                _formCaptionButtonSmall = new ControlPaintHelper(PaintHelperData.Read(smallButton, _currentManager, "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);
            }
        }
Пример #3
0
        /// <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;
        }
Пример #4
0
        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);
        }
Пример #5
0
        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;
        }