用鼠标在图像上拖动文本框

drag textbox with mouse on image

本文关键字:拖动 文本 图像 鼠标      更新时间:2023-09-26

我想问如何在图像上移动文本。实际上,我正在设计在线设计衬衫网站,让用户能够在图像上添加文字。用户如何调整图像上的文本位置。这是我的代码,它是工作和文字是写在图像上,但我们不能使用鼠标光标移动图像。请帮助

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
namespace roughly
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void TextBox1_TextChanged(object sender, EventArgs e)
        {
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string value = Request.Form["TextBox1"];

            Bitmap bitMapImage = new
   System.Drawing.Bitmap(Server.MapPath("dallen.jpg"));
            Graphics graphicImage = Graphics.FromImage(bitMapImage);
            graphicImage.SmoothingMode = SmoothingMode.AntiAlias;
            graphicImage.DrawString (value,
   new Font("Arial", 12, FontStyle.Bold),
   SystemBrushes.WindowText, new Point(250, 300));

            Response.ContentType = "image/jpeg";
           bitMapImage.Save(Response.OutputStream, ImageFormat.Jpeg);
            graphicImage.Dispose();
            bitMapImage.Dispose();
        }
    }
}

你可能会重新发明轮子,为什么不试试这个-

http://jqueryui.com/draggable/