示例#1
0
        public static LibrelioLocalUrl GetLocalUrl(IXmlNode mag)
        {
            if (mag == null)
            {
                return(null);
            }

            if (mag.ChildNodes.Count > 0)
            {
                var index    = Convert.ToInt32(mag.SelectNodes("index")[0].InnerText);
                var title    = mag.SelectNodes("title")[0].InnerText;
                var subtitle = mag.SelectNodes("subtitle")[0].InnerText;
                var path     = mag.SelectNodes("path")[0].InnerText;
                var pos      = 0;
                if (path != "" && path != "ND")
                {
                    pos  = path.LastIndexOf('\\');
                    path = path.Substring(0, pos + 1);
                }
                var metadata = mag.SelectNodes("metadata")[0].InnerText;
                pos      = metadata.LastIndexOf('\\');
                metadata = metadata.Substring(pos + 1);
                var u   = mag.SelectNodes("url")[0].InnerText;
                var rel = mag.SelectNodes("relPath")[0].InnerText;
                var isd = mag.SelectNodes("sampledownloaded")[0].InnerText;

                return(new LibrelioLocalUrl(index, title, subtitle, path, GetFullNameFromUrl(rel), u, rel, isd.Equals("true")));
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        /**
         *   Returns an array of numbers to use numering the dancers
         */
        public static string[] getNumbers(IXmlNode tam)
        {
            var paths  = tam.SelectNodes("path");
            var retval = new string[paths.Count * 2];
            var np     = Math.Min(paths.Count, 4);

            for (int i = 0; i < paths.Count; i++)
            {
                var p = paths.ElementAt(i);
                var n = p.attr("numbers");
                if (n.Length >= 3) // numbers supplied in animation XML
                {
                    retval[i * 2]     = n.Substring(0, 1);
                    retval[i * 2 + 1] = n.Substring(2, 1);
                }
                else if (i > 3) // phantoms
                {
                    retval[i * 2]     = " ";
                    retval[i * 2 + 1] = " ";
                }
                else // default numbers
                {
                    retval[i * 2]     = (i + 1).ToString();
                    retval[i * 2 + 1] = (i + 1 + np).ToString();
                }
            }
            return(retval);
        }
示例#3
0
        private void LoadConferenceDayData(IXmlNode nodeDay)
        {
            Day day = new Day();
            day.Index = int.Parse(nodeDay.Attributes.GetNamedItem("index").InnerText);
            day.Date = DateTime.Parse(nodeDay.Attributes.GetNamedItem("date").InnerText);
            Conference.Days.Add(day);

            XmlNodeList nodesRooms = nodeDay.SelectNodes("room");
            foreach (IXmlNode item in nodesRooms)
            {
                LoadConferenceRoomData(item, day);
            }
        }
示例#4
0
        //  Create a context from a formation defined in XML
        public CallContext(IXmlNode f)
        {
            dancers = new List <Dancer>();
            var fds = f.SelectNodes("dancer");

            for (uint i = 0; i < fds.Count; i++)
            {
                var fd = fds.Item(i);
                //  Assume square geometry
                var m = Matrix.CreateRotation(fd.attr("angle").toDouble() * Math.PI / 180);
                m = m * Matrix.CreateTranslation(fd.attr("x").toDouble(), fd.attr("y").toDouble());
                dancers.Add(new Dancer($"{i * 2 + 1}", $"{i + 1}",
                                       genderMap(fd.attr("gender")), Colors.White, m,
                                       GeometryMaker.makeOne(GeometryType.SQUARE, 0), new List <Movement>()));
                dancers.Add(new Dancer($"{i * 2 + 2}", $"{i + 1}",
                                       genderMap(fd.attr("gender")), Colors.White, m,
                                       GeometryMaker.makeOne(GeometryType.SQUARE, 1), new List <Movement>()));
            }
        }
示例#5
0
        public static string[] getCouples(IXmlNode tam)
        {
            var retval = new string[] { "1", "3", "1", "3",
                                        "2", "4", "2", "4",
                                        "5", "6", "5", "6",
                                        " ", " ", " ", " " };
            var paths = tam.SelectNodes("path");

            for (int i = 0; i < paths.Count; i++)
            {
                var c = paths.ElementAt(i).attr("couples");
                if (c.Length > 0)
                {
                    retval[i * 2]     = c.Substring(0, 1);
                    retval[i * 2 + 1] = c.Substring(2, 1);
                }
            }
            return(retval);
        }
        protected NextbusPredictions ParsePredictionsXml(IXmlNode predictionsNode)
        {
            NextbusPredictions predictions = new NextbusPredictions();

            predictions.AgencyTitle = GetAttributeValue("agencyTitle", predictionsNode.Attributes);
            predictions.RouteTag    = GetAttributeValue("routeTag", predictionsNode.Attributes);
            predictions.RouteTitle  = GetAttributeValue("routeTitle", predictionsNode.Attributes);
            predictions.StopTag     = GetAttributeValue("stopTag", predictionsNode.Attributes);
            predictions.StopTitle   = GetAttributeValue("stopTitle", predictionsNode.Attributes);
            predictions.Directions  = new List <NextbusPredictionsDirection>();
            // TODO

            predictions.Messages = new List <NextbusMessage>();
            foreach (var messageNode in predictionsNode.SelectNodes("message"))
            {
                predictions.Messages.Add(new NextbusMessage()
                {
                    Text     = GetAttributeValue("text", messageNode.Attributes),
                    Priority = GetAttributeValue("priority", messageNode.Attributes)
                });
            }

            return(predictions);
        }
        public BlogProviderFromXml(IXmlNode providerNode)
        {
            string id = NodeText(providerNode.SelectSingleNode("id"));

            if (id.Length == 0)
            {
                throw new ArgumentException("Missing Id parameter");
            }

            string name = NodeText(providerNode.SelectSingleNode("name"));

            if (name.Length == 0)
            {
                throw new ArgumentException("Missing Name parameter");
            }

            string description = NodeText(providerNode.SelectSingleNode("description"));

            string link = NodeText(providerNode.SelectSingleNode("link"));

            string clientType = NodeText(providerNode.SelectSingleNode("clientType"));

            if (clientType.Length == 0)
            {
                throw new ArgumentException("Missing ClientType parameter");
            }
            //if ( !BlogClientManager.IsValidClientType(clientType) )
            //	throw new ArgumentException("Invalid ClientType: " + clientType) ;

            string postApiUrl = NodeText(providerNode.SelectSingleNode("postApiUrl"));

            if (postApiUrl.Length == 0)
            {
                throw new ArgumentException("Invalid PostApiUrl");
            }

            // visibiilty flag
            bool visible = BlogClientOptions.ReadBool(NodeText(providerNode.SelectSingleNode("visible")), true);;

            // auto-detection
            string homepageUrlPattern     = NodeText(providerNode.SelectSingleNode("homepageUrlPattern"));
            string homepageContentPattern = NodeText(providerNode.SelectSingleNode("homepageContentPattern"));
            string rsdEngineNamePattern   = NodeText(providerNode.SelectSingleNode("rsdEngineNamePattern"));
            string rsdHomepageLinkPattern = NodeText(providerNode.SelectSingleNode("rsdHomepageLinkPattern"));

            // rsd client type mappings
            ArrayList rsdClientTypeMappings = new ArrayList();
            var       mappingNodes          = providerNode.SelectNodes("rsdClientTypeMappings/mapping");

            foreach (var mappingNode in mappingNodes)
            {
                string rsdClientType    = NodeText(mappingNode.SelectSingleNode("@rsdClientType"));
                string writerClientType = NodeText(mappingNode.SelectSingleNode("@clientType"));
                if (rsdClientType != String.Empty && writerClientType != String.Empty)
                {
                    rsdClientTypeMappings.Add(new RsdClientTypeMapping(rsdClientType, writerClientType));
                }
            }

            // provider faults
            ArrayList providerFaults = new ArrayList();
            var       faultNodes     = providerNode.SelectNodes("faults/fault");

            foreach (var faultNode in faultNodes)
            {
                string codePattern   = NodeText(faultNode.SelectSingleNode("codePattern"));
                string stringPattern = NodeText(faultNode.SelectSingleNode("stringPattern"));
                string messageId     = NodeText(faultNode.SelectSingleNode("messageId"));
                if (messageId != String.Empty)
                {
                    providerFaults.Add(new ProviderFault(codePattern, stringPattern, messageId));
                }
            }


            // parse options (create generic options object to populate defaults)
            var optionsNode = providerNode.SelectSingleNode("options");

            foreach (var node in optionsNode.ChildNodes)
            {
                if (node.NodeType == NodeType.ElementNode)
                {
                    if (_options.ContainsKey(node.NodeName))
                    {
                        _options.Remove(node.NodeName);
                    }
                    _options.Add(node.NodeName, node.InnerText.Trim());
                }
            }

            StringId   postApiUrlLabel           = StringId.CWSelectProviderApiUrlLabel;
            XmlElement postApiUrlDescriptionNode = providerNode.SelectSingleNode("postApiUrlLabel") as XmlElement;

            if (postApiUrlDescriptionNode != null)
            {
                try
                {
                    postApiUrlLabel = (StringId)Enum.Parse(
                        typeof(StringId),
                        "CWSelectProviderApiUrlLabel_" + postApiUrlDescriptionNode.InnerText,
                        false);
                }
                catch
                {
                    Debug.Fail("Invalid value for postApiUrlLabel");
                }
            }

            string appid     = null;
            var    appIdNode = providerNode.SelectSingleNode("appid/text()");

            if (appIdNode != null && !string.IsNullOrEmpty((string)appIdNode.NodeValue))
            {
                appid = (string)appIdNode.NodeValue;
            }

            // initialize
            Init(id, name, description, link, clientType, postApiUrl, postApiUrlLabel, appid,
                 homepageUrlPattern, homepageContentPattern,
                 rsdClientTypeMappings.ToArray(typeof(RsdClientTypeMapping)) as RsdClientTypeMapping[],
                 rsdEngineNamePattern, rsdHomepageLinkPattern,
                 providerFaults.ToArray(typeof(ProviderFault)) as ProviderFault[],
                 visible);
        }
示例#8
0
        public static LibrelioLocalUrl GetLocalUrl(IXmlNode mag)
        {
            if (mag == null) return null;

            if (mag.ChildNodes.Count > 0)
            {
                var index = Convert.ToInt32(mag.SelectNodes("index")[0].InnerText);
                var title = mag.SelectNodes("title")[0].InnerText;
                var subtitle = mag.SelectNodes("subtitle")[0].InnerText;
                var path = mag.SelectNodes("path")[0].InnerText;
                var pos = 0;
                if (path != "" && path != "ND")
                {
                    pos = path.LastIndexOf('\\');
                    path = path.Substring(0, pos + 1);
                }
                var metadata = mag.SelectNodes("metadata")[0].InnerText;
                pos = metadata.LastIndexOf('\\');
                metadata = metadata.Substring(pos + 1);
                var u = mag.SelectNodes("url")[0].InnerText;
                var rel = mag.SelectNodes("relPath")[0].InnerText;
                var isd = mag.SelectNodes("sampledownloaded")[0].InnerText;

                return new LibrelioLocalUrl(index, title, subtitle, path, GetFullNameFromUrl(rel), u, rel, isd.Equals("true"));
            }
            else
            {
                return null;
            }
        }
        protected NextbusPredictions ParsePredictionsXml(IXmlNode predictionsNode)
        {
            NextbusPredictions predictions = new NextbusPredictions();

            predictions.AgencyTitle = GetAttributeValue("agencyTitle", predictionsNode.Attributes);
            predictions.RouteTag = GetAttributeValue("routeTag", predictionsNode.Attributes);
            predictions.RouteTitle = GetAttributeValue("routeTitle", predictionsNode.Attributes);
            predictions.StopTag = GetAttributeValue("stopTag", predictionsNode.Attributes);
            predictions.StopTitle = GetAttributeValue("stopTitle", predictionsNode.Attributes);
            predictions.Directions = new List<NextbusPredictionsDirection>();
            // TODO

            predictions.Messages = new List<NextbusMessage>();
            foreach (var messageNode in predictionsNode.SelectNodes("message"))
            {
                predictions.Messages.Add(new NextbusMessage()
                {
                    Text = GetAttributeValue("text", messageNode.Attributes),
                    Priority = GetAttributeValue("priority", messageNode.Attributes)
                });
            }

            return predictions;
        }
示例#10
0
        //  Takes a path, which is an XML element with children that
        //  are moves or movements.
        //  Returns an array of movements
        public static List <Movement> translatePath(IXmlNode pathelem)
        {
            var nodelist = pathelem.SelectNodes("*");

            return(nodelist.SelectMany(translate).ToList());
        }
        public void resetAnimation()
        {
            if (tam != null)
            {
                leadin  = interactiveDancer < 0 ? 2 : 3;
                leadout = interactiveDancer < 0 ? 2 : 1;
                // if (isRunnning)
                //  doneCallback();
                isRunning = false;
                beats     = 0.0;

                var tlist     = tam.SelectNodes("formation");
                var formation = tlist.Length > 0
          ? tlist.First()                                //  formation defined in animation
          : tam.hasAttr("formation")
          ? TamUtils.getFormation(tam.attr("formation")) // formation reference to formations.xml
          : tam;                                         //  formation passed in for sequencer
                var flist = formation.SelectNodes("dancer");
                dancers = new Dancer[flist.Length * (int)geometry];

                //  Except for the phantoms, these are the standard colors
                //  used for teaching callers
                var dancerColor = geometry == GeometryType.HEXAGON ?
                                  new Color[] { Colors.Red, Colors.ForestGreen, Colors.Magenta,
                                                Colors.Blue, Colors.Yellow, Colors.Cyan,
                                                Colors.LightGray, Colors.LightGray, Colors.LightGray, Colors.LightGray }
          :
                new Color[] { Colors.Red, ColorUtilities.ColorFromHex(0xff00c000), Colors.Blue, Colors.Yellow,
                              Colors.LightGray, Colors.LightGray, Colors.LightGray, Colors.LightGray };
                //  Get numbers for dancers and couples
                //  This fetches any custom numbers that might be defined in
                //  the animation to match a Callerlab or Ceder Chest illustration
                var paths   = tam.SelectNodes("path");
                var numbers = geometry == GeometryType.HEXAGON ?
                              new string[] { "A", "E", "I",
                                             "B", "F", "J",
                                             "C", "G", "K",
                                             "D", "H", "L",
                                             "u", "v", "w", "x", "y", "z" }
        : geometry == GeometryType.BIGON || paths.Length == 0 ?
                new string[] { "1", "2", "3", "4", "5", "6", "7", "8" }
        : TamUtils.getNumbers(tam);
                var couples = geometry == GeometryType.HEXAGON ?
                              new string[] { "1", "3", "5", "1", "3", "5",
                                             "2", "4", "6", "2", "4", "6",
                                             "7", "8", "7", "8", "7", "8" }
          : geometry == GeometryType.BIGON ?
                new string[] { "1", "2", "3", "4", "5", "6", "7", "8" }
          : paths.Length == 0 ?
                new string[] { "1", "3", "1", "3", "2", "4", "2", "4" }
          : TamUtils.getCouples(tam);
                var geoms = GeometryMaker.makeAll(geometry);

                //  Select a random dancer of the correct gender for the interactive dancer
                var icount = -1;
                var im     = Matrix3x2.Identity;
                if (interactiveDancer > 0)
                {
                    var rand     = new Random();
                    var selector = interactiveDancer == (int)Gender.BOY
            ? "dancer[@gender='boy']" : "dancer[@gender='girl']";
                    var glist = formation.SelectNodes(selector);
                    icount = rand.Next(glist.Count);
                    //  If the animations starts with "Heads" or "Sides"
                    //  then select the first dancer.
                    //  Otherwise the formation could rotate 90 degrees
                    //  which would be confusing
                    var title = tam.attr("title");
                    if (title.Contains("Heads") || title.Contains("Sides"))
                    {
                        icount = 0;
                    }
                    //  Find the angle the interactive dancer faces at start
                    //  We want to rotate the formation so that direction is up
                    var iangle = glist.Item((uint)icount).attr("angle").toDouble();
                    im     = Matrix.CreateRotation(-iangle.toRadians()) * im;
                    icount = icount * geoms.Count() + 1;
                }

                //  Create the dancers and set their starting positions
                int dnum = 0;
                for (var i = 0; i < flist.Length; i++)
                {
                    var fd       = flist.ElementAt(i);
                    var x        = fd.attr("x").toDouble();
                    var y        = fd.attr("y").toDouble();
                    var angle    = fd.attr("angle").toDouble();
                    var gender   = fd.attr("gender");
                    var g        = gender == "boy" ? Gender.BOY : gender == "girl" ? Gender.GIRL : Gender.PHANTOM;
                    var movelist = paths.Length > i?TamUtils.translatePath(paths.ElementAt(i))
                                       : new List <Movement>();

                    //  Each dancer listed in the formation corresponds to
                    //  one, two, or three real dancers depending on the geometry
                    foreach (Geometry geom in geoms)
                    {
                        var m    = Matrix3x2.Identity * Matrix.CreateRotation(angle.toRadians()) * Matrix.CreateTranslation(x, y) * im;
                        var nstr = g == Gender.PHANTOM ? " " : numbers[dnum];
                        var cstr = g == Gender.PHANTOM ? " " : couples[dnum];
                        var c    = g == Gender.PHANTOM ? Colors.LightGray : dancerColor[int.Parse(cstr) - 1];
                        //  add one dancer
                        //icount -= 1;
                        if ((int)g == interactiveDancer && --icount == 0)
                        {
                            idancer       = new InteractiveDancer(nstr, cstr, g, c, m, geom.clone(), movelist);
                            dancers[dnum] = idancer;
                        }
                        else
                        {
                            dancers[dnum]        = new Dancer(nstr, cstr, g, c, m, geom.clone(), movelist);
                            dancers[dnum].hidden = g == Gender.PHANTOM && !showPhantoms;
                        }
                        beats = Math.Max(dancers[dnum].beats + leadout, beats);
                        dnum++;
                    }
                } // All dancers added

                //  Initialize other stuff
                parts     = tam.attr("parts") + tam.attr("fractions");
                hasParts  = tam.attr("parts").Length > 0;
                isRunning = false;
                beat      = -leadin;
                prevbeat  = -leadin;
                partbeats = partsValues();
                //  force a redraw
                canvas.Invalidate();
                //  ready callback
                Callouts.animationReady();
            }
        }
示例#12
0
        private void LoadConferenceRoomData(IXmlNode nodeRoom, Day day)
        {
            string roomName = nodeRoom.Attributes.GetNamedItem("name").InnerText;
            Room room = Conference.Rooms.FirstOrDefault(item => item.Name == roomName);
            if(room == null)
            {
                room = new Room() { Name = roomName };
                Conference.Rooms.Add(room);
            }

            XmlNodeList nodesEvents = nodeRoom.SelectNodes("event");
            foreach (IXmlNode item in nodesEvents)
            {
                LoadConferenceEventData(item, day, room);
            }
        }