我需要创建一个网页,我可以使用鼠标绘制图像(类似于绘画)。它可以在c#,asp.net或银光中帮助
答案 0 :(得分:2)
您可以使用javascript来查看此网站jsDraw2D
和这一个Drawing line in javascript
检查此页面的来源follow_the_mouse.htm
你可以看到它有鼠标移动功能,你可以得到鼠标坐标,而不是你应该定制它的最终解决方案!
答案 1 :(得分:1)
雅,通过在silverlight中使用Shapes,可以在silverlight中实现。您必须使用鼠标捕获的MouseDownPoint和MouseUpPoint来绘制图像。以下方法将显示silverlight
中矩形的示例图void DrawShape(Shape MyShape, Point MyStartpoint, Point MyEndpoint)
{
if (CreateRectangle)
{
MyShape.Stroke = new SolidColorBrush(SetColor);
MyShape.Stroke.Opacity = 0.1;
MyShape.Fill = new SolidColorBrush(SetColor);
MyShape.Fill.Opacity = 0;
MyShape.StrokeThickness = 2;
if (DrawMode)
{
Temp = End;
DrawMode = false;
}
if (Temp.X < MyEndpoint.X && Temp.Y < MyEndpoint.Y)
{
MyShape.SetValue(Canvas.LeftProperty, MyStartpoint.X);
MyShape.SetValue(Canvas.TopProperty, MyStartpoint.Y);
}
else if (Temp.X > MyEndpoint.X && Temp.Y < MyEndpoint.Y)
{
double LeftX = MyStartpoint.X - (Temp.X - MyEndpoint.X);
MyShape.SetValue(Canvas.LeftProperty, LeftX);
MyShape.SetValue(Canvas.TopProperty, MyStartpoint.Y);
}
else if (Temp.X < MyEndpoint.X && Temp.Y > MyEndpoint.Y)
{
double TopY = MyStartpoint.Y - (Temp.Y - MyEndpoint.Y);
MyShape.SetValue(Canvas.LeftProperty, MyStartpoint.X);
MyShape.SetValue(Canvas.TopProperty, TopY);
}
else if (Temp.X > MyEndpoint.X && Temp.Y > MyEndpoint.Y)
{
double LeftX = MyStartpoint.X - (Temp.X - End.X);
double TopY = MyStartpoint.Y - (Temp.Y - End.Y);
MyShape.SetValue(Canvas.LeftProperty, LeftX);
MyShape.SetValue(Canvas.TopProperty, TopY);
}
if (MyStartpoint.X > MyEndpoint.X)
{
MyShape.Width = MyStartpoint.X - MyEndpoint.X;
}
else
{
MyShape.Width = MyEndpoint.X - MyStartpoint.X;
}
if (MyStartpoint.Y > MyEndpoint.Y)
{
MyShape.Height = MyStartpoint.Y - MyEndpoint.Y;
}
else
{
MyShape.Height = MyEndpoint.Y - MyStartpoint.Y;
}
//Buttondown = false;
//diagram.Children.Add(MyShape);
}
}