示例#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);
         }
     }
 }
示例#2
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();
 }
示例#3
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;
        }
示例#4
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();
     }
 }
示例#5
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();
            }
        }
示例#6
0
 private void PatternPB_MouseLeave(object sender, EventArgs e)
 {
     LocationMouseTSSL.Text = "";
     PatternPB.Refresh();
 }