public void AddToPicList(SerPic picture) { pic.Add(picture); }
private void button1_Click(object sender, RoutedEventArgs e) { selCanv.InvalidateVisual(); Microsoft.Win32.SaveFileDialog savedialog = new Microsoft.Win32.SaveFileDialog(); savedialog.Title = "Сохранить картинку как ..."; savedialog.OverwritePrompt = true; savedialog.CheckPathExists = true; savedialog.Filter = "AC File(*.ac)|*.ac|" + "Bitmap File(*.bmp)|*.bmp|" + "GIF File(*.gif)|*.gif|" + "JPEG File(*.jpg)|*.jpg|" + "TIF File(*.tif)|*.tif|" + "PNG File(*.png)|*.png"; if (savedialog.ShowDialog() == true) { string fileName = savedialog.FileName; string strFilExtn = fileName.Remove(0, fileName.Length - 3); // Save file switch (strFilExtn) { case "bmp": CreateSaveBitmap(selCanv, fileName); break; case "jpg": CreateSaveBitmap(selCanv, fileName); break; case "gif": CreateSaveBitmap(selCanv, fileName); break; case "tif": CreateSaveBitmap(selCanv, fileName); break; case "png": CreateSaveBitmap(selCanv, fileName); break; case ".ac": ObjSer os = new ObjSer(); foreach (Image pic in pictureBox1) { Point relativePoint = pic.TransformToAncestor(this).Transform(new Point(0, 0)); SerPic sp = new SerPic(relativePoint.X, relativePoint.Y, pic.Width, pic.Height, ImageToString(pic.Source)); os.AddToPicList(sp); } foreach (TextBox text in textList) { Point relativePoint = text.TransformToAncestor(this).Transform(new Point(0, 0)); SerText st = new SerText(relativePoint.X, relativePoint.Y, text.FontFamily.Source, text.FontSize, text.Foreground.ToString(), text.Text); os.AddToTextList(st); } foreach (Grid table in gridList) { List<string> text = new List<string>(); foreach (TextBox t in table.Children) { text.Add(t.Text); } Point relativePoint = table.TransformToAncestor(this).Transform(new Point(0, 0)); SerGrid sg = new SerGrid(relativePoint.X, relativePoint.Y, table.RowDefinitions.Count, table.ColumnDefinitions.Count / table.RowDefinitions.Count, text); os.AddToGridList(sg); } Stream TestFileStream = File.Create(fileName); BinaryFormatter serializer = new BinaryFormatter(); serializer.Serialize(TestFileStream, os); TestFileStream.Close(); break; } } }
private void button1_Click(object sender, RoutedEventArgs e) { selCanv.InvalidateVisual(); Microsoft.Win32.SaveFileDialog savedialog = new Microsoft.Win32.SaveFileDialog(); savedialog.Title = "Сохранить картинку как ..."; savedialog.OverwritePrompt = true; savedialog.CheckPathExists = true; savedialog.Filter = "AC File(*.ac)|*.ac|" + "Bitmap File(*.bmp)|*.bmp|" + "GIF File(*.gif)|*.gif|" + "JPEG File(*.jpg)|*.jpg|" + "TIF File(*.tif)|*.tif|" + "PNG File(*.png)|*.png"; if (savedialog.ShowDialog() == true) { string fileName = savedialog.FileName; string strFilExtn = fileName.Remove(0, fileName.Length - 3); // Save file switch (strFilExtn) { case "bmp": CreateSaveBitmap(selCanv, fileName); break; case "jpg": CreateSaveBitmap(selCanv, fileName); break; case "gif": CreateSaveBitmap(selCanv, fileName); break; case "tif": CreateSaveBitmap(selCanv, fileName); break; case "png": CreateSaveBitmap(selCanv, fileName); break; case ".ac": ObjSer os = new ObjSer(); foreach (Image pic in pictureBox1) { Point relativePoint = pic.TransformToAncestor(this).Transform(new Point(0, 0)); SerPic sp = new SerPic(relativePoint.X, relativePoint.Y, pic.Width, pic.Height, ImageToString(pic.Source)); os.AddToPicList(sp); } foreach (TextBox text in textList) { Point relativePoint = text.TransformToAncestor(this).Transform(new Point(0, 0)); SerText st = new SerText(relativePoint.X, relativePoint.Y, text.FontFamily.Source, text.FontSize, text.Foreground.ToString(), text.Text); os.AddToTextList(st); } foreach (Grid table in gridList) { List <string> text = new List <string>(); foreach (TextBox t in table.Children) { text.Add(t.Text); } Point relativePoint = table.TransformToAncestor(this).Transform(new Point(0, 0)); SerGrid sg = new SerGrid(relativePoint.X, relativePoint.Y, table.RowDefinitions.Count, table.ColumnDefinitions.Count / table.RowDefinitions.Count, text); os.AddToGridList(sg); } Stream TestFileStream = File.Create(fileName); BinaryFormatter serializer = new BinaryFormatter(); serializer.Serialize(TestFileStream, os); TestFileStream.Close(); break; } } }