Exemplo n.º 1
0
        public string SaveToXML()
        {
            //
            var sb = new StringBuilderForXML();

            sb.Append("<xml>");
            //
            sb.Append("width", pnl.Width.ToString());
            sb.Append("height", pnl.Height.ToString());
            //
            sb.Append("<block1>");
            sb.Append("width", panel1.Width.ToString());
            sb.Append("height", panel1.Height.ToString());
            AppendItem(panel1, sb);
            sb.Append("</block1>");
            //
            sb.Append("<block2>");
            sb.Append("width", panel2.Width.ToString());
            sb.Append("height", panel2.Height.ToString());
            AppendItem(panel2, sb);
            sb.Append("</block2>");
            //
            sb.Append("<block3>");
            sb.Append("width", panel3.Width.ToString());
            sb.Append("height", panel3.Height.ToString());
            AppendItem(panel3, sb);
            sb.Append("</block3>");
            //
            sb.Append("</xml>");
            //
            return(sb.ToString());
        }
Exemplo n.º 2
0
 private void AppendItem(System.Windows.Forms.Control par, StringBuilderForXML sb)
 {
     foreach (System.Windows.Forms.Control con in par.Controls)
     {
         if (con.Visible == false)
         {
             continue;
         }
         if (con.GetType() == typeof(FieldLabel))
         {
             FieldLabel c = (FieldLabel)con;
             sb.Append("<field>");
             sb.Append("field", c.Field);
             sb.Append("left", c.Left.ToString());
             sb.Append("top", c.Top.ToString());
             sb.Append("width", c.Width.ToString());
             sb.Append("height", c.Height.ToString());
             sb.Append("font_name", c.Font.FontFamily.Name);
             sb.Append("font_size", c.Font.Size.ToString());
             sb.Append("font_style", FontHelper.GetFontStyle(c.Font).ToString());
             sb.Append("format", c.Format);
             sb.Append("</field>");
         }
         if (con.GetType() == typeof(TextLabel))
         {
             TextLabel c = (TextLabel)con;
             sb.Append("<text>");
             sb.Append("text", c.Text);
             sb.Append("left", c.Left.ToString());
             sb.Append("top", c.Top.ToString());
             sb.Append("width", c.Width.ToString());
             sb.Append("height", c.Height.ToString());
             sb.Append("font_name", c.Font.FontFamily.Name);
             sb.Append("font_size", c.Font.Size.ToString());
             sb.Append("font_style", FontHelper.GetFontStyle(c.Font).ToString());
             sb.Append("</text>");
         }
         if (con.GetType() == typeof(Line))
         {
             Line c = (Line)con;
             sb.Append("<line>");
             sb.Append("left", c.Left.ToString());
             sb.Append("top", c.Top.ToString());
             sb.Append("width", c.Width.ToString());
             sb.Append("height", c.Height.ToString());
             sb.Append("</line>");
         }
         if (con.GetType() == typeof(LineII))
         {
             LineII c = (LineII)con;
             sb.Append("<lineII>");
             sb.Append("left", c.Left.ToString());
             sb.Append("top", c.Top.ToString());
             sb.Append("width", c.Width.ToString());
             sb.Append("height", c.Height.ToString());
             sb.Append("</lineII>");
         }
         if (con.GetType() == typeof(Picture))
         {
             Picture c = (Picture)con;
             sb.Append("<picture>");
             sb.Append("left", c.Left.ToString());
             sb.Append("top", c.Top.ToString());
             sb.Append("width", c.Width.ToString());
             sb.Append("height", c.Height.ToString());
             sb.Append("data", Picture.ImageToString(c.Image));
             sb.Append("</picture>");
         }
     }
 }