public static void Save_File() { SerializerObject.Clear(); int _num = 0; for (int i = 0; i < DraggableObjects.Count; i++) { if (DraggableObjects[i].isContent) { OperationObject object_item = new OperationObject(); object_item.Num = control_Num; object_item.Id = DraggableObjects[i].Id; object_item.Belong_Band = DraggableObjects[i].Belong_Band; object_item.Region = DraggableObjects[i].Region; object_item.ControlType = DraggableObjects[i].ControlType; object_item.isContent = DraggableObjects[i].isContent; if (DraggableObjects[i].ControlType == 2) { Bitmap _bmp = new Bitmap(DraggableObjects[i].Field_Img.Width, DraggableObjects[i].Field_Img.Height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); Graphics draw = Graphics.FromImage(_bmp); draw.DrawImage(DraggableObjects[i].Field_Img, 0, 0); object_item.Field_ImgBase64 = ImgToBase64String(_bmp); draw.Dispose(); _bmp.Dispose(); } object_item.Field_Text = DraggableObjects[i].Field_Text; object_item.Field_Calculate = DraggableObjects[i].Field_Calculate; object_item.Field_TextFont = DraggableObjects[i].Field_TextFont; object_item.Field_TextFontSize = DraggableObjects[i].Field_TextFontSize; object_item.Field_TextFontStyleString = DraggableObjects[i].Field_TextFontStyle.ToString(); object_item.Field_Align = DraggableObjects[i].Field_Align; object_item.Field_ImgZoom = DraggableObjects[i].Field_ImgZoom; for (int t = 0; t < 8; t++) { object_item.Field_BoxLine[t] = DraggableObjects[i].Field_BoxLine[t]; } object_item.Field_LineColorString = ColorTranslator.ToHtml(DraggableObjects[i].Field_LineColor); object_item.Field_LineThickness = DraggableObjects[i].Field_LineThickness; object_item.Field_LineType = DraggableObjects[i].Field_LineType; object_item.Field_Shape = DraggableObjects[i].Field_Shape; object_item.Field_ControlColorString = ColorTranslator.ToHtml(DraggableObjects[i].Field_ControlColor); object_item.Field_BackColorString = ColorTranslator.ToHtml(DraggableObjects[i].Field_BackColor); object_item.page_Type = page_TypeFace; for (int t = 0; t < 3; t++) { object_item.Band_Region[t] = DraggableBandObjects[t].Region; } SerializerObject.Add(object_item); _num += 1; } } if (_num > 0) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "报表文件(*.rpt)|*.rpt"; sfd.FilterIndex = 1; sfd.RestoreDirectory = true; sfd.FileName = ReportFile_Name.Text; if (sfd.ShowDialog() == DialogResult.OK) { string localFilePath = sfd.FileName.ToString(); //获得文件路径 Serializer.ObjectToFile(SerializerObject, sfd.FileName); ReportChange_Flag = false; } } else { MessageBox.Show("报表组件内不包含内容,报表将不被保存。"); } }