Exemplo n.º 1
0
        private TeaseDelay CreateDelay(XmlNode pageNode)
        {
            var delayLengthNode = pageNode.SelectSingleNode("delaylength");

            if (delayLengthNode != null)
            {
                var delayLengthMin = delayLengthNode.Attributes["rdmMin"].Value;
                var delayLengthMax = delayLengthNode.Attributes["rdmMax"].Value;

                var delaySecondsNode = delayLengthNode.SelectSingleNode("delayseconds");
                if (delaySecondsNode != null)
                {
                    int seconds;
                    if (Int32.TryParse(delaySecondsNode.InnerText, out seconds) && seconds > 0)
                    {
                        var result = new TeaseDelay();

                        if (delayLengthMin == "0" && delayLengthMax == "0")
                        {
                            result.Seconds = seconds.ToString();
                        }
                        else
                        {
                            result.Seconds = String.Format("({0}..{1})", delayLengthMin, delayLengthMax);
                        }

                        var delayVisibleNode = pageNode.SelectSingleNode("delayvisible");
                        if (delayVisibleNode != null)
                        {
                            result.Style = delayVisibleNode.InnerText.Equals("0") ? DelayStyle.Secret : DelayStyle.Normal;
                        }

                        var targetNode = pageNode.SelectSingleNode("delaytarget");
                        if (targetNode != null)
                        {
                            var delayTargetMin = targetNode.Attributes["rdmMin"].Value;
                            var delayTargetMax = targetNode.Attributes["rdmMax"].Value;
                            var delayTargetId  = targetNode["delaytargetid"].InnerText;

                            if (delayTargetMin == "0" && delayTargetMax == "0")
                            {
                                result.Target = delayTargetId;
                            }
                            else
                            {
                                result.Target = String.Format("{0}({1}..{2})", delayTargetId, delayTargetMin, delayTargetMax);
                            }
                        }
                        return(result);
                    }
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        private TeaseDelay GetDelay(CommonTree delayNode)
        {
            if (delayNode == null)
            {
                return(null);
            }

            var result = new TeaseDelay();

            var timeNode = delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.TIME) as CommonTree;

            if (timeNode != null)
            {
                int secs = System.Convert.ToInt32(timeNode.GetChild(0).Text);
                if (timeNode.GetChild(1).Text == "min")
                {
                    secs = secs * 60;
                }
                result.Seconds = secs.ToString();
            }

            result.Target = GetPageId(delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.TARGET).GetChild(0) as CommonTree);

            var styleNode = delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.STYLE) as CommonTree;

            if (styleNode != null && styleNode.ChildCount > 0)
            {
                switch (styleNode.GetChild(0).Text)
                {
                case "hidden": result.Style = DelayStyle.Hidden; break;

                case "secret": result.Style = DelayStyle.Secret; break;

                default: result.Style = DelayStyle.Normal; break;
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        private TeaseDelay GetDelay(CommonTree delayNode)
        {
            if (delayNode == null)
            {
                return(null);
            }

            var result = new TeaseDelay();

            var timeNode = delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.TIME) as CommonTree;

            if (timeNode != null)
            {
                var minNode = (CommonTree)timeNode.GetFirstChildWithType(FlashTeaseScriptLexer.MIN);
                int minSecs = Convert.ToInt32(minNode.GetChild(0).Text);
                if (minNode.ChildCount > 1)
                {
                    var minUnit = minNode.GetChild(1).Text;
                    switch (minUnit)
                    {
                    case "hrs": { minSecs = minSecs * 60 * 60; break; }

                    case "min": { minSecs = minSecs * 60; break; }

                    default: break;
                    }
                }

                var maxNode = timeNode.GetFirstChildWithType(FlashTeaseScriptLexer.MAX) as CommonTree;
                int maxSecs = -1;
                if (maxNode != null)
                {
                    maxSecs = Convert.ToInt32(maxNode.GetChild(0).Text);
                    if (maxNode.ChildCount > 1)
                    {
                        var maxUnit = maxNode.GetChild(1).Text;
                        switch (maxUnit)
                        {
                        case "hrs": { maxSecs = maxSecs * 60 * 60; break; }

                        case "min": { maxSecs = maxSecs * 60; break; }

                        default: break;
                        }
                    }
                }

                result.Seconds = (maxSecs > minSecs) ? String.Format("({0}..{1})", minSecs, maxSecs) : String.Format("{0}", minSecs);
            }

            result.Target = GetPageId(delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.TARGET).GetChild(0) as CommonTree);

            var styleNode = delayNode.GetFirstChildWithType(FlashTeaseScriptLexer.STYLE) as CommonTree;

            if (styleNode != null && styleNode.ChildCount > 0)
            {
                switch (styleNode.GetChild(0).Text.ToLowerInvariant())
                {
                case "hidden": result.Style = DelayStyle.Hidden; break;

                case "secret": result.Style = DelayStyle.Secret; break;

                default: result.Style = DelayStyle.Normal; break;
                }
            }

            return(result);
        }