Beispiel #1
0
        private void LoadToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var deserializer = new Serializer();

            FigureList.Figures = deserializer.Deserialize();
            Graphics g = pictureBox1.CreateGraphics();

            ConfigKeeper.LoadXml();
            RepaintFigureList(g);
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var serializer = new Serializer();

            if (FigureList.Figures.Count != 0)
            {
                serializer.Serialize(FigureList.Figures);
                ConfigKeeper.SaveXml();
            }
            else
            {
                string            message = "Нарисуйте что-нибудь, тогда сохраним))";
                string            caption = "Save";
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                MessageBox.Show(message, caption, buttons);
            }
        }
Beispiel #4
0
 private void Paint_FormClosing(object sender, FormClosingEventArgs e)
 {
     ConfigKeeper.SaveXml();
 }