Beispiel #1
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn public static ToolKit GetInstance(PictureBox mainView)
        ///
        /// \brief Gets an instance
        ///
        /// \param mainView The main view control.
        ///
        /// \return The instance.
        ///-------------------------------------------------------------------------------------------------

        public static ToolKit GetInstance(PictureBox mainView)
        {
            if (mInstance == null)
            {
                mInstance = new ToolKit(mainView);
            }
            return(mInstance);
        }
Beispiel #2
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn private void MainView_MouseMove(object sender, MouseEventArgs e)
        ///
        /// \brief Event handler. Called by MainView for mouse move events
        ///
        /// \param sender Source of the event.
        /// \param e      Mouse event information.
        ///-------------------------------------------------------------------------------------------------

        private void MainView_MouseMove(object sender, MouseEventArgs e)
        {
            if (isEnabled)
            {
                using (Graphics g = Graphics.FromImage(mainView.Image))
                {
                    LineTool lt = (LineTool)(ToolKit.GetInstance().LineTool);
                    lt.lineAgent.DrawLine(g, Setting.GetInstance().Pen, oldLocation, e.Location);
                    oldLocation = e.Location;
                    mainView.Invalidate();
                }
            }
        }
Beispiel #3
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn public MainWin()
        ///
        /// \brief Default constructor
        ///-------------------------------------------------------------------------------------------------

        public MainWin()
        {
            InitializeComponent();
            // some initialize progress.
            // initialize the toolKit
            toolKit = ToolKit.GetInstance(mainView);
            // set default tool.
            toolKit.currentTool = toolKit.pointerTool;
            toolKit.currentTool.RegisterTool();
            ToolButton.currentButton = pointerButton;

            // init buttons
            pointerButton.BindingTool  = toolKit.pointerTool;
            pencilButton.BindingTool   = toolKit.pencilTool;
            lineButton.BindingTool     = toolKit.lineTool;
            circleButton.BindingTool   = toolKit.circleTool;
            clipButton.BindingTool     = toolKit.clipTool;
            ellipseButton.BindingTool  = toolKit.ellipseTool;
            polygonButton.BindingTool  = toolKit.polygonTool;
            resizeButton.BindingTool   = toolKit.resizeTool;
            rotatingButton.BindingTool = toolKit.rotatingTool;



            // set default color box button, to emphasize the colorBox which is currently being used.
            currentSettingColorButton = colorBoxButton1;
            // undo and redo button set unenabled
            redoButton.Enabled = undoButton.Enabled = false;
            redoButton.Cursor  = undoButton.Cursor = Cursors.No;
            //image related
            mainView.Image = new Bitmap(mainView.Width, mainView.Height);
            //fill the image with white
            using (Graphics g = Graphics.FromImage(mainView.Image))
            {
                g.FillRectangle(Brushes.White, 0, 0, mainView.Image.Width, mainView.Image.Height);
            }


            //set the resize button to the lower right corner.
            resizePictureBoxButton      = new ResizeCanvasButton(mainView);
            resizePictureBoxButton.Size = new Size(7, 7);

            threeDButton.BackgroundImage = Resource1.cube;
        }
Beispiel #4
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn private void bSplineToolStripMenuItem_Click(object sender, EventArgs e)
        ///
        /// \brief Event handler. Called by bSplineToolStripMenuItem for click events
        ///
        /// \param sender Source of the event.
        /// \param e      Event information.
        ///-------------------------------------------------------------------------------------------------

        private void bSplineToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ToolKit.GetInstance().currentTool.UnRegisterTool();
            ToolKit.GetInstance().currentTool = ToolKit.GetInstance().bSplineTool;
            ToolKit.GetInstance().currentTool.RegisterTool();
        }
Beispiel #5
0
        ///-------------------------------------------------------------------------------------------------
        /// \fn private void toolStripMenuItem3_Click(object sender, EventArgs e)
        ///
        /// \brief Event handler. Called by toolStripMenuItem3 for click events
        ///
        /// \param sender Source of the event.
        /// \param e      Event information.
        ///-------------------------------------------------------------------------------------------------

        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            ToolKit.GetInstance().currentTool.UnRegisterTool();
            ToolKit.GetInstance().currentTool = ToolKit.GetInstance().scanFillTool;
            ToolKit.GetInstance().currentTool.RegisterTool();
        }