}   //End the OnCreateControl() method

        /// <summary>
        /// Item click event handler for the Drawing Tools DXMenuItem
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnDrawingToolsClick(object sender, EventArgs e)
        {
            using (frmDrawingTool showDrawingTools = new frmDrawingTool(Image))
            {
                if (showDrawingTools.ShowDialog(Parent) == DialogResult.OK)
                {
                    //Change us into Drawing Mode
                    _IsDrawingMode = true;
                    Cursor         = Cursors.Cross;
                    CurrentShape   = showDrawingTools.SelectedShape;
                }
            } //End the using() statement
        }     //End the OnDrawingToolsClick() method
        }     //End the SaveModifiedImage() method

        /// <summary>
        /// On key down event handler
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);

            //See if we should cancel out of Drawing mode
            if (e.KeyCode == Keys.Escape && _IsDrawingMode == true)
            {
                _IsDrawingMode = false;
                CurrentShape   = null;
                Cursor         = Cursors.Default;
                Invalidate();
            }
        }   //End the OnKeyDown() method
예제 #3
0
        }   //End the btnCheckTextSize_Click() method



        /// <summary>
        /// Button click event handler for the Ok button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (pnlTools.Buttons["Line"].IsChecked.Value == true)
            {
                _SelectedShape = new Line();
                (_SelectedShape as Line).EndCap = (LineCap)cboEndCap.EditValue;
                (_SelectedShape as Line).StartCap = (LineCap)cboStartCap.EditValue;
                
            }
            else if (pnlTools.Buttons["Rectangle"].IsChecked.Value == true)
            {
                _SelectedShape = new Rectangle();
                (_SelectedShape as FillableShape).FillColor = cboFillColor.Color;
            }
            else if (pnlTools.Buttons["Ellipse"].IsChecked.Value == true)
            {
                _SelectedShape = new Ellipse();
                (_SelectedShape as FillableShape).FillColor = cboFillColor.Color;
            }
            else if (pnlTools.Buttons["Freehand"].IsChecked.Value == true)
            {
                _SelectedShape = new Freehand();
                (_SelectedShape as Freehand).Points = new List<Point>(50);
            }
            else if (pnlTools.Buttons["Text"].IsChecked.Value == true)
            {
                FontStyle style = FontStyle.Regular;

                if (btnBold.Checked)
                    style = FontStyle.Bold;
                if (btnItalic.Checked)
                    style = style | FontStyle.Italic;
                if (btnUnderline.Checked)
                    style = style | FontStyle.Underline;

                _SelectedShape = new TextStamp();
                (_SelectedShape as TextStamp).FillColor = cboFillColor.Color;
                (_SelectedShape as TextStamp).Text = txtText.Text;
                (_SelectedShape as TextStamp).TextFont = new Font(txtFont.Text, Convert.ToSingle(txtFontSize.Value), style);
            }

            _SelectedShape.BorderWidth = Convert.ToSingle(txtBorderWidth.Value);
            _SelectedShape.ForeColor = cboForeColor.Color;

            DialogResult = DialogResult.OK;
            Close();

        }   //End the btnOk_Click() method
        }   //End the OnMouseMove() method

        /// <summary>
        /// On mouse up event handler
        /// </summary>
        /// <param name="e"></param>
        protected override void OnMouseUp(MouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (_IsDrawingMode == false)
            {
                return;
            }

            if (IsDesignMode == false && CurrentShape != null)
            {
                //Add this Shape to our collection
                Shapes.Add(CurrentShape);
                CurrentShape = null;

                //Turn off Drawing Mode
                _IsDrawingMode = false;
                Cursor         = Cursors.Default;
            }
        }   //End the OnMouseUp() method