Example #1
0
 public void loadNav(Nav.Game Game)
 {
     loadNav(Game.name);
 }
Example #2
0
        private void loadTheme(Nav.Game Game)
        {
            String rom = Game.rom;
            String ExistingZipFile = settings.hyperspinPath + "Media\\" + nav.systemLoaded + "\\Themes\\" + rom + ".zip";
            if (!File.Exists(ExistingZipFile))
            {
                ExistingZipFile = settings.hyperspinPath + "Media\\" + nav.systemLoaded + "\\Themes\\default.zip";
            }

            String VideoPath = GetVideo(rom);

            //Only load theme if it exists and it's not already loaded
            if (File.Exists(ExistingZipFile) && (themeLoaded != ExistingZipFile)) {
                //Hide all image containers as some themes don't use all of them
                Artwork1.Visibility = Visibility.Hidden;
                Artwork2.Visibility = Visibility.Hidden;
                Artwork3.Visibility = Visibility.Hidden;
                Artwork4.Visibility = Visibility.Hidden;
                Video.Visibility = Visibility.Hidden;
                VideoClip.Visibility = Visibility.Hidden;
                //Background.Visibility = Visibility.Hidden;

                //Open the theme zip and parse Theme.xml(this contains the info of where the video and images should display
                using (ZipFile zip = ZipFile.Read(ExistingZipFile))
                {
                    DisplayImageFromZip(zip, Background, "Background");

                    ZipEntry entry = zip["Theme.xml"];
                    using (var stream = entry.OpenReader())
                    {
                        XmlTextReader reader = new XmlTextReader(stream);
                        while (reader.Read())
                        {
                            if ((reader.NodeType.ToString().ToUpper() == "ELEMENT")&&(reader.Name.ToUpper() != "THEME"))
                            {
                                if ((reader.Name.ToUpper() == "VIDEO")||(reader.Name.ToUpper().Substring(0, 7) == "ARTWORK"))
                                {
                                    //Determine where the video overlay image and the artwork files should go
                                    double x = ParseDoubleAttribute(reader.GetAttribute("x"));
                                    double y = ParseDoubleAttribute(reader.GetAttribute("y"));
                                    double rotation = ParseDoubleAttribute(reader.GetAttribute("r"));

                                    string imgName = UppercaseFirst(reader.Name);
                                    Image img = (Image)this.FindName(imgName);
                                    if (DisplayImageFromZip(zip, img, imgName))
                                        MoveElement(img, x, y, rotation);

                                    //Setup the animation
                                    string AnimationType = ParseStringAttribute(reader.GetAttribute("type"));
                                    if (AnimationType != "none")
                                    {
                                        Animation animation = new Animation();
                                        animation.AnimationType = AnimationType;
                                        animation.Time = ParseDoubleAttribute(reader.GetAttribute("time"));
                                        animation.Delay = ParseDoubleAttribute(reader.GetAttribute("delay"));
                                        animation.Start = ParseStringAttribute(reader.GetAttribute("start"));
                                        animation.Rest = ParseStringAttribute(reader.GetAttribute("rest"));
                                        animation.Animate(img);
                                    }
                                    //Load the video
                                    if (reader.Name.ToUpper() == "VIDEO")
                                    {
                                        double width = ParseDoubleAttribute(reader.GetAttribute("w"));
                                        double height = ParseDoubleAttribute(reader.GetAttribute("h"));

                                        //resize the video overlay image and the video container
                                        //Video.Width = width;
                                        //Video.Height = height;

                                        if (VideoPath != null)
                                        {
                                            VideoClip.StretchDirection = StretchDirection.Both;
                                            VideoClip.Width = width;
                                            VideoClip.Height = height;

                                            MoveElement(VideoClip, x, y, rotation);
                                            VideoClip.Visibility = Visibility.Visible;
                                            VideoClip.Source = new Uri(VideoPath);
                                            VideoClip.LoadedBehavior = MediaState.Manual;
                                            VideoClip.MediaEnded += new RoutedEventHandler(Media_Ended);
                                            VideoClip.Play();
                                        }
                                    }
                                }
                                else if (reader.Name.ToUpper() == "PARTICLE")
                                {

                                }
                            }
                        }

                    }
                }
                themeLoaded = ExistingZipFile;
            }
            else if (themeLoaded == ExistingZipFile) {
                //Theme already loaded, just change the video
                VideoClip.Source = new Uri(VideoPath);
                VideoClip.LoadedBehavior = MediaState.Manual;
                VideoClip.Play();
            }
        }