private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            m_action = Action.Move;


            if (m_paint)
            {
                switch (m_currItem)
                {
                case Item.Brush:
                {
                    actions.Add(new DrawAction(m_action, e.X, e.Y, m_currItem, m_paintcolor));
                    m_color = new SolidBrush(m_paintcolor);
                    using (Graphics g = panel1.CreateGraphics())
                    {
                        g.FillEllipse(m_color, e.X, e.Y, 20, 20);
                    }
                    break;
                }

                case Item.Pencil:
                {
                    actions.Add(new DrawAction(m_action, e.X, e.Y, m_currItem, m_paintcolor));
                    m_color = new SolidBrush(m_paintcolor);
                    using (Graphics g = panel1.CreateGraphics())
                    {
                        g.FillEllipse(m_color, e.X, e.Y, 5, 5);
                    }
                    break;
                }
                }
            }
        }
 private void panel1_MouseDown(object sender, MouseEventArgs e)
 {
     m_action = Action.Down;
     actions.Add(new DrawAction(m_action, e.X, e.Y, m_currItem, m_paintcolor));
     m_paint = true;
     m_x     = e.X;
     m_y     = e.Y;
 }
        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            m_action = Action.Up;

            actions.Add(new DrawAction(m_action, e.X, e.Y, m_currItem, m_paintcolor));


            m_paint = false;
            m_x1    = e.X;
            m_y1    = e.Y;
            switch (m_currItem)
            {
            case Item.Ellipse:
            {
                Pen myPen = new Pen(m_paintcolor);
                using (Graphics g = panel1.CreateGraphics())
                {
                    g.DrawEllipse(myPen, m_x, m_y, m_x1 - m_x, m_y1 - m_y);
                }
                break;
            }

            case Item.Rectangle:
            {
                var myPen = new Pen(m_paintcolor);
                using (Graphics g = panel1.CreateGraphics())
                {
                    g.DrawRectangle(myPen, Math.Min(m_x, m_x1), Math.Min(m_y, m_y1), Math.Abs(m_x1 - m_x), Math.Abs(m_y1 - m_y));
                }
                break;
            }

            case Item.Line:
            {
                Pen myPen = new Pen(m_paintcolor);
                using (Graphics g = panel1.CreateGraphics())
                {
                    g.DrawLine(myPen, m_x, m_y, m_x1, m_y1);
                }
                break;
            }
            }
        }