/// <summary>
        /// Path to directory with skin files
        /// </summary>
        private bool SetSkin(string dirPath)
        {
            if (dirPath == null || dirPath == "")
            {
                return(false);
            }
            DirectoryInfo info = new DirectoryInfo(dirPath);

            if (!info.Exists)
            {
                return(false);
            }
            FileInfo[] files = info.GetFiles();

            FormSkin skin = new FormSkin();

            foreach (FileInfo file in files)
            {
                if (file.Extension == @".xml")
                {
                    if (SetSkinFromFile(file.FullName))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #2
0
 public bool SetSkin(FormSkin skin)
 {
     if (skinController == null)
     {
         return(false);
     }
     skinController.Skin = skin;
     return(true);
 }
Exemple #3
0
        /// <summary>
        /// Load all hotspots for the skin
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        internal ArrayList      LoadControls(XmlNode xmlNode)
        {
            ArrayList mControls = new ArrayList();

            foreach (XmlNode node in xmlNode.ChildNodes)
            {
                if (node.Name == @"#comment")
                {
                    continue;
                }
                SkinBaseControl skinControl = (SkinBaseControl)LoadElement(node);
                if (skinControl == null)
                {
                    continue;
                }
                if (node.ChildNodes.Count != 0)
                {
                    FormSkin skin = new FormSkin();
                    skin.ResDir = ResDir;
                    foreach (XmlNode cnode in node.ChildNodes)
                    {
                        if (cnode.Name == "window" && skin.Load(cnode))
                        {
                            skinControl.Skin = skin;
                            break;
                        }
                    }
                }
                else
                {
                    foreach (XmlAttribute attr in node.Attributes)
                    {
                        if (attr.Name == @"file")
                        {
                            FormSkin skin = new FormSkin();
                            skin.ResDir = ResDir;
                            try
                            {
                                if (skin.Load(ResDir + @"\", attr.Value))
                                {
                                    skinControl.Skin = skin;
                                    break;
                                }
                            }
                            catch (Exception)
                            {
                                break;
                            }
                        }
                    }
                }
                mControls.Add(skinControl);
            }
            return(mControls);
        }
 /// <summary>
 /// Skin all controls if necessary
 /// </summary>
 public void SkinControls()
 {
     if (mSkin != null && mSkin.SubSkins != null)
     {
         foreach (Object obj in mSkin.SubSkins)
         {
             FormSkin formSkin = (FormSkin)obj;
             SkinControls(formSkin);
         }
     }
     SkinControls(mSkin);
 }
Exemple #5
0
 /// <summary>
 /// Paint skin if necessary
 /// </summary>
 public void Paint(PaintEventArgs e)
 {
     foreach (SkinLevel level in levels)
     {
         if (e.ClipRectangle.IntersectsWith(level.Bounds))
         {
             level.Paint(e.Graphics);
         }
     }
     foreach (Object obj in SubSkins)
     {
         FormSkin formSkin = (FormSkin)obj;
         formSkin.Paint(e);
     }
 }
        /// <summary>
        /// Path to directory with skin files
        /// </summary>
        private bool SetSkinFromFile(string fullPath)
        {
            FormSkin skin = new FormSkin();

            if (skin.Load(fullPath))
            {
                Skin = skin;
                return(true);
            }
            else
            {
                Skin = null;
            }
            return(false);
        }
        protected void    SkinControls(FormSkin skin)
        {
            if (skin == null)
            {
                return;
            }
            ArrayList controls = skin.Controls;

            if (controls == null)
            {
                return;
            }

            foreach (object control in controls)
            {
                Control formControl = GetNamedControl(((SkinBaseControl)control).name);
                if (formControl != null)
                {
                    if (formControl is ISkinnedControl)
                    {
                        ((ISkinnedControl)formControl).SetSkinElement((SkinBaseElement)control);
                    }
                    else if (formControl is IResizableSkinnedControl)
                    {
                        ((IResizableSkinnedControl)formControl).SetSkin(((SkinBaseElement)control).Skin);
                    }
                    if (((SkinBaseElement)control).Skin != null)
                    {
                        ((SkinBaseElement)control).Skin.SetControlProperties(formControl);
                    }
                }
                else
                {
                    if (slaver.GetType().ToString() == ((SkinBaseControl)control).name && slaver is ISkinnedControl)
                    {
                        ((ISkinnedControl)slaver).SetSkinElement((SkinBaseElement)control);
                        if (((SkinBaseElement)control).Skin != null)
                        {
                            ((SkinBaseElement)control).Skin.SetControlProperties(formControl);
                        }
                    }
                }
            }
            if (skin != null)
            {
                skin.SetControlProperties(slaver);
            }
        }
Exemple #8
0
        /// <summary>
        /// Calculate regions of skin parts
        /// </summary>
        /// <param name="dwWidth">Width of the skin</param>
        /// <param name="dwHeight">Height of the skin</param>
        public Region UpdateRegions(int dwWidth, int dwHeight)
        {
            if (dwWidth <= 0 || dwHeight <= 0)
            {
                return(null);
            }
            Rectangle pureRectangle = new Rectangle(0, 0, dwWidth, dwHeight);

            skinSize = pureRectangle.Size;
            if (levels != null)
            {
                foreach (SkinLevel level in levels)
                {
                    if (pureRectangle.Width == 0 || pureRectangle.Height == 0)
                    {
                        break;
                    }
                    Rectangle restRectangle = level.UpdateRegions(pureRectangle);
                    pureRectangle = restRectangle;
                }
            }
            Region region = SkinToRegion(Color.FromArgb(255, 167, 150));

            foreach (Object obj in SubSkins)
            {
                FormSkin formSkin  = (FormSkin)obj;
                Region   subregion = formSkin.UpdateRegions(dwWidth, dwHeight);
                if (subregion != null)
                {
                    if (region != null)
                    {
                        region.Dispose();
                    }
                    region = subregion;
                }
            }

            return(region);
        }
Exemple #9
0
        /// <summary>
        /// Load included skin
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        internal void   LoadInclude(XmlNode xmlNode)
        {
            FormSkin includeSkin = new FormSkin();

            foreach (XmlAttribute node in xmlNode.Attributes)
            {
                if (node.Name == @"file")
                {
                    try
                    {
                        if (includeSkin.Load(ResDir + @"\", node.Value))
                        {
                            subSkins.Add(includeSkin);
                            return;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }