2

Is there a way to type/edit text on a PictureBox or Panel? When user click somewhere on the PictureBox, the caret is shown and allow user to type text. I am making a program about graphic. I want it like text tool in MS Paint or Photoshop. But I have no idea. Someone has experience about this please give me a guide.

4

1 に答える 1

4

これを機能させるために取り組むことができるいくつかのコードを次に示します。

private void image_Click(object sender, EventArgs e)
    {
        float y = (float)Cursor.Position.Y -50;
        float x = (float)Cursor.Position.X -50;

        Bitmap b = new Bitmap(@"C:\Users\Dozer789\Downloads\notepad-png.bmp");

        RectangleF r = new RectangleF(x, y, 0, 0);

        Graphics g = Graphics.FromImage(b);

        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
        g.DrawString("yourText", new Font("Thaoma", 8), Brushes.Black, r);

        g.Flush();

        image.Image = b;
    }

いくつかのものを編集して追加する必要がありますが、それは少なくとも開始です。

これがうまくいくことを願っています!!

于 2013-07-25T01:55:07.833 に答える