예제 #1
0
 private void ReadLineII(System.Windows.Forms.Control par, ReadXml read, string path)
 {
     foreach (ReadXml r in read.ReadList(path))
     {
         var con = new LineII();
         con.Left   = Convert.ToInt32(r.Read("left"));
         con.Top    = Convert.ToInt32(r.Read("top"));
         con.Width  = Convert.ToInt32(r.Read("width"));
         con.Height = Convert.ToInt32(r.Read("height"));
         par.Controls.Add(con);
     }
 }
예제 #2
0
 private void cms_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
 {
     cms.Visible = false;
     System.Windows.Forms.Control par = (System.Windows.Forms.Control)cms.Tag;
     if (e.ClickedItem.Text.StartsWith("#") == true)//字段
     {
         var lbl = new FieldLabel(e.ClickedItem.Text.Substring(1));
         lbl.AutoSize = false;
         lbl.Location = p;
         par.Controls.Add(lbl);
     }
     else if (e.ClickedItem.Text == "文本")
     {
         var frm = new frmInputbox("文本");
         if (frm.ShowDialog() == DialogResult.OK)
         {
             var lbl = new TextLabel();
             lbl.AutoSize = false;
             lbl.Text     = frm.Context();
             lbl.Location = p;
             par.Controls.Add(lbl);
         }
     }
     else if (e.ClickedItem.Text == "横线")
     {
         var line = new Line();
         line.Location = p;
         par.Controls.Add(line);
     }
     else if (e.ClickedItem.Text == "竖线")
     {
         var line = new LineII();
         line.Location = p;
         par.Controls.Add(line);
     }
     else if (e.ClickedItem.Text == "图片")
     {
         var f = new System.Windows.Forms.OpenFileDialog();
         f.Filter = "*.jpg|*.jpg";
         if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             var pic = new Picture();
             pic.Image    = Image.FromFile(f.FileName);
             pic.Location = p;
             par.Controls.Add(pic);
         }
     }
 }
예제 #3
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>");
         }
     }
 }