Ejemplo n.º 1
0
        private Skin(string folder, List <Skin> generatedSkins)
        {
            _resources = Properties.Resources.ResourceManager;
            string skinPath = Path.Combine(Environment.CurrentDirectory, folder);

            if (!File.Exists(Path.Combine(skinPath, "skin.xml")))
            {
                //throw new ConfigParseException ("Could not find skin.xml for skin at '"+folder+"'.");
                return;
            }
            XDocument doc = XDocument.Load(Path.Combine(skinPath, "skin.xml"));

            Name   = ReadStringAttr(doc.Root, "name");
            Author = ReadStringAttr(doc.Root, "author");

            string typeStr = ReadStringAttr(doc.Root, ("type"));

            string[] typesVec = typeStr.Split(';');

            List <Tuple <InputSource, string> > types = new List <Tuple <InputSource, string> >();

            foreach (string type in typesVec)
            {
                string orgType = type;
                string type1;
                if (type.Contains("."))
                {
                    type1 = type.Substring(0, type.IndexOf('.'));
                }
                else
                {
                    type1 = type;
                }
                types.Add(new Tuple <InputSource, string>(InputSource.ALL.First(x => x.TypeTag == type1), orgType));
            }

            int i = 0;

            foreach (Tuple <InputSource, string> inputSource in types)
            {
                Skin TempSkin = null;
                if (i == 0)
                {
                    TempSkin = this;
                    i++;
                }
                else
                {
                    TempSkin = new Skin();
                }

                TempSkin.LoadSkin(Name, Author, inputSource.Item1, doc, skinPath, inputSource.Item2);
                generatedSkins.Add(TempSkin);
            }
        }
Ejemplo n.º 2
0
        private Skin(string folder, List <Skin> generatedSkins)
        {
            string skinPath = Path.Combine(Environment.CurrentDirectory, folder);

            if (!File.Exists(Path.Combine(skinPath, "skin.xml")))
            {
                //throw new ConfigParseException ("Could not find skin.xml for skin at '"+folder+"'.");
                return;
            }
            XDocument doc = XDocument.Load(Path.Combine(skinPath, "skin.xml"));

            Name   = ReadStringAttr(doc.Root, "name");
            Author = ReadStringAttr(doc.Root, "author");

            string typeStr = ReadStringAttr(doc.Root, ("type"));

            string[] typesVec = typeStr.Split(';');

            List <InputSource> types = new List <InputSource>();

            foreach (string type in typesVec)
            {
                InputSource TempType = InputSource.ALL.First(x => x.TypeTag == type);

                if (TempType == null)
                {
                    throw new ConfigParseException("Illegal value specified for skin attribute 'type'.");
                }
                types.Add(TempType);
            }

            int i = 0;

            foreach (InputSource inputSource in types)
            {
                Skin TempSkin = null;
                if (i == 0)
                {
                    TempSkin = this;
                    i++;
                }
                else
                {
                    TempSkin = new Skin();
                }

                TempSkin.LoadSkin(Name, Author, inputSource, doc, skinPath);
                generatedSkins.Add(TempSkin);
            }
        }