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
 public Tile(string id, string name, TileType tileType, string color, Style style, Coordinate coordinate, TileAction action, string actionURI, string content = null, ContentType? correspondingScreenContentType = null, Dictionary<string, Tile> subTiles = null)
 {
     Id = id;
     Name = name;
     TileType = tileType;
     Color = (Color)ColorConverter.ConvertFromString(color);
     Style = style;
     Coordinate = coordinate;
     Action = action;
     ActionURI = actionURI;
     Content = content;
     CorrespondingScreenContentType = correspondingScreenContentType;
     SubTiles = subTiles;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tiles"></param>
        /// <returns></returns>
        private static List<XElement> GetXElementTiles(Dictionary<string, Tile> tiles)
        {
            List<XElement> eTiles = new List<XElement>();
            XElement eTile = null;

            foreach (var tile in tiles)
            {
                eTile = GetXElementTile(tile.Value);

                eTiles.Add(eTile);
            }

            return eTiles;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the tile information from the tileTag.
        /// </summary>
        /// <param name="tileTag"></param>
        /// <returns>RippleDictionary.Tile</returns>
        /// <exception cref="System.ArgumentNullException
        ///     RippleDictionary.TileTypeNotKnownException
        ///     RippleDictionary.InvalidStyleException
        ///     RippleDictionary.InvalidCoordinateException
        ///     RippleDictionary.TypeNotKnownException
        ///     RippleDictionary.ActionNotKnownException" />
        private static Tile GetTile(XElement tileTag)
        {
            Tile tile = null;
            string id, name, tileType, content, color, action, actionURI, style, coordinate, correspondingScreenContentType;
            Dictionary<string, Tile> subTiles = new Dictionary<string, Tile>();

            id = tileTag.Attribute(XMLElementsAndAttributes.Id).Value;
            name = tileTag.Attribute(XMLElementsAndAttributes.Name).Value;
            tileType = tileTag.Attribute(XMLElementsAndAttributes.TileType).Value;
            content = tileTag.Attribute(XMLElementsAndAttributes.Content).Value;
            color = tileTag.Attribute(XMLElementsAndAttributes.Color).Value;
            action = tileTag.Attribute(XMLElementsAndAttributes.Action).Value;
            var actionURIObj = tileTag.Attribute(XMLElementsAndAttributes.ActionURI);
            actionURI = actionURIObj != null ? actionURIObj.Value : null;
            style = tileTag.Attribute(XMLElementsAndAttributes.Style).Value;
            coordinate = tileTag.Attribute(XMLElementsAndAttributes.Coordinate).Value;
            var correspondingScreenContentTypeObj = tileTag.Attribute(XMLElementsAndAttributes.CorrespondingScreenContentType);
            correspondingScreenContentType = correspondingScreenContentTypeObj != null ? correspondingScreenContentTypeObj.Value : null;

            if (tileTag.Elements().Count() != 0)
            {
                subTiles = GetTilesDictionaryFromTag(tileTag);
            }
            else
            {
                subTiles = null;
            }

            tile = new Tile(id, name, GetTileType(tileType), color, GetStyle(style), GetCoordinate(coordinate), GetAction(action), actionURI, content, GetType(correspondingScreenContentType), subTiles);

            return tile;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets all the tiles from the tagContent's parent node.
        /// </summary>
        /// <param name="tagContent"></param>
        /// <param name="parentTile"></param>
        /// <returns>"Dictionary&lt;string, RippleDictionary.Tile&gt;"</returns>
        /// <exception cref="System.ArgumentNullException
        ///     RippleDictionary.UnparseableXMLException
        ///     RippleDictionary.TileTypeNotKnownException
        ///     RippleDictionary.InvalidStyleException
        ///     RippleDictionary.InvalidCoordinateException
        ///     RippleDictionary.TypeNotKnownException
        ///     RippleDictionary.ActionNotKnownException" />
        private static Dictionary<string, Tile> GetTilesDictionaryFromTag(XElement tagContent)
        {
            Dictionary<string, Tile> tiles = new Dictionary<string, Tile>();

            foreach (var tileTag in tagContent.Elements())
            {
                Tile tile = GetTile(tileTag);

                tiles.Add(tile.Id, tile);
            }

            return tiles;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets all the tiles from from the file RippleXML.xml existing in the execution directory.
        /// </summary>
        /// <param name="tagContent"></param>
        /// <param name="parentTile"></param>
        /// <returns>"Dictionary&lt;string, RippleDictionary.Tile&gt;"</returns>
        /// <exception cref="System.ArgumentNullException
        ///     RippleDictionary.UnparseableXMLException
        ///     RippleDictionary.TileTypeNotKnownException
        ///     RippleDictionary.InvalidStyleException
        ///     RippleDictionary.InvalidCoordinateException
        ///     RippleDictionary.TypeNotKnownException
        ///     RippleDictionary.ActionNotKnownException" />
        public static Dictionary<string, Tile> GetTilesDictionary()
        {
            Dictionary<string, Tile> tiles = new Dictionary<string, Tile>();

            XDocument xdoc = XDocument.Load(GenerateRippleDictionaryStreamFromXML(XMLElementsAndAttributes.RippleXMLFile));

            foreach (var xel in xdoc.Root.Elements())
            {
                if (xel.Name == XMLElementsAndAttributes.Floor)
                {
                    foreach (var tagContent in xel.Elements())
                    {
                        if (tagContent.Name == XMLElementsAndAttributes.Tiles)
                        {
                            tiles = GetTilesDictionaryFromTag(tagContent);
                        }
                    }
                }
                else
                {
                    continue;
                }
            }

            return tiles;
        }        
Ejemplo n.º 7
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;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets the Screen tag from the Ripple XML.
        /// </summary>
        /// <param name="xml"></param>
        /// <returns>RippleDictionary.Screen</returns>
        /// <exception cref="System.NullReferenceException
        ///     System.ArgumentNullException
        ///     RippleDictionary.TypeNotKnownException
        ///     RippleDictionary.UnparseableXMLException" />
        public static Screen GetScreenFromXML(string xml)
        {
            Screen screen = null;
            XDocument xdoc = XDocument.Load(GenerateRippleDictionaryStreamFromXML(xml));

            foreach (var xel in xdoc.Root.Elements())
            {
                if (xel.Name == XMLElementsAndAttributes.Screen)
                {
                    
                    string type, id, header, content;
                    Dictionary<string, ScreenContent> screenContents = new Dictionary<string, ScreenContent>();
                    ScreenContent screenContent;
                    foreach (var tagContent in xel.Elements())
                    {
                        if (tagContent.Name == XMLElementsAndAttributes.ScreenContent)
                        {
                            type = tagContent.Attribute(XMLElementsAndAttributes.Type).Value;
                            id = tagContent.Attribute(XMLElementsAndAttributes.Id).Value;
                            header = tagContent.Attribute(XMLElementsAndAttributes.Header).Value;
                            content = tagContent.Attribute(XMLElementsAndAttributes.Content).Value;
                            var loopVideoObj = tagContent.Attribute(XMLElementsAndAttributes.LoopVideo);
                            bool loopVideo = loopVideoObj != null ? (loopVideoObj.Value.ToLower() == "true" ? (bool)true : (loopVideoObj.Value.ToLower() == "false" ? (bool)false : false)) : false;

                            screenContent = new ScreenContent(GetType(type), id, header, content, loopVideo);
                            screenContents.Add(screenContent.Id, screenContent);
                        }
                    }

                    screen = new Screen(screenContents); 
                    
                }
                else
                {
                    continue;
                }
            }

            return screen;
        }
Ejemplo n.º 9
0
 public Screen(Dictionary<string, ScreenContent> screenContents)
 {
     ScreenContents = screenContents;
 }