예제 #1
0
        /// <summary>
        /// 设置本节点在生成Xhtml时的标签,默认是div
        /// </summary>
        protected virtual void TagCreator()
        {
            XhtmlSection ownerPage = (XhtmlSection)this._ParentXhtmlElement.OwnerPage;

            this._XhtmlElement = ownerPage.CreateXhtmlDiv();
            this._ParentXhtmlElement.AppendChild(this._XhtmlElement);
        }
예제 #2
0
        private void 快速测试F5ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            XhtmlSection sec = new XhtmlSection();

            XhtmlTags.Img img = sec.CreateXhtmlImg();
            img.Builder(new CssSection("css"), "alt", "hspace", "src", Xhtml.Align.bottom, "vspace", "1", "name");
            this.codeTextBox.Text = img.ToString();


            XhtmlTags.A a = sec.CreateXhtmlA();
            a.Builder("a", "title", Xhtml.Target._parent, 1, 't');
            this.outXmlTextBox.Text = a.ToString();
        }
예제 #3
0
        /// <summary>
        /// OK事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void okButton_Click(object sender, EventArgs e)
        {
            XhtmlSection section = new XhtmlSection();

            XhtmlTags.A aTag = section.CreateXhtmlA();
            if (mainTabControl.SelectedIndex == 0)
            {
                string strUrl = "[url:]" + linkTitleTextBox.Text;
                if (!String.IsNullOrEmpty(bookmarkComboBox.Text.Trim()))
                {
                    strUrl += "#" + bookmarkComboBox.Text.Trim();
                }
                aTag.Href      = strUrl;
                aTag.LinkText  = linkTextTextBox.Text;
                aTag.Title     = linkTitleTextBox.Text;
                aTag.Target    = targetComboBox.Text;
                aTag.TabIndex  = tabKeyIndexTextBox.Text;
                aTag.Accesskey = accesskeyTextBox.Text;

                if (_aElement == null)
                {
                    return;
                }

                XmlElement ele = (XmlElement)aTag.ToXmlNode();
                //将原来属性删除掉,重新赋值
                _aElement.Attributes.RemoveAll();
                foreach (XmlAttribute att in ele.Attributes)
                {
                    _aElement.SetAttribute(att.Name, att.Value);
                }
            }
            else if (mainTabControl.SelectedIndex == 1)
            {
                aTag.Href = "mailto:" + emailTextTextBox.Text;

                XmlElement ele = (XmlElement)aTag.ToXmlNode();
                //将原来属性删除掉,重新赋值
                _aElement.Attributes.RemoveAll();
                if (ele.HasAttribute("href"))
                {
                    _aElement.SetAttribute("href", ele.Attributes["href"].Value);
                    XmlDocument xmlDoc = new XmlDocument();
                    //XmlText xmlText = _aElement.OwnerDocument.CreateTextNode(emailSubjectTextBox.Text);
                    XmlText xmlText = xmlDoc.CreateTextNode(emailSubjectTextBox.Text);
                    _aElement.AppendChild(xmlText);
                }
            }
        }
예제 #4
0
        public static XhtmlTags.Img GetDefaultPicHtml(string picPath, string customerId)
        {
            XhtmlSection _section = new XhtmlSection();

            XhtmlTags.Img img = _section.CreateXhtmlImg();

            Image      upImage = Image.FromFile(picPath);
            string     width   = upImage.Width.ToString();
            string     height  = upImage.Height.ToString();
            CssSection css     = new CssSection();

            css.Properties["width"]  = width;
            css.Properties["height"] = height;
            img.Builder(css, "0", "0", customerId, Xhtml.Align.left, "0", "0", "img");
            return(img);
        }
예제 #5
0
        /// <summary>
        /// 资源的高级设置
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ResourceHighSetting_Click(object sender, EventArgs e)
        {
            if (resourceFilesListView.SelectedItems.Count != 1)
            {
                return;                                                 //不支持多选
            }
            MyListItem myitem = resourceFilesListView.SelectedItems[0] as MyListItem;

            if (myitem is MyListFileItem)
            {
                BaseForm        form         = new BaseForm();
                XhtmlTagElement xhtmlElement = null;// new XhtmlTagElement();
                XhtmlSection    _section     = new XhtmlSection();
                string          strHref      = "[url: " + ((MyListFileItem)myitem).Element.Id + "]";
                switch (((MyListFileItem)myitem).ItemMediaType)
                {
                case MediaFileType.None:
                    break;

                case MediaFileType.Pic:
                    #region 图片
                {
                    xhtmlElement = _section.CreateXhtmlImg();
                    ((XhtmlTags.Img)xhtmlElement).Src = strHref;
                    form = new InsertPicCodeForm(xhtmlElement, ((MyListFileItem)myitem).Element.AbsoluteFilePath);
                    break;
                }

                    #endregion
                case MediaFileType.Flash:
                    #region Flash
                {
                    xhtmlElement = _section.CreateXhtmlFlash();

                    CssSection style = new CssSection();
                    ((XhtmlTags.Flash)xhtmlElement).Builder(style, "", strHref, Xhtml.Align.left, "", -1, -1, "", "", "");
                    form = new InsertFlashCodeForm(xhtmlElement, ((MyListFileItem)myitem).Element.AbsoluteFilePath);

                    break;
                }

                    #endregion
                case MediaFileType.Audio:
                    #region Audio
                {
                    xhtmlElement = _section.CreateXhtmlObject();
                    //((XhtmlTags.Object)xhtmlElement).Src = strHref;
                    form = new InsertAudioCodeForm(xhtmlElement, ((MyListFileItem)myitem).Element.AbsoluteFilePath);
                    break;
                }

                    #endregion
                case MediaFileType.Video:
                    #region Video
                {
                    xhtmlElement = _section.CreateXhtmlObject();
                    //((XhtmlTags.Object)xhtmlElement).Src = strHref;
                    form = new InsertVideoCodeForm(xhtmlElement, ((MyListFileItem)myitem).Element.AbsoluteFilePath);
                    break;
                }

                    #endregion
                default:
                    Debug.Fail("未知的type:" + ((MyListFileItem)myitem).ItemMediaType.ToString());
                    break;
                }
                if (form.ShowDialog() == DialogResult.OK)
                {
                    ((MyListFileItem)myitem).XmlAttribute = (XmlElement)xhtmlElement.ToXmlNode();
                }
            }
        }
예제 #6
0
        /// <summary>
        /// 根据当前节点的特性来设置该节点
        /// </summary>
        protected virtual void MarkXhtmlElement(PageSection pageSection)
        {
            switch (pageSection)
            {
            case PageSection.MainPage:
            {
                _XhtmlElement = new XhtmlSection();
                string       tmpltFullFile = this.ToHtmlHelper.TmpltRelativeUrl;
                XhtmlElement tag           = _XhtmlElement.CreateXhtmlCommentShtml
                                                 (tmpltFullFile + this.SdsiteElement.TmpltId + Utility.Const.ShtmlFileExt);
                _XhtmlElement.AppendChild(tag);
                this._isAlreadyToMainPageHtml = true;
                break;
            }

            case PageSection.Head:
            {
                _HeadXhtmlElement = new XhtmlSection();

                #region Title

                XhtmlTagElement title = _HeadXhtmlElement.CreateXhtmlTitle();
                title.InnerText = this.Title;
                _HeadXhtmlElement.AppendChild(title);

                #endregion

                #region keywords

                XhtmlAtts.Name    name;
                StringBuilder     sb;
                XhtmlAtts.Content content;

                if (!(this.PageKeywords == null))
                {
                    name = new XhtmlAtts.Name("keywords");
                    sb   = new StringBuilder();
                    foreach (string str in this.PageKeywords)
                    {
                        sb.Append(str).Append(',');
                    }
                    content = new XhtmlAtts.Content(sb.ToString().TrimEnd(','));
                    XhtmlTagElement keyword = _HeadXhtmlElement.CreateXhtmlMeta(name, content);
                    _HeadXhtmlElement.AppendChild(keyword);
                }

                #endregion

                #region description

                name    = new XhtmlAtts.Name("description");
                content = new XhtmlAtts.Content(this.PageSummary);
                XhtmlTagElement description = _HeadXhtmlElement.CreateXhtmlMeta(name, content);
                _HeadXhtmlElement.AppendChild(description);

                #endregion

                this._isAlreadyToHeadHtml = true;
                break;
            }

            case PageSection.Content:
            {
                SdsiteXmlDocument doc = (SdsiteXmlDocument)this.SdsiteElement.OwnerAnyDocument;

                string           tmpltId = this.SdsiteElement.TmpltId;
                TmpltXmlDocument tmplt   = doc.GetTmpltDocumentById(this.SdsiteElement.TmpltId);
                XhtmlSection     ele     = (XhtmlSection)tmplt.GetContentSnipEle().XhtmlElement;
                if (ele == null)
                {
                    SnipXmlElement snip = tmplt.GetContentSnipEle();
                    snip.MarkXhtmlElement(this);
                    ele = (XhtmlSection)tmplt.GetContentSnipEle().XhtmlElement;
                }
                _ContentXhtmlElement = ele;

                this._isAlreadyToContentHtml = true;
                break;
            }

            case PageSection.None:
            default:
                break;
            }
        }