我只是希望用戶能夠用某種指針在屏幕上繪圖。如何在C#中使用Windows Metro風格應用程序的屏幕?
我已經有代碼工作捕捉指針的位置,但我無法弄清楚如何將像素或形狀或任何東西放在屏幕上。
我發現這個有用的教程:
http://www.dotnetspeaks.com/DisplayArticle.aspx?ID=137
而且我在這裏的文件一直在尋找:
http://msdn.microsoft.com/en-us/library/windows/apps/hh465055(v=VS.85).aspx
至今沒有運氣。 =(這個教程是針對Windows Phone 7的,所以它有點不同。= \ Help,please?=)
這就是我到目前爲止所做的。
拱起部:
private void Image_PointerPressed(object sender, PointerEventArgs e)
{
Debug.WriteLine("Image_PointerPressed");
isTracing = true;
}
private void Image_PointerReleased(object sender, PointerEventArgs e)
{
Debug.WriteLine("Image_PointerReleased");
isTracing = false;
}
private void Image_PointerMoved(object sender, PointerEventArgs e)
{
Debug.WriteLine("Image_PointerMoved");
Debug.WriteLine(e.GetCurrentPoint(this).Position);
if (isTracing)
{
Debug.WriteLine("isTracing");
Point pos = e.GetCurrentPoint(this).Position;
Color color = Colors.Green;
Line line = new Line() { X1 = pos.X, X2 = pos.X + 1, Y1 = pos.Y, Y2 = pos.Y + 1 };
line.Stroke = new SolidColorBrush(color);
line.StrokeThickness = 15;
//// So how do I draw this line onto the screen?? ////
}
}
僅供參考,東西在代碼的其他地方:
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Threading.Tasks; using Multimedia.FFmpeg; using Windows.Foundation; using Windows.Storage; using Windows.Storage.Pickers; using Windows.Storage.Streams; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Shapes; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Input; using Windows.UI.Input; bool isTracing = false;
我也發現這個教程,但仍然沒有幫助。 http://www.windowsphonegeek.com/tips/drawing-in-wp7-1-getting-started-and-line-shape – Crystal
什麼不工作的權利你已經擁有的代碼? –
我沒有畫任何東西到屏幕上。我不知道該怎麼做。 (順便說一句,感謝評論!) – Crystal