Esempio n. 1
0
        public GraphicsPath GetPath()
        {
            if (!bKeyColor)
            {
                if (destRect.Width > 0 && destRect.Height > 0)
                {
                    GraphicsPath path = new GraphicsPath();
                    path.AddRectangle(destRect);
                    return(path);
                }
            }
            if (bitmapRectangle != destRect)
            {
                if (pBitmapPath != null)
                {
                    pBitmapPath.Dispose();
                }
                pBitmapPath = null;
            }

            if (pBitmapPath == null)
            {
                bitmapRectangle = destRect;
                pBitmapPath     = SkinBaseElement.GetPath(destRect, bitmapPortion, keycolor);
            }
            else
            {
                Matrix matrix = new Matrix();
                matrix.Translate(destRect.X - PathPoint.X, destRect.Y - PathPoint.Y);
                pBitmapPath.Transform(matrix);
            }
            PathPoint = destRect.Location;
            return(pBitmapPath);
        }
Esempio n. 2
0
        protected virtual void OnSkinElementChanged(SkinBaseElement element)
        {
            Image image = null;

            if (activeImage != null)
            {
                image = activeImage;
            }
            else if (pressedImage != null)
            {
                image = pressedImage;
            }
            else if (disabledImage != null)
            {
                image = disabledImage;
            }

            if (image != null)
            {
                Platform.MoveWindow(cbInfo.hwndCombo, Location.X, Location.Y, image.Width, image.Height, true);
                this.Size = image.Size;
            }

            if (element.haskeycolor)
            {
                GraphicsPath path = SkinBaseElement.GetPath(new Rectangle(Point.Empty, this.Size), (Bitmap)activeImage, element.keycolor);
                if (path != null)
                {
                    this.Region = new Region(path);
                    path.Dispose();
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Load all elements for the skin level
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        internal ArrayList      LoadElements(XmlNode xmlNode)
        {
            ArrayList mElements = new ArrayList();

            foreach (XmlNode node in xmlNode.ChildNodes)
            {
                SkinBaseElement skinElement = (SkinBaseElement)LoadElement(node);
                mElements.Add(skinElement);
            }
            return(mElements);
        }
Esempio n. 4
0
 protected virtual void CreateRegion(SkinBaseElement element)
 {
     if (element.haskeycolor)
     {
         GraphicsPath path = SkinBaseElement.GetPath(new Rectangle(Point.Empty, this.Size), (Bitmap)activeImage, element.keycolor);
         if (path != null)
         {
             this.Region = new Region(path);
             path.Dispose();
         }
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Loads the style element from document node.
        /// </summary>
        /// <param name="objectNode">document node which repersents object</param>
        /// <returns>instance of class SlideElement</returns>
        private Object LoadElement(XmlNode styleNode)
        {
            string objectType = styleNode.Name;
            Object retobject  = null;

            if (objectType == "bitmap")
            {
                retobject = new SkinBitmap(sResDir);
            }
            if (objectType == "element")
            {
                retobject = new SkinBaseElement();
                ((SkinBaseElement)retobject).BitmapChanged += new BitmapChangedEventHandler(element_BitmapChanged);
            }
            else if (objectType == "control")
            {
                retobject = new SkinBaseControl();
                ((SkinBaseElement)retobject).BitmapChanged += new BitmapChangedEventHandler(element_BitmapChanged);
            }
            else if (objectType == "property")
            {
                retobject = new SkinElementPropertyInfo();
            }

            /*else	if (objectType == "button")
             * {
             *      retobject = new FlatToggleButton();
             *      ((SkinBaseElement)retobject).BitmapChanged += new BitmapChangedEventHandler( element_BitmapChanged);
             *      ((FlatToggleButton)retobject).OnNeedUpdate +=new EventHandler(FormSkin_OnNeedUpdate);
             *      ((FlatToggleButton)retobject).OnClick +=new EventHandler(FormSkin_OnClick);
             * }
             * else	if (objectType == "dragbutton")
             * {
             *      retobject = new DragFormButton();
             *      ((DragFormButton)retobject).OnDragBy +=new MouseEventHandler(FormSkin_OnDragBy);
             * }
             * else	if (objectType == "resizebutton")
             * {
             *      retobject = new ResizeFormButton();
             *      ((ResizeFormButton)retobject).OnResizeBy +=new MouseEventHandler(FormSkin_OnResizeBy);
             * }*/

            if (retobject != null)
            {
                foreach (XmlAttribute node in styleNode.Attributes)
                {
                    SetProperty(retobject, node);
                }
            }

            return(retobject);
        }
Esempio n. 6
0
        public void SetSkinElement(SkinBaseElement element)
        {
            // TODO:  Add ToggleButton.SetSkinElement implementation
            if (element == null || element.Image == null)
            {
                return;
            }
            Bitmap image = element.Image;

            try
            {
                // We need : image, active image, disabled image
                int buttonWidth  = image.Width / 4;
                int buttonHeight = image.Height;
                for (int i = 0; i < 4; i++)
                {
                    Bitmap   buttonBitmap  = new Bitmap(buttonWidth, buttonHeight);
                    Graphics imageGraphics = Graphics.FromImage(buttonBitmap);
                    imageGraphics.DrawImage(image, new Rectangle(0, 0, buttonWidth, buttonHeight),
                                            buttonWidth * i, 0, buttonWidth, buttonHeight,
                                            GraphicsUnit.Pixel);
                    if (i == 0)
                    {
                        Image = buttonBitmap;
                    }
                    else if (i == 1)
                    {
                        activeImage = buttonBitmap;
                    }
                    else if (i == 2)
                    {
                        pressedImage = buttonBitmap;
                    }
                    else if (i == 3)
                    {
                        disabledImage = buttonBitmap;
                    }
                }
                CreateRegion(element);
            }
            catch (Exception)
            {
            }
        }
Esempio n. 7
0
 public void SetSkinElement(SkinBaseElement element)
 {
     radio_btnBack.SetSkinElement(element);
     OnButtonSizeChanged();
 }
Esempio n. 8
0
        protected override void OnSkinElementChanged(SkinBaseElement element)
        {
            Image image = null;

            if (ActiveImage != null)
            {
                image = ActiveImage;
            }
            else if (PressedImage != null)
            {
                image = PressedImage;
            }
            else if (DisabledImage != null)
            {
                image = DisabledImage;
            }

            if (image == null)
            {
                return;
            }

            if (element.haskeycolor)
            {
                GraphicsPath path = null;                //SkinBaseElement.GetPath(new Rectangle(Point.Empty, this.Size), (Bitmap)ActiveImage, element.keycolor);
                if (WestWidth != 0)
                {
                    GraphicsPath west_path = SkinBaseElement.GetPath(
                        new Rectangle(Point.Empty, new Size(WestWidth, this.Height)),
                        (Bitmap)ActiveImage,
                        new Rectangle(Point.Empty, new Size(WestWidth, image.Height)),
                        element.keycolor);

                    if (west_path != null)
                    {
                        path = west_path;
                    }
                }
                if (EastWidth != 0)
                {
                    GraphicsPath east_path = SkinBaseElement.GetPath(
                        new Rectangle(new Point(this.Width - EastWidth, 0), new Size(EastWidth, this.Height)),
                        (Bitmap)ActiveImage,
                        new Rectangle(new Point(image.Width - EastWidth, 0), new Size(EastWidth, image.Height)),
                        element.keycolor);
                    if (east_path != null)
                    {
                        if (path == null)
                        {
                            path = east_path;
                        }
                        else
                        {
                            path.AddPath(east_path, true);
                        }
                    }
                }
                GraphicsPath center_path = SkinBaseElement.GetPath(
                    new Rectangle(new Point(WestWidth, 0), new Size(this.Width - EastWidth - WestWidth, this.Height)),
                    (Bitmap)ActiveImage,
                    new Rectangle(new Point(WestWidth, 0), new Size(image.Width - EastWidth - WestWidth, image.Height)),
                    element.keycolor);
                if (path == null)
                {
                    path = center_path;
                }
                else
                {
                    path.AddPath(center_path, true);
                }

                if (path != null)
                {
                    this.Region = new Region(path);
                    path.Dispose();
                }
            }
        }
        protected override void CreateRegion(SkinBaseElement element)
        {
            /*if( element.haskeycolor)
             * {
             *      GraphicsPath path = null;
             *      if( WestWidth != 0)
             *      {
             *              GraphicsPath west_path = SkinBaseElement.GetPath(new Rectangle(Point.Empty, new Size(WestWidth, this.Height)), (Bitmap)ActiveImage, element.keycolor);
             *              if( west_path!=null)
             *              {
             *                      path = west_path;
             *              }
             *      }
             * }*/
            Bitmap image = (Bitmap)ActiveImage;

            if (image != null && element.haskeycolor)
            {
                GraphicsPath path = null;                //SkinBaseElement.GetPath(new Rectangle(Point.Empty, this.Size), (Bitmap)ActiveImage, element.keycolor);
                if (WestWidth != 0)
                {
                    GraphicsPath west_path = SkinBaseElement.GetPath(
                        new Rectangle(Point.Empty, new Size(WestWidth, this.Height)),
                        (Bitmap)ActiveImage,
                        new Rectangle(Point.Empty, new Size(WestWidth, image.Height)),
                        element.keycolor);

                    if (west_path != null)
                    {
                        path = west_path;
                    }
                }
                if (EastWidth != 0)
                {
                    GraphicsPath east_path = SkinBaseElement.GetPath(
                        new Rectangle(new Point(this.Width - EastWidth, 0), new Size(EastWidth, this.Height)),
                        (Bitmap)ActiveImage,
                        new Rectangle(new Point(image.Width - EastWidth, 0), new Size(EastWidth, image.Height)),
                        element.keycolor);
                    if (east_path != null)
                    {
                        if (path == null)
                        {
                            path = east_path;
                        }
                        else
                        {
                            path.AddPath(east_path, true);
                        }
                    }
                }
                GraphicsPath center_path = SkinBaseElement.GetPath(
                    new Rectangle(new Point(WestWidth, 0), new Size(this.Width - EastWidth - WestWidth, this.Height)),
                    (Bitmap)ActiveImage,
                    new Rectangle(new Point(WestWidth, 0), new Size(image.Width - EastWidth - WestWidth, image.Height)),
                    element.keycolor);
                if (path == null)
                {
                    path = center_path;
                }
                else
                {
                    path.AddPath(center_path, true);
                }

                if (path != null)
                {
                    this.Region = new Region(path);
                    path.Dispose();
                }
            }
        }
Esempio n. 10
0
 public void SetSkinElement(SkinBaseElement element)
 {
     // TODO:  Add SkinEdit.SetSkinElement implementation
     textedit_btnBack.SetSkinElement(element);
 }
Esempio n. 11
0
        /// <summary>
        /// Grap rectangle portion for this level and remove recent rectangle
        /// </summary>
        public Rectangle UpdateRegions(Rectangle pureRect)
        {
            if (elements.Count == 0)
            {
                return(pureRect);
            }
            if (elements[0] == null)
            {
                return(pureRect);
            }

            // Grab first portion
            Rectangle       levelRect = pureRect;
            SkinBaseElement felement  = (SkinBaseElement)elements[0];

            levelRect.Height = (felement.srcRect.Height < pureRect.Height && felement.srcRect != Rectangle.Empty)?felement.srcRect.Height:pureRect.Height;

            if (valign == VAlignEnumeration.Bottom)
            {
                levelRect.Location = new Point(levelRect.Left, pureRect.Bottom - levelRect.Height);
            }
            else if (valign == VAlignEnumeration.Justify)
            {
                levelRect = pureRect;
            }

            mBounds = levelRect;
            foreach (SkinBaseElement element in elements)
            {
                Rectangle elementRect = levelRect;
                if (element == null)
                {
                    continue;
                }

                if (element.align == AlignEnumeration.Justify)
                {
                    elementRect.Width = levelRect.Width;
                    levelRect.Width   = 0;
                }
                else
                {
                    elementRect.Width = element.srcRect.Width;
                    if (element.align == AlignEnumeration.Right)
                    {
                        elementRect.Location = new Point(levelRect.Right - elementRect.Width, levelRect.Top);
                        levelRect.Width     -= elementRect.Width;
                    }
                    else if (element.align == AlignEnumeration.Left)
                    {
                        levelRect.Width   -= element.srcRect.Width;
                        levelRect.Location = new Point(levelRect.Left + element.srcRect.Width, levelRect.Top);;
                    }
                }

                if (element.valign == VAlignEnumeration.Justify)
                {
                    elementRect.Height = levelRect.Height;
                    //levelRect.Height = 0;
                }
                else
                {
                    elementRect.Height = element.srcRect.Height;
                    if (element.valign == VAlignEnumeration.Bottom)
                    {
                        elementRect.Location = new Point(element.srcRect.Left, levelRect.Bottom - element.srcRect.Height);
                        //levelRect.Height -= element.srcRect.Height;
                    }
                    else if (element.valign == VAlignEnumeration.Bottom)
                    {
                        //levelRect.Height -= element.srcRect.Height;
                        levelRect.Location = new Point(levelRect.Left, levelRect.Top + element.srcRect.Height);
                    }
                }
                element.destRect = elementRect;
                if (levelRect.Width == 0 || levelRect.Height == 0)
                {
                    break;
                }
            }

            // Compute rest of the level
//			if( !levelRect.IsEmpty)
//			{
            if (valign == VAlignEnumeration.Top)
            {
                pureRect.Location = new Point(pureRect.Left, pureRect.Top + mBounds.Height);
                pureRect.Height  -= mBounds.Height;
            }
            else if (valign == VAlignEnumeration.Bottom)
            {
                pureRect.Height -= mBounds.Height;
            }
            else if (valign == VAlignEnumeration.Justify)
            {
                pureRect = Rectangle.Empty;
            }
//			}
            return(pureRect);
        }
Esempio n. 12
0
 /// <summary>
 /// Return path for this element
 /// </summary>
 public GraphicsPath GetPath(Color transparencyColor)
 {
     return(SkinBaseElement.GetPath(destRect, bitmapPortion, transparencyColor));
 }