Example #1
0
 public ClickDrawForm()
 {
     InitializeComponent();
     ClickGraphic = ClickDrawPanel.CreateGraphics();
     ClickPen     = new Pen(Color.Black, 3);
     ClickPen.SetLineCap(System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.LineCap.Round, System.Drawing.Drawing2D.DashCap.Round);
 }
Example #2
0
        private void ClearButtonClickDrawing_Click(object sender, EventArgs e)
        {
            ClickDrawPanel.Invalidate();

            checkedListBox1.Items.Clear();
            //ClickDrawPanel.BackColor = Color.White;
            //ClickDrawPanel.Invalidate();
            //ClickDrawPanel.Controls.Clear();
            //ClickDrawPanel.Controls.Add();
            //ClickGraphic.Clear(Color.White);
            //ClickGraphic.Clear(Color.Red);
        }
Example #3
0
        private void ComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.Text == "Open")
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Filter = "JPG(*.JPG)|*.jpg";
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    File = Image.FromFile(openFileDialog.FileName);
                    //ClickDrawPanel.Image = File;
                    ClickDrawPanel.BackgroundImage = File;
                }
            }
            else if (comboBox1.Text == "Save")
            {
                SaveFileDialog dialog = new SaveFileDialog();
                dialog.Filter = "JPG(*.JPG)|*.jpg|Bitmap|*.bmp|Gif|*.gif|JPEG(*.JPEG)|*.jpeg";



                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    if (checkBox1.Checked)
                    {
                        dialog.Filter = "JPG(*.JPG)|*.jpg|Bitmap|*.bmp|Gif|*.gif|JPEG(*.JPEG)|*.jpeg";
                        int    width  = Convert.ToInt32(CutShapes[0].Width);
                        int    height = Convert.ToInt32(CutShapes[0].Height);
                        Bitmap bmp    = new Bitmap(width, height);
                        ClickDrawPanel.DrawToBitmap(bmp, new Rectangle(0, 0, width, height));
                        bmp.Save(dialog.FileName, ImageFormat.Jpeg);
                    }
                    else
                    {
                        dialog.Filter = "JPG(*.JPG)|*.jpg|Bitmap|*.bmp|Gif|*.gif|JPEG(*.JPEG)|*.jpeg";
                        int    width  = Convert.ToInt32(ClickDrawPanel.Width);
                        int    height = Convert.ToInt32(ClickDrawPanel.Height);
                        Bitmap bmp    = new Bitmap(width, height);
                        ClickDrawPanel.DrawToBitmap(bmp, new Rectangle(0, 0, width, height));
                        bmp.Save(dialog.FileName, ImageFormat.Jpeg);
                    }
                }
                //}
            }
        }
Example #4
0
        private void ClickDrawPanel_MouseMove_1(object sender, MouseEventArgs e)
        {
            //ClickDrawPanel.Size = this.ClickDrawPanel.Size;
            //ClickDrawPanel.Width = this.ClickDrawPanel.Width;

            if (checkBox1.Checked)
            {
                if (IsMouseDown != true)
                {
                    old = e.Location;
                    Refresh();
                }
            }
            else
            {
                cursor         = ClickDrawPanel.PointToClient(Cursor.Position);
                Xposition.Text = Convert.ToString(cursor.X);
                Yposition.Text = Convert.ToString(cursor.Y);
                if (FreeDrawingCheck.Checked)
                {
                    //Drawcheck.Enabled = false;
                    //LoopCheck.Enabled = false;
                    if (e.Button == MouseButtons.Left)
                    {
                        ClickGraphic = ClickDrawPanel.CreateGraphics();
                        current      = e.Location;
                        ClickGraphic.DrawLine(ClickPen, old, current);
                        old = current;

                        comboBox1.Visible = true;
                        if (comboBox1.Text == "1")
                        {
                            ClickGraphic = ClickDrawPanel.CreateGraphics();
                            current      = e.Location;
                            ClickGraphic.DrawLine(ClickPen, old, current);
                            old = current;
                        }
                    }
                }
            }
        }