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

时间:2014-03-12 10:27:38

标签: javascript jquery html asp.net ajax

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

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();

        }
    }
}

1 个答案:

答案 0 :(得分:1)

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

http://jqueryui.com/draggable/

相关问题