Esempio n. 1
0
        private static IEnumerable <ImageAsset> ExtractImageAssets(ZipArchive archive, IEnumerable <XElement> imageAssets)
        {
            if (archive == null)
            {
                throw new ArgumentNullException("archive");
            }

            if (imageAssets == null)
            {
                return(null);
            }

            if (imageAssets.Any(imageAsset => imageAsset.Name != ImageAssetTag))
            {
                throw new InvalidOperationException();
            }

            IEnumerable <ImageAsset> assets = imageAssets.Select(imageAsset => new ImageAsset
            {
                Angle    = Convert.ToDouble(imageAsset.Attribute(ImageAssetRotationAngle).Value),
                Content  = new ImageBrush(StreamManipulation.ExtractBitmapImage(archive, string.Format(Images, imageAsset.Attribute(ImageAssetContentPath).Value).RemoveFirstSlash())),
                Position = new Position
                {
                    X = Convert.ToDouble(imageAsset.Attribute(ImageAssetLeft).Value),
                    Y = Convert.ToDouble(imageAsset.Attribute(ImageAssetTop).Value)
                },
                Size  = Convert.ToInt32(imageAsset.Attribute(ImageAssetSize).Value),
                Layer = Convert.ToInt32(imageAsset.Attribute(LayerAttribute).Value)
            });

            return(assets);
        }
Esempio n. 2
0
        private static void ExtractNoGoNoActivity(ZipArchive archive, XElement game, GoNoGoGame activity)
        {
            NoGoNoActivity gameActivity = new NoGoNoActivity
            {
                new GameOption
                {
                    Option  = new ImageBrush(StreamManipulation.ExtractBitmapImage(archive, string.Format(Images, game.Attribute("GoNoGoFocusImage").Value).RemoveFirstSlash())),
                    IsWrong = true
                },
                new GameOption
                {
                    Option  = new ImageBrush(StreamManipulation.ExtractBitmapImage(archive, string.Format(Images, game.Attribute("GoNoGoWrongImage1").Value).RemoveFirstSlash())),
                    IsWrong = false
                },
                new GameOption
                {
                    Option  = new ImageBrush(StreamManipulation.ExtractBitmapImage(archive, string.Format(Images, game.Attribute("GoNoGoWrongImage2").Value).RemoveFirstSlash())),
                    IsWrong = false
                },
                new GameOption
                {
                    Option  = new ImageBrush(StreamManipulation.ExtractBitmapImage(archive, string.Format(Images, game.Attribute("GoNoGoWrongImage3").Value).RemoveFirstSlash())),
                    IsWrong = false
                }
            };

            activity.TriggerInterval = TimeSpan.FromSeconds(Convert.ToInt32(game.Attribute("TriggerInterval").Value));
            activity.Activities      = new NoGoNoActivity[] { gameActivity };
        }
Esempio n. 3
0
        private static BookPage ExtractBookPage(ZipArchive archive, XElement pageElement)
        {
            if (archive == null)
            {
                throw new ArgumentNullException("archive");
            }

            if (pageElement == null)
            {
                throw new ArgumentNullException("pageElement");
            }

            BookPage page = new BookPage
            {
                Background  = new ImageBrush(StreamManipulation.ExtractBitmapImage(archive, string.Format(Images, pageElement.Attribute("backgroundPath").Value).RemoveFirstSlash())),
                TextAssets  = new ReadOnlyObservableCollection <TextAsset>(new ObservableCollection <TextAsset>(ExtractTextAssets(pageElement.Descendants(TextAssetTag)))),
                ImageAssets = new ReadOnlyObservableCollection <ImageAsset>(new ObservableCollection <ImageAsset>(ExtractImageAssets(archive, pageElement.Descendants(ImageAssetTag)))),
                KinectGame  = ExtractKinectActivity(archive, pageElement.Descendants("GameAsset").SingleOrDefault(), pageElement)
            };

            return(page);
        }
Esempio n. 4
0
        private static void ExtractOddOneOutActivity(ZipArchive archive, IEnumerable <XElement> sequencies, OddOneOutGame activity)
        {
            List <OddOneOutActivity> seqs = new List <OddOneOutActivity>();

            foreach (XElement sequence in sequencies)
            {
                OddOneOutActivity seq = new OddOneOutActivity
                {
                    new GameOption
                    {
                        Option  = new ImageBrush(StreamManipulation.ExtractBitmapImage(archive, string.Format(Images, sequence.Attribute("rightAnswerPath").Value).RemoveFirstSlash())),
                        IsWrong = true
                    },
                    new GameOption
                    {
                        Option  = new ImageBrush(StreamManipulation.ExtractBitmapImage(archive, string.Format(Images, sequence.Attribute("WrongAnswerPath1").Value).RemoveFirstSlash())),
                        IsWrong = false
                    },
                    new GameOption
                    {
                        Option  = new ImageBrush(StreamManipulation.ExtractBitmapImage(archive, string.Format(Images, sequence.Attribute("WrongAnswerPath2").Value).RemoveFirstSlash())),
                        IsWrong = false
                    },
                    new GameOption
                    {
                        Option  = new ImageBrush(StreamManipulation.ExtractBitmapImage(archive, string.Format(Images, sequence.Attribute("WrongAnswerPath3").Value).RemoveFirstSlash())),
                        IsWrong = false
                    }
                };

                seq.PositiveFeedback = sequence.Attribute("positiveFeedback").Value;
                seq.NegativeFeedback = sequence.Attribute("negativeFeedback").Value;

                seqs.Add(seq);
            }

            activity.Activities = seqs.ToArray();
        }