Esempio n. 1
0
        public static STexture GetSkinVideoTexture(string VideoName)
        {
            int SkinIndex = GetSkinIndex();

            if (SkinIndex != -1)
            {
                for (int i = 0; i < _Skins[SkinIndex].VideoList.Count; i++)
                {
                    SkinElement sk = _Skins[SkinIndex].VideoList[i];
                    if (sk.Name == VideoName)
                    {
                        float Time = 0f;
                        if (sk.VideoIndex == -1)
                        {
                            sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name));
                            CVideo.VdSetLoop(sk.VideoIndex, true);
                        }
                        CVideo.VdGetFrame(sk.VideoIndex, ref sk.Texture, Time, ref Time);
                        _Skins[SkinIndex].VideoList[i] = sk;
                        return(sk.Texture);
                    }
                }
            }
            return(new STexture(-1));
        }
Esempio n. 2
0
        public static void SkinVideoResume(string VideoName)
        {
            int SkinIndex = GetSkinIndex();

            if (SkinIndex != -1)
            {
                for (int i = 0; i < _Skins[SkinIndex].VideoList.Count; i++)
                {
                    SkinElement sk = _Skins[SkinIndex].VideoList[i];
                    if (sk.Name == VideoName)
                    {
                        if (sk.VideoIndex == -1)
                        {
                            sk.VideoIndex = CVideo.VdLoad(GetVideoFilePath(sk.Name));
                            CVideo.VdSetLoop(sk.VideoIndex, true);
                        }
                        CVideo.VdResume(sk.VideoIndex);
                        _Skins[SkinIndex].VideoList[i] = sk;
                        return;
                    }
                }
            }
        }
Esempio n. 3
0
        public static void LoadSkins()
        {
            for (int index = 0; index < _Skins.Count; index++)
            {
                bool loaded = false;
                XPathDocument xPathDoc = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc = new XPathDocument(Path.Combine(_Skins[index].Path, _Skins[index].FileName));
                    navigator = xPathDoc.CreateNavigator();
                    loaded = true;
                }
                catch (Exception e)
                {
                    CLog.LogError("Error loading skin " + _Skins[index].FileName + ": " + e.Message);
                    loaded = false;
                    if (navigator != null)
                        navigator = null;

                    if (xPathDoc != null)
                        xPathDoc = null;
                }

                if (loaded)
                {
                    string value = String.Empty;

                    // load skins/textures
                    for (int i = 0; i < _Skins[index].SkinList.Count; i++)
                    {
                        CHelper.GetValueFromXML("//root/Skins/" + _Skins[index].SkinList[i].Name, navigator, ref value, String.Empty);
                        SkinElement sk = new SkinElement();
                        sk.Name = _Skins[index].SkinList[i].Name;
                        sk.Value = value;
                        sk.VideoIndex = -1;
                        sk.Texture = CDraw.AddTexture(Path.Combine(_Skins[index].Path, sk.Value));
                        _Skins[index].SkinList[i] = sk;
                    }

                    // load videos
                    for (int i = 0; i < _Skins[index].VideoList.Count; i++)
                    {
                        CHelper.GetValueFromXML("//root/Videos/" + _Skins[index].VideoList[i].Name, navigator, ref value, String.Empty);
                        SkinElement sk = new SkinElement();
                        sk.Name = _Skins[index].VideoList[i].Name;
                        sk.Value = value;
                        sk.VideoIndex = CVideo.VdLoad(Path.Combine(_Skins[index].Path, sk.Value));
                        CVideo.VdSetLoop(sk.VideoIndex, true);
                        CVideo.VdPause(sk.VideoIndex);
                        sk.Texture = new STexture(-1);
                        _Skins[index].VideoList[i] = sk;
                    }

                    // load colors
                    LoadColors(navigator, index);
                }
            }
        }
Esempio n. 4
0
        public static void ListSkins()
        {
            CHelper Helper = new CHelper();
            int themeIndex = GetThemeIndex();
            _Skins.Clear();

            if (themeIndex < 0)
            {
                CLog.LogError("Error List Skins. Can't find Theme: " + CConfig.Theme);
                return;
            }

            Theme theme = _Themes[themeIndex];

            string path = Path.Combine(theme.Path, theme.SkinFolder);
            List<string> files = Helper.ListFiles(path, "*.xml", false);

            foreach (string file in files)
            {
                bool loaded = false;
                XPathDocument xPathDoc = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc = new XPathDocument(Path.Combine(path, file));
                    navigator = xPathDoc.CreateNavigator();
                    loaded = true;
                }
                catch (Exception e)
                {
                    CLog.LogError("Error loading skin " + file + ": " + e.Message);
                    loaded = false;
                    if (navigator != null)
                        navigator = null;

                    if (xPathDoc != null)
                        xPathDoc = null;
                }

                if (loaded)
                {
                    Skin skin = new Skin();

                    int version = 0;
                    CHelper.TryGetIntValueFromXML("//root/SkinSystemVersion", navigator, ref version);

                    if (version == SkinSystemVersion)
                    {
                        CHelper.GetValueFromXML("//root/Info/Name", navigator, ref skin.Name, String.Empty);
                        if (skin.Name != String.Empty)
                        {
                            CHelper.GetValueFromXML("//root/Info/Author", navigator, ref skin.Author, String.Empty);
                            CHelper.TryGetIntValueFromXML("//root/Info/SkinVersionMajor", navigator, ref skin.SkinVersionMajor);
                            CHelper.TryGetIntValueFromXML("//root/Info/SkinVersionMinor", navigator, ref skin.SkinVersionMinor);

                            skin.Path = path;
                            skin.FileName = file;

                            skin.SkinList = new List<SkinElement>();
                            List<string> names = CHelper.GetValuesFromXML("Skins", navigator);
                            foreach (string str in names)
                            {
                                SkinElement sk = new SkinElement();
                                sk.Name = str;
                                sk.Value = String.Empty;
                                skin.SkinList.Add(sk);
                            }

                            skin.VideoList = new List<SkinElement>();
                            names = CHelper.GetValuesFromXML("Videos", navigator);
                            foreach (string str in names)
                            {
                                SkinElement sk = new SkinElement();
                                sk.Name = str;
                                sk.Value = String.Empty;
                                skin.VideoList.Add(sk);
                            }
                            _Skins.Add(skin);
                        }
                    }
                    else
                    {
                        string msg = "Can't load Skin \"" + file + "\", ";
                        if (version < SkinSystemVersion)
                            msg += "the file ist outdated! ";
                        else
                            msg += "the file is for newer program versions! ";

                        msg += "Current SkinSystemVersion is " + SkinSystemVersion.ToString();
                        CLog.LogError(msg);
                    }
                }
            }
        }
Esempio n. 5
0
        public static void ListSkins()
        {
            CHelper Helper     = new CHelper();
            int     themeIndex = GetThemeIndex();

            _Skins.Clear();

            if (themeIndex < 0)
            {
                CLog.LogError("Error List Skins. Can't find Theme: " + CConfig.Theme);
                return;
            }

            Theme theme = _Themes[themeIndex];

            string        path  = Path.Combine(theme.Path, theme.SkinFolder);
            List <string> files = Helper.ListFiles(path, "*.xml", false);

            foreach (string file in files)
            {
                bool           loaded    = false;
                XPathDocument  xPathDoc  = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc  = new XPathDocument(Path.Combine(path, file));
                    navigator = xPathDoc.CreateNavigator();
                    loaded    = true;
                }
                catch (Exception e)
                {
                    CLog.LogError("Error loading skin " + file + ": " + e.Message);
                    loaded = false;
                    if (navigator != null)
                    {
                        navigator = null;
                    }

                    if (xPathDoc != null)
                    {
                        xPathDoc = null;
                    }
                }

                if (loaded)
                {
                    Skin skin = new Skin();

                    int version = 0;
                    CHelper.TryGetIntValueFromXML("//root/SkinSystemVersion", navigator, ref version);

                    if (version == SkinSystemVersion)
                    {
                        CHelper.GetValueFromXML("//root/Info/Name", navigator, ref skin.Name, String.Empty);
                        if (skin.Name != String.Empty)
                        {
                            CHelper.GetValueFromXML("//root/Info/Author", navigator, ref skin.Author, String.Empty);
                            CHelper.TryGetIntValueFromXML("//root/Info/SkinVersionMajor", navigator, ref skin.SkinVersionMajor);
                            CHelper.TryGetIntValueFromXML("//root/Info/SkinVersionMinor", navigator, ref skin.SkinVersionMinor);


                            skin.Path     = path;
                            skin.FileName = file;

                            skin.SkinList = new Dictionary <string, SkinElement>();
                            List <string> names = CHelper.GetValuesFromXML("Skins", navigator);
                            foreach (string str in names)
                            {
                                SkinElement sk = new SkinElement();
                                sk.Name            = str;
                                sk.Value           = String.Empty;
                                skin.SkinList[str] = sk;
                            }

                            skin.VideoList = new List <SkinElement>();
                            names          = CHelper.GetValuesFromXML("Videos", navigator);
                            foreach (string str in names)
                            {
                                SkinElement sk = new SkinElement();
                                sk.Name  = str;
                                sk.Value = String.Empty;
                                skin.VideoList.Add(sk);
                            }
                            _Skins.Add(skin);
                        }
                    }
                    else
                    {
                        string msg = "Can't load Skin \"" + file + "\", ";
                        if (version < SkinSystemVersion)
                        {
                            msg += "the file ist outdated! ";
                        }
                        else
                        {
                            msg += "the file is for newer program versions! ";
                        }

                        msg += "Current SkinSystemVersion is " + SkinSystemVersion.ToString();
                        CLog.LogError(msg);
                    }
                }
            }
        }
Esempio n. 6
0
        public static void LoadSkins()
        {
            for (int index = 0; index < _Skins.Count; index++)
            {
                bool           loaded    = false;
                XPathDocument  xPathDoc  = null;
                XPathNavigator navigator = null;

                try
                {
                    xPathDoc  = new XPathDocument(Path.Combine(_Skins[index].Path, _Skins[index].FileName));
                    navigator = xPathDoc.CreateNavigator();
                    loaded    = true;
                }
                catch (Exception e)
                {
                    CLog.LogError("Error loading skin " + _Skins[index].FileName + ": " + e.Message);
                    loaded = false;
                    if (navigator != null)
                    {
                        navigator = null;
                    }

                    if (xPathDoc != null)
                    {
                        xPathDoc = null;
                    }
                }

                if (loaded)
                {
                    string value = String.Empty;


                    // load skins/textures
                    List <string> keys = new List <string>(_Skins[index].SkinList.Keys);

                    foreach (string name in keys)
                    {
                        try
                        {
                            CHelper.GetValueFromXML("//root/Skins/" + name, navigator, ref value, String.Empty);
                            SkinElement sk = _Skins[index].SkinList[name];
                            sk.Value      = value;
                            sk.VideoIndex = -1;
                            sk.Texture    = CDraw.AddTexture(Path.Combine(_Skins[index].Path, sk.Value));
                            _Skins[index].SkinList[name] = sk;
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("Error on loading texture \"" + name + "\": " + e.Message + e.StackTrace);
                            CLog.LogError("Error on loading texture \"" + name + "\": " + e.Message + e.StackTrace);
                        }
                    }


                    // load videos
                    for (int i = 0; i < _Skins[index].VideoList.Count; i++)
                    {
                        try
                        {
                            CHelper.GetValueFromXML("//root/Videos/" + _Skins[index].VideoList[i].Name, navigator, ref value, String.Empty);
                            SkinElement sk = new SkinElement();
                            sk.Name       = _Skins[index].VideoList[i].Name;
                            sk.Value      = value;
                            sk.VideoIndex = CVideo.VdLoad(Path.Combine(_Skins[index].Path, sk.Value));
                            CVideo.VdSetLoop(sk.VideoIndex, true);
                            CVideo.VdPause(sk.VideoIndex);
                            sk.Texture = new STexture(-1);
                            _Skins[index].VideoList[i] = sk;
                        }
                        catch (Exception e)
                        {
                            MessageBox.Show("Error on loading video \"" + _Skins[index].VideoList[i].Name + "\": " + e.Message + e.StackTrace);
                            CLog.LogError("Error on loading video \"" + _Skins[index].VideoList[i].Name + "\": " + e.Message + e.StackTrace);
                        }
                    }

                    // load colors
                    LoadColors(navigator, index);
                }
            }
        }