private void LoadToolStripMenuItem_Click(object sender, EventArgs e) { var deserializer = new Serializer(); FigureList.Figures = deserializer.Deserialize(); Graphics g = pictureBox1.CreateGraphics(); ConfigKeeper.LoadXml(); RepaintFigureList(g); }
public Paint() { AddPlugins(); InitializeComponent(); AddUserFigures(); ConfigKeeper.LoadXml(); UserFigure.FieldHeight = pictureBox1.Size.Width; UserFigure.FieldWidth = pictureBox1.Size.Height; List <StripMenuItemInfo> itemsList = new List <StripMenuItemInfo>(); string[][] FigureNames = new string[][] { new string[] { "Line", "Rectangle", "Square", "Rhombus", "Circle", "Ellipse" }, new string[] { "Линия", "Прямоугольник", "Квадрат", "Ромб", "Круг", "Эллипс" } }; MenuItem[] menuItems = new MenuItem[] { new MenuItem("Delete", new EventHandler(ContextMenuDeleteClickHandler)), new MenuItem("Copy", new EventHandler(ContextMenuCopyClickHandler)), new MenuItem("Paste", new EventHandler(ContextMenuPasteClickHandler)), new MenuItem("Background Color", new EventHandler(ContextMenuBGColorClickHandler)) }; ContextMenu = new ContextMenu(menuItems); foreach (var creator in FigureCreatorList.Creators) { foreach (var figurename in FigureNames[0]) { if ((creator).ToString().Contains(figurename)) { itemsList.Add(new StripMenuItemInfo { figureName = figurename, FigureCreator = creator }); break; } } } ToolStripMenuItem menuItem; foreach (StripMenuItemInfo items in itemsList) { menuItem = new ToolStripMenuItem(items.figureName) { Tag = items.FigureCreator }; menuItem.Click += new EventHandler(MenuItemFigureClickHandler); figuresToolStripMenuItem.DropDownItems.Add(menuItem); } Pen = new Pen(PenColor, PenWidth); trackBar1.Value = PenWidth; pictureBox1.BackColor = BackgroundColor; }