Esempio n. 1
0
 ///<summary> Constructor. </summary>
 public HtmlTagNode(HtmlTagNode aParentNode, HtmlTag aTag)
     : base()
 {
     isRoot = false;
     parentNode = aParentNode;
     tag = aTag;
     childTags = new List<HtmlTagNode>();
 }
Esempio n. 2
0
        /// <summary> Add a Non TextTag to Tag List </summary>        
        internal void addTag(HtmlTag aTag)
        {
            //            HtmlTagNode newNode = new HtmlTagNode(
            if (previousNode == null) { previousNode = tree; }

            while (!previousNode.CanAdd(aTag))
                previousNode = previousNode.Parent;

            previousNode = previousNode.Add(aTag);
        }
Esempio n. 3
0
 public void UpdateStyle(HtmlTag aTag)
 {
     if (!aTag.IsEndTag)
         activeStyle.Add(aTag);
     else
         for (int i = activeStyle.Count - 1; i >= 0; i--)
             if ('/' + activeStyle[i].Name == aTag.Name)
             {
                 activeStyle.RemoveAt(i);
                 break;
             }
     updateStyle();
 }
Esempio n. 4
0
 private static bool matchHeader(HtmlTag input, CssHeaderStyleType chs)
 {
     return (((chs.tagName == CssHeaderStyleType.UnspecifiedTagName) ||
               (input.Name == chs.tagName)) &&
               ((chs.tagClass == "") || (chs.tagClass == input["class"])) &&
               ((chs.tagID == "") || (chs.tagID == input["id"])));
 }
Esempio n. 5
0
 private static bool haveOtherClassID(HtmlTag input, CssHeaderStyleType chs)
 {
     bool retVal = false;
     if ((chs.tagClass != "") && (input["class"] != ""))
         retVal = (chs.tagClass == input["class"]);
     if ((chs.tagID != "") && (input["id"] != ""))
         retVal = (chs.tagID == input["id"]);
     return retVal;
 }
Esempio n. 6
0
        //        /// <summary>
        //        /// Loop and check if currenTag matched the list ParentTagNames
        //        /// </summary>
        //        internal static bool MatchParentTags(HtmlTag currentTag, ArrayList parentTagNames)
        //        {
        //            if (parentTagNames == null) return false;
        //            
        //            HtmlTag tempTag;
        //            for (Int32 i = parentTagNames.Count -1; i >= 0; i--)
        //                if (!(Utils.MatchParentTag(currentTag, (string)parentTagNames[i], out tempTag)))
        //                    return false;
        //            
        //            return true;
        //        }
        /// <summary>
        /// Check if currentTag matches the header
        /// </summary>
        internal static bool MatchCurrentTag(HtmlTag currentTag, string header)
        {
            CssHeaderStyleType chs = new CssHeaderStyleType(header);
            bool retVal = true;//((chs.tagClass == "") && (chs.tagID == ""));

            retVal = retVal && ((chs.tagClass == "") ||
                                ((currentTag.Contains("class")) &&
                                 (chs.tagClass == currentTag["class"])));
            retVal = retVal && ((chs.tagID == "") ||
                                ((currentTag.Contains("id")) &&
                                                     (chs.tagID == currentTag["id"])));

            return retVal;
        }
Esempio n. 7
0
        public HtmlTagNode Add(HtmlTag aTag)
        {
            if (!CanAdd(aTag))
                throw new Exception("Cannot add here, check your coding.");

            HtmlTagNode retVal = new HtmlTagNode(this, aTag);
            Items.Add(retVal);

            if (aTag.Name == '/' + tag.Name)
                return Parent;
            else return retVal;
        }
Esempio n. 8
0
 ///<summary> Constructor, hide from user view. </summary>
 private HtmlTagNode(HtmlTag aTag)
 {
     ;
 }
Esempio n. 9
0
        public virtual bool CanAdd(HtmlTag aTag)
        {
            if (tag.IsEndTag)
                return false;

            if ((aTag.Name == '/' + tag.Name) ||
                (aTag.Level < tag.Level))
                return true;
            return false;
        }
Esempio n. 10
0
 public override bool CanAdd(HtmlTag aTag)
 {
     return true;
 }
Esempio n. 11
0
 public HtmlTagTree()
     : base(null, null)
 {
     isRoot = true;
     tag = new HtmlTag("master","");
 }
Esempio n. 12
0
        private Inline UpdateElement(HtmlTag aTag)
        {
            Inline retVal = null;

            switch (aTag.Name)
            {
                case "binding":
                case "text":
                    if (aTag.Name == "binding")
                    {
                        retVal = new Bold(new Run("{Binding}"));
                        if (aTag.Contains("path") && (textBlock.DataContext != null))
                        {
                            object obj = textBlock.DataContext;
                            PropertyInfo pi = obj.GetType().GetProperty(aTag["path"]);
                            if (pi != null && pi.CanRead)
                                retVal = new Run(pi.GetValue(obj, null).ToString());
                        }
                    }
                    else
                        retVal = new Run(aTag["value"]);

                    if (currentState.SubScript) retVal.SetValue(Typography.VariantsProperty, FontVariants.Subscript);
                    if (currentState.SuperScript) retVal.SetValue(Typography.VariantsProperty, FontVariants.Superscript);
                    if (currentState.Bold) retVal = new Bold(retVal);
                    if (currentState.Italic) retVal = new Italic(retVal);
                    if (currentState.Underline) retVal = new Underline(retVal);

                    if (currentState.Foreground.HasValue)
                        retVal.Foreground = new SolidColorBrush(currentState.Foreground.Value);

                    if (currentState.Font != null)
                        try { retVal.FontFamily = new FontFamily(currentState.Font); }
                        catch { } //Font name not found...

                    if (currentState.FontSize.HasValue)
                        retVal.FontSize = currentState.FontSize.Value;

                    break;
                case "br":
                    retVal = new LineBreak();
                    break;
                default:
                    Debug.WriteLine("UpdateElement - " + aTag.Name + " not handled.");
                    retVal = new Run();
                    break;
            }

            if (currentState.HyperLink != null && currentState.HyperLink != "")
            {
                Hyperlink link = new Hyperlink(retVal);
                try
                {
                    link.NavigateUri = new Uri(currentState.HyperLink);
                }
                catch
                {
                    link.NavigateUri = null;
                }
                retVal = link;
            }

            return retVal;
        }
Esempio n. 13
0
 private void UpdateStyle(HtmlTag aTag)
 {
     currentState.UpdateStyle(aTag);
 }