private void LoadBtn_Click(object sender, RoutedEventArgs e) { try { Serializator.Deserialize(nameBox.Text + ".xml"); } catch { MessageBox.Show("Данный файл не существует"); } }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { try { Serializator.Serialize(nameBox.Text + ".xml"); } catch { MessageBox.Show("Некорректный файл"); } }
private void Form_Closing(object sender, System.ComponentModel.CancelEventArgs e) { Serializator.Serialize("last_session.xml"); }
public MainWindow() { InitializeComponent(); appWindow = this; planeHost = new PlaneHost { VerticalAlignment = VerticalAlignment.Stretch, HorizontalAlignment = HorizontalAlignment.Stretch }; selectedColor = Color1; var baseUri = new Uri("C:/Users/АДМИН/source/repos/GrafRedactorMakovei/NewPaint/Resourses/"); Resources = new ResourceDictionary() { Source = new Uri(baseUri, "ResourceDictionary.xaml") }; Dictionary <string, string> btns = new Dictionary <string, string> { { "Undo_Button", "icons/Undo.bmp" }, { "Redo_Button", "icons/Redo.bmp" }, { "ClearAll_Button", "icons/ClearAllTool.bmp" }, { "Pencil_Button", "icons/PencilTool.bmp" }, { "Line_Button", "icons/LineTool.bmp" }, { "Rectangle_Button", "icons/RectangleTool.bmp" }, { "RoundRectangle_Button", "icons/RoundRectangleTool.bmp" }, { "Ellipse_Button", "icons/EllipseTool.bmp" }, { "Hand_Button", "icons/HandTool.bmp" }, { "Zoom_Button", "icons/ZoomTool.bmp" }, { "Emphasize_Button", "icons/EmphasizeTool.bmp" } }; Color[] colors = new Color[] { Colors.Black, Colors.White, Colors.Brown, Colors.Yellow, Colors.Blue, Colors.DarkSlateBlue, Colors.LightBlue, Colors.SlateBlue, Colors.Pink, Colors.Purple, Colors.MediumPurple, Colors.Red, Colors.Green, Colors.Goldenrod, Colors.LightYellow, Colors.LightGreen }; int j = 0; foreach (string key in btns.Keys) { Create_Button(MainGrid, key, j, new Uri(baseUri, btns[key])); j++; } int i = 0; j = 0; foreach (Color color in colors) { Create_Button(Palette, new SolidColorBrush(color), i, j); j++; if (j > 7) { j = 0; i++; } } canvas.Children.Add(planeHost); Loaded += delegate { GlobalVars.sizeCanvas = new Size(canvas.ActualWidth, canvas.ActualHeight); ScrollBarX.Maximum = canvas.ActualWidth / 100; ScrollBarY.Maximum = canvas.ActualHeight / 100; propPanels = new List <Grid> { standartProps, fillProp, roundsProp }; }; Serializator.Deserialize("last_session.xml"); planeHost.Redraw(); }