Esempio n. 1
0
 private void PatternPB_MouseMove(object sender, MouseEventArgs e)
 {
     LocationMouseTSSL.Text = $"{e.X}, {e.Y}px";
     if (Painting && (e.Button == MouseButtons.Left || e.Button == MouseButtons.Right))
     {
         MyPen          = new Pen(e.Button == MouseButtons.Left ? Color1Btn.BackColor : Color2Btn.BackColor, MyPen.Width);
         MyPen.StartCap = MyPen.EndCap = LineCap.Round;
         MyPen.LineJoin = LineJoin.Round;
         if (Painter == Painters.Pencil)
         {
             Array.Resize(ref PencilPoints, PencilPoints.Length + 1);
             PencilPoints[PencilPoints.Length - 1] = new Point(e.X, e.Y);
             Array.Resize(ref PenTypes, PenTypes.Length + 1);
             PenTypes[PenTypes.Length - 1] = 1;
             g.DrawPath(MyPen, new GraphicsPath(PencilPoints, PenTypes));
         }
         else if (Painter == Painters.Rectangle)
         {
             PatternPB.Refresh();
             g.DrawPolygon(MyPen, new[] { new Point(movestart.X, movestart.Y), new Point(movestart.X, e.Y), new Point(e.X, e.Y), new Point(e.X, movestart.Y) });
         }
         else if (Painter == Painters.Ellipse)
         {
             PatternPB.Refresh();
             g.DrawEllipse(MyPen, movestart.X, movestart.Y, e.X - movestart.X, e.Y - movestart.Y);
         }
         else if (Painter == Painters.Line)
         {
             PatternPB.Refresh();
             g.DrawLine(MyPen, movestart.X, movestart.Y, e.X, e.Y);
         }
     }
 }
Esempio n. 2
0
        private void ShadowPic_MouseUp(object sender, MouseEventArgs e)
        {
            Rectangle rec = PatternPB.RectangleToScreen(PatternPB.ClientRectangle);

            MyPic = new Bitmap(PatternPB.ClientSize.Width, PatternPB.ClientSize.Height);
            Graphics.FromImage(MyPic).CopyFromScreen(rec.Location, new Point(0, 0), rec.Size);
            g = PatternPB.CreateGraphics();
        }
Esempio n. 3
0
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     path  = "";
     Text  = TitleName;
     MyPic = new Bitmap(PatternPB.ClientSize.Width, PatternPB.ClientSize.Height);
     g     = PatternPB.CreateGraphics();
     PatternPB.Refresh();
 }
Esempio n. 4
0
 private void ShadowPic_MouseMove(object sender, MouseEventArgs e)
 {
     if ((e.Button & MouseButtons.Left) != 0)
     {
         Point deltaPos = new Point(e.X - movestart.X, e.Y - movestart.Y);
         ShadowPic.Size = new Size(sizestartPnl.Width + deltaPos.X, sizestartPnl.Height + deltaPos.Y);
         g = PatternPB.CreateGraphics();
     }
 }
Esempio n. 5
0
        private void Color2Btn_BackColorChanged(object sender, EventArgs e)
        {
            Rectangle rec = PatternPB.RectangleToScreen(PatternPB.ClientRectangle);

            MyPic = new Bitmap(PatternPB.ClientSize.Width, PatternPB.ClientSize.Height);
            Graphics.FromImage(MyPic).CopyFromScreen(rec.Location, new Point(0, 0), rec.Size);
            PatternPB.Refresh();
            PatternPB.BackColor = Color2Btn.BackColor;
        }
Esempio n. 6
0
        private void PatternPB_MouseUp(object sender, MouseEventArgs e)
        {
            Rectangle rec = PatternPB.RectangleToScreen(PatternPB.ClientRectangle);

            MyPic = new Bitmap(PatternPB.ClientSize.Width, PatternPB.ClientSize.Height);
            Graphics.FromImage(MyPic).CopyFromScreen(rec.Location, new Point(0, 0), rec.Size);
            Painting = false;
            Array.Resize(ref PencilPoints, 0);
            Array.Resize(ref PenTypes, 0);
        }
Esempio n. 7
0
 private void Form1_Load(object sender, EventArgs e)
 {
     g = PatternPB.CreateGraphics();
     SizePictureTSSL.Text = $"{PatternPB.Width} × {PatternPB.Height}px";
     label1.Text          = Painter.ToString();
     for (int i = 100; i >= 1; i--)
     {
         SizeDUD.Items.Add(i);
     }
     SizeDUD.SelectedIndex = 99;
     MyPic = new Bitmap(PatternPB.ClientSize.Width, PatternPB.ClientSize.Height);
 }
Esempio n. 8
0
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     openFileDialog1.FileName = "";
     openFileDialog1.Filter   = filtersave +
                                "|ICO (*.ico)|*.ico;|" +
                                "WEBP (*.webp)|*.webp;|" +
                                "All Picture Files|*.bmp; *.dib; *.jpg; *.jpeg; *.jpe; *.jfif; *.gif; *.tif; *.tiff; *.png; *.heic; *.ico; *.webp;|" +
                                "All Files|*.*";
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         path = openFileDialog1.FileName;
         string file = openFileDialog1.SafeFileName;
         Text = file + " - " + TitleName;
         Image pic = Image.FromFile(path, true);
         MyPic          = new Bitmap(pic);
         ShadowPic.Size = new Size(MyPic.Width + 5, MyPic.Height + 5);
         g = PatternPB.CreateGraphics();
         PatternPB.Refresh();
     }
 }
Esempio n. 9
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            saveFileDialog1.Filter = filtersave;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                path = saveFileDialog1.FileName;
                string file = path.Split('\\').Last();
                Text = file + " - " + TitleName;
                switch (file.Split('.').Last())
                {
                case "bmp":
                    MyPic.Save(path, ImageFormat.Bmp);
                    break;

                case "jpg":
                    MyPic.Save(path, ImageFormat.Jpeg);
                    break;

                case "gif":
                    MyPic.Save(path, ImageFormat.Gif);
                    break;

                case "tif":
                    MyPic.Save(path, ImageFormat.Tiff);
                    break;

                case "png":
                    MyPic.Save(path, ImageFormat.Png);
                    break;
                }
                Image pic = Image.FromFile(path, true);
                MyPic          = new Bitmap(pic);
                ShadowPic.Size = new Size(MyPic.Width + 5, MyPic.Height + 5);
                g = PatternPB.CreateGraphics();
                PatternPB.Refresh();
            }
        }
Esempio n. 10
0
        private void PatternPB_MouseDown(object sender, MouseEventArgs e)
        {
            if (Painting)
            {
                Painting = false;
                g.DrawImage(MyPic, 0, 0);
            }
            else if ((e.Button == MouseButtons.Left || e.Button == MouseButtons.Right) && Painter != Painters.None)
            {
                Painting = true;

                PencilPoints = new Point[1] {
                    new Point(e.X, e.Y)
                };
                PenTypes = new byte[1] {
                    0
                };
                movestart = new Point(e.X, e.Y);

                Rectangle rec = PatternPB.RectangleToScreen(PatternPB.ClientRectangle);
                MyPic = new Bitmap(PatternPB.ClientSize.Width, PatternPB.ClientSize.Height);
                Graphics.FromImage(MyPic).CopyFromScreen(rec.Location, new Point(0, 0), rec.Size);
            }
        }
Esempio n. 11
0
 private void PatternPB_MouseLeave(object sender, EventArgs e)
 {
     LocationMouseTSSL.Text = "";
     PatternPB.Refresh();
 }