Ejemplo n.º 1
0
 public Floor(Start start, Transition transition, Dictionary<string, Tile> tiles, double _lockingPeriod, int _systemAutoLockPeriod, String _setupID, Tile upperTile)
 {
     Start = start;
     Transition = transition;
     Tiles = tiles;
     LockingPeriod = _lockingPeriod;
     SystemAutoLockPeriod = _systemAutoLockPeriod;
     SetupID = _setupID;
     UpperTile = upperTile;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Initializes an instance of Start in XElement format with specified contents and attributes.
        /// </summary>
        /// <param name="start">RippleDictionary.Start</param>
        /// <returns></returns>
        private static XElement GetXElementStart(Start start)
        {
            XElement eAnimation = new XElement(XMLElementsAndAttributes.Animation,
                new XAttribute(XMLElementsAndAttributes.Name, start.Animation.Name),
                new XAttribute(XMLElementsAndAttributes.Content, start.Animation.Content),
                new XAttribute(XMLElementsAndAttributes.AnimationType, start.Animation.AnimType.ToString())
                );

            XElement eUnlock = new XElement(XMLElementsAndAttributes.Unlock,
                new XAttribute(XMLElementsAndAttributes.Mode, start.Unlock.Mode),
                new XAttribute(XMLElementsAndAttributes.UnlockType, start.Unlock.UnlockType)
                );

            XElement eIntroVideoWaitPeriod = new XElement(XMLElementsAndAttributes.IntroVideoWaitPeriod,
                new XAttribute(XMLElementsAndAttributes.Value, start.IntroVideoWaitPeriod.ToString())
                );

            return new XElement(XMLElementsAndAttributes.Start, eAnimation, eUnlock, eIntroVideoWaitPeriod);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the Floor tag from the Ripple XML.
        /// </summary>
        /// <param name="xml"></param>
        /// <returns>RippleDictionary.Floor</returns>
        /// <exception cref="System.NullReferenceException
        ///     System.ArgumentNullException
        ///     System.FormatException
        ///     System.OverflowException
        ///     RippleDictionary.UndefinedUnlockException
        ///     RippleDictionary.TileTypeNotKnownException
        ///     RippleDictionary.InvalidStyleException
        ///     RippleDictionary.InvalidCoordinateException
        ///     RippleDictionary.TypeNotKnownException
        ///     RippleDictionary.ActionNotKnownException
        ///     RippleDictionary.UnparseableXMLException" />
        public static Floor GetFloorFromXML(string xml)
        {
            Floor floor = null;

            XDocument xdoc = XDocument.Load(GenerateRippleDictionaryStreamFromXML(xml));

            foreach (var xel in xdoc.Root.Elements())
            {
                if (xel.Name == XMLElementsAndAttributes.Floor)
                {
                    Start start = null;
                    Transition transition = null;
                    Tile upperTile = null;
                    Dictionary<string, Tile> tiles = new Dictionary<string, Tile>();
                    double lockingPeriod = 0.0;
                    int systemAutoLockPeriod = 0;
                    String setupID = String.Empty;

                    foreach (var tagContent in xel.Elements())
                    {
                        if (tagContent.Name == XMLElementsAndAttributes.Start)
                        {
                            Animation animation;
                            Unlock unlock;
                            int introVideoWaitPeriod;

                            GetStartContent(tagContent, out animation, out unlock, out introVideoWaitPeriod);

                            start = new Start(animation, unlock, introVideoWaitPeriod);
                        }
                        else if (tagContent.Name == XMLElementsAndAttributes.Transition)
                        {
                            string music = tagContent.Attribute(XMLElementsAndAttributes.Music).Value;
                            string animation = tagContent.Attribute(XMLElementsAndAttributes.Animation).Value;

                            transition = new Transition(music, animation);
                        }
                        else if (tagContent.Name == XMLElementsAndAttributes.Tiles)
                        {
                            tiles = GetTilesDictionaryFromTag(tagContent);
                        }
                        else if (tagContent.Name == XMLElementsAndAttributes.UpperTile)
                        {
                            string id = tagContent.Attribute(XMLElementsAndAttributes.Id).Value;
                            string name = tagContent.Attribute(XMLElementsAndAttributes.Name).Value;
                            string tileType = tagContent.Attribute(XMLElementsAndAttributes.TileType).Value;
                            string content = tagContent.Attribute(XMLElementsAndAttributes.Content).Value;
                            string color = tagContent.Attribute(XMLElementsAndAttributes.Color).Value;
                            string action = tagContent.Attribute(XMLElementsAndAttributes.Action).Value;
                            var actionURIObj = tagContent.Attribute(XMLElementsAndAttributes.ActionURI);
                            string actionURI = actionURIObj != null ? actionURIObj.Value : null;
                            string style = tagContent.Attribute(XMLElementsAndAttributes.Style).Value;
                            string coordinate = tagContent.Attribute(XMLElementsAndAttributes.Coordinate).Value;
                            var correspondingScreenContentTypeObj = tagContent.Attribute(XMLElementsAndAttributes.CorrespondingScreenContentType);
                            string correspondingScreenContentType = correspondingScreenContentTypeObj != null ? correspondingScreenContentTypeObj.Value : null;

                            upperTile = new Tile(id, name, GetTileType(tileType), color, GetStyle(style), GetCoordinate(coordinate), GetAction(action), actionURI, content, GetType(correspondingScreenContentType), null);
                        }
                        else if (tagContent.Name == XMLElementsAndAttributes.LockingPeriod)
	                    {
		                    lockingPeriod = Convert.ToDouble(tagContent.Value);
	                    }
                        else if (tagContent.Name == XMLElementsAndAttributes.SystemAutoLockPeriod)
                        {
                            systemAutoLockPeriod = Convert.ToInt32(tagContent.Value);
                        }
                        else if (tagContent.Name == XMLElementsAndAttributes.SetupID)
                        {
                            setupID = tagContent.Value;
                        }
                    }

                    floor = new Floor(start, transition, tiles, lockingPeriod, systemAutoLockPeriod, setupID, upperTile);
                }
                else
                {
                    continue;
                }
            }

            return floor;
        }