Пример #1
0
 public SkinControlInformation(SkinControlInformation source) : base(source)
 {
     DefaultSize   = source.DefaultSize;
     MinimumSize   = source.MinimumSize;
     OriginMargins = source.OriginMargins;
     ClientMargins = source.ClientMargins;
     ResizerSize   = source.ResizerSize;
     Layers        = new SkinList <SkinLayer>(source.Layers);
     Attributes    = new SkinList <SkinAttribute>(source.Attributes);
 } // SkinControl
Пример #2
0
        public SkinList(SkinList <T> source)
        {
            foreach (T t1 in source)
            {
                Type[] t = new Type[1];
                t[0] = typeof(T);

                object[] p = new object[1];
                p[0] = t1;

                Add((T)t[0].GetConstructor(t).Invoke(p));
            }
        } // SkinList
Пример #3
0
        } // SkinLayer

        public SkinLayer(SkinLayer source) : base(source)
        {
            if (source != null)
            {
                Image          = new SkinImage(source.Image);
                Width          = source.Width;
                Height         = source.Height;
                OffsetX        = source.OffsetX;
                OffsetY        = source.OffsetY;
                Alignment      = source.Alignment;
                SizingMargins  = source.SizingMargins;
                ContentMargins = source.ContentMargins;
                States         = source.States;
                Overlays       = source.Overlays;
                Text           = new SkinText(source.Text);
                Attributes     = new SkinList <SkinAttribute>(source.Attributes);
            }
            else
            {
                throw new Exception("Parameter for SkinLayer copy constructor cannot be null.");
            }
        } // SkinLayer
Пример #4
0
        /// <summary>
        /// Manage the skin content (mouse cursors, elements' images, fonts, and skin's parameters)
        /// </summary>
        public static void LoadSkin(string skinName)
        {
            CurrentSkinName = skinName;

            AssetContentManager userContentManager = AssetContentManager.CurrentContentManager;

            #region Unload previous skin

            Controls = new SkinList <SkinControlInformation>();
            Fonts    = new SkinList <SkinFont>();
            Images   = new SkinList <SkinImage>();
            #if (WINDOWS)
            Cursors = new SkinList <SkinCursor>();
            #endif

            if (skinContentManager == null)
            {
                skinContentManager = new AssetContentManager {
                    Name = "Skin Content Manager", Hidden = true
                }
            }
            ;
            else
            {
                skinContentManager.Unload();
            }
            AssetContentManager.CurrentContentManager = skinContentManager;

            #endregion

            #region Load Description File

            string fullPath = "Skin" + "\\" + skinName + "\\Description";
            skinDescription = new Document(fullPath);

            // Read XML data.
            if (skinDescription.Resource.Element("Skin") != null)
            {
                try
                {
                    LoadImagesDescription();
                    LoadFontsDescription();
                    #if (WINDOWS)
                    LoadCursorsDescription();
                    #endif
                    LoadControlsDescription();
                }
                catch (Exception e)
                {
                    throw new Exception("Failed to load skin: " + skinName + ".\n\n" + e.Message);
                }
            }
            else
            {
                throw new Exception("Failed to load skin: " + skinName + ". Skin tag doesn't exist.");
            }

            #endregion

            #region Load Resources

            try
            {
                foreach (SkinFont skinFont in Fonts)
                {
                    skinFont.Font = new Font(skinFont.Filename);
                }
                #if (WINDOWS)
                foreach (SkinCursor skinCursor in Cursors)
                {
                    skinCursor.Cursor = new Cursor(skinName + "\\" + skinCursor.Filename);
                }
                #endif
                foreach (SkinImage skinImage in Images)
                {
                    skinImage.Texture = new Texture("Skin\\" + skinName + "\\" + skinImage.Filename);
                }
                foreach (SkinControlInformation skinControl in Controls)
                {
                    foreach (SkinLayer skinLayer in skinControl.Layers)
                    {
                        if (skinLayer.Image.Name != null)
                        {
                            skinLayer.Image = Images[skinLayer.Image.Name];
                        }
                        else
                        {
                            skinLayer.Image = Images[0];
                        }
                        skinLayer.Text.Font = skinLayer.Text.Name != null ? Fonts[skinLayer.Text.Name] : Fonts[0];
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception("Failed to load skin: " + skinName + ".\n\n" + e.Message);
            }

            #endregion

            // Restore user content manager.
            AssetContentManager.CurrentContentManager = userContentManager;
        } // LoadSkin