Abstract class use as base class of all draw tool class
예제 #1
0
        /// <summary>
        /// mouse event handle
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openingPictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (MouseButtons.Left == e.Button || MouseButtons.Right == e.Button)
            {
                Graphics g = openingPictureBox.CreateGraphics();

                m_tool.OnMouseDown(g, e);
                m_tool.OnRightMouseClick(g, e);
            }
            else if (MouseButtons.Middle == e.Button)
            {
                m_tool.OnMidMouseDown(null, null);
                m_tool = m_tools.Peek();
                m_tools.Enqueue(m_tool);
                m_tools.Dequeue();
                Graphics graphic = openingPictureBox.CreateGraphics();
                graphic.DrawString(m_tool.ToolType.ToString(),
                    SystemFonts.DefaultFont, SystemBrushes.Highlight, 2, 5);
                this.Refresh();
            }
        }
예제 #2
0
 /// <summary>
 /// add tools, then use can draw by these tools in picture box
 /// </summary>
 private void InitTools()
 {
     //wall
     if(m_profile is ProfileWall)
     {
         m_tool = new RectTool();
         m_tools.Enqueue(m_tool);
         m_tools.Enqueue(new EmptyTool());
     }
     //floor
     else
     {
         m_tool = new LineTool();
         m_tools.Enqueue(m_tool);
         m_tools.Enqueue(new RectTool());
         m_tools.Enqueue(new CircleTool());
         m_tools.Enqueue(new ArcTool());
         m_tools.Enqueue(new EmptyTool());
     }
 }