コード例 #1
0
        public void CreateHtmlContent(XmlNode node, EnumWebElementPositionType positiontype, int groupId)
        {
            //
            _resourceFiles = new List <WebResourceFile>();
            _htmlParts     = new Dictionary <string, string>();

            bool   b;
            string btimg = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "limnortabs.css");

            if (File.Exists(btimg))
            {
                _resourceFiles.Add(new WebResourceFile(btimg, WebResourceFile.WEBFOLDER_Css, out b));
            }
            //
            XmlUtil.SetAttribute(node, "tabindex", this.TabIndex);
            WebPageCompilerUtility.SetWebControlAttributes(this, node);
            WebPageCompilerUtility.GetElementStyleSize(this, out _widthStyle, out _heighStyle);
            //
            StringBuilder sb = new StringBuilder();

            //
            if (this.Parent is HtmlFlowLayout)
            {
                sb.Append("min-height:");
                sb.Append(this.Height.ToString(CultureInfo.InvariantCulture));
                sb.Append("px;overflow:hidden;");
            }
            else
            {
            }
            //
            WebPageCompilerUtility.CreateWebElementZOrder(this.zOrder, sb);
            WebPageCompilerUtility.CreateElementPosition(this, sb, positiontype);
            WebPageCompilerUtility.CreateWebElementCursor(cursor, sb, false);
            //
            if (_dataNode != null)
            {
                XmlNode pNode = _dataNode.SelectSingleNode(string.Format(CultureInfo.InvariantCulture,
                                                                         "{0}[@name='Visible']", XmlTags.XML_PROPERTY));
                if (pNode != null)
                {
                    string s = pNode.InnerText;
                    if (!string.IsNullOrEmpty(s))
                    {
                        try
                        {
                            b = Convert.ToBoolean(s, CultureInfo.InvariantCulture);
                            if (!b)
                            {
                                sb.Append("display:none; ");
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                //
                pNode = _dataNode.SelectSingleNode(string.Format(CultureInfo.InvariantCulture,
                                                                 "{0}[@name='disabled']", XmlTags.XML_PROPERTY));
                if (pNode != null)
                {
                    string s = pNode.InnerText;
                    if (!string.IsNullOrEmpty(s))
                    {
                        try
                        {
                            b = Convert.ToBoolean(s, CultureInfo.InvariantCulture);
                            if (b)
                            {
                                XmlUtil.SetAttribute(node, "disabled", "disabled");
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            //
            XmlUtil.SetAttribute(node, "style", sb.ToString());
            //
            string   fnt = ObjectCreationCodeGen.GetFontStyleString(this.Font);
            Graphics g   = this.CreateGraphics();

            g.PageUnit = GraphicsUnit.Pixel;
            float tabloc = (float)10;

            //
            for (int i = 0; i < TabPages.Count; i++)
            {
                TabPage p        = this.TabPages[i];
                XmlNode pageNode = node.OwnerDocument.CreateElement("section");
                node.AppendChild(pageNode);
                XmlUtil.SetAttribute(pageNode, "id", p.Name);
                XmlNode h2 = node.OwnerDocument.CreateElement("h2");
                pageNode.AppendChild(h2);
                XmlNode a = node.OwnerDocument.CreateElement("a");
                h2.AppendChild(a);
                a.InnerText = p.Text;
                XmlUtil.SetAttribute(a, "href", string.Format(CultureInfo.InvariantCulture, "#{0}", p.Name));
                SizeF         txtSize  = g.MeasureString(p.Text, this.Font);
                float         txtwidth = txtSize.Width + (float)6.0;
                StringBuilder h2style  = new StringBuilder(fnt);
                h2style.Append(string.Format(CultureInfo.InvariantCulture, "width:{0}px;", Math.Round(txtwidth, 2)));
                if (i > 0)
                {
                    h2style.Append(string.Format(CultureInfo.InvariantCulture, "left:{0}px;", Math.Round(tabloc, 2)));
                }
                tabloc = tabloc + txtwidth + (float)3;
                XmlUtil.SetAttribute(h2, "style", h2style.ToString());
                foreach (Control ct in p.Controls)
                {
                    createControlWebContents(ct, pageNode);
                }
                StringBuilder sbPageStyle = new StringBuilder();
                if (p.BackColor != Color.Empty && p.BackColor != Color.Transparent)
                {
                    sbPageStyle.Append("background-color:");
                    sbPageStyle.Append(ObjectCreationCodeGen.GetColorString(p.BackColor));
                    sbPageStyle.Append(";");
                }
                if (!string.IsNullOrEmpty(_widthStyle))
                {
                    sbPageStyle.Append("width:");
                    sbPageStyle.Append(_widthStyle);
                }
                if (!string.IsNullOrEmpty(_heighStyle))
                {
                    sbPageStyle.Append("height:");
                    sbPageStyle.Append(_heighStyle);
                }
                if (sbPageStyle.Length > 0)
                {
                    XmlUtil.SetAttribute(pageNode, "style", sbPageStyle.ToString());
                }
            }
        }