windows phone画板程序
                                                            生活随笔
收集整理的這篇文章主要介紹了
                                windows phone画板程序
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.                        
                                ????????? 前幾天想要這樣一個(gè)程序,沒找到,今天上網(wǎng)偶然發(fā)現(xiàn)了,轉(zhuǎn)載過來。
<Grid> <InkPresenter x:Name="MyPresenter" HorizontalAlignment="Left" VerticalAlignment="Top" MouseLeftButtonDown="MyPresenter_MouseLeftButtonDown" LostMouseCapture="MyPresenter_LostMouseCapture" MouseMove="MyPresenter_MouseMove" Background="Transparent" Opacity="1" Width="480" Height="750" /> </Grid>
??????
[csharp] view plaincopyprint? using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Microsoft.Phone.Controls; // 引入以下命名空間。 using System.Windows.Ink; namespace InkPresentSample { public partial class MainPage : PhoneApplicationPage { Stroke CurrentStroke = null; // 構(gòu)造函數(shù) public MainPage() { InitializeComponent(); // 設(shè)置剪輯,以便收集墨跡 RectangleGeometry rg = new RectangleGeometry(); // 為了使范圍準(zhǔn)確,應(yīng)使用控件的最終呈現(xiàn)高度。 rg.Rect = new Rect(0, 0, MyPresenter.ActualWidth, MyPresenter.ActualHeight); MyPresenter.Clip = rg; } private void MyPresenter_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { // 當(dāng)我們點(diǎn)擊時(shí)獲捉鼠標(biāo)光標(biāo) MyPresenter.CaptureMouse(); // 收集當(dāng)前的光標(biāo)所在的位置的點(diǎn) StylusPointCollection sc = new StylusPointCollection(); sc.Add(e.StylusDevice.GetStylusPoints(MyPresenter)); CurrentStroke = new Stroke(sc); // 設(shè)置筆觸的顏色,大小 CurrentStroke.DrawingAttributes.Color = Colors.Yellow; CurrentStroke.DrawingAttributes.Width = 8; CurrentStroke.DrawingAttributes.Height = 8; // 把新的筆觸添加到集合中 MyPresenter.Strokes.Add(CurrentStroke); } private void MyPresenter_LostMouseCapture(object sender, MouseEventArgs e) { // 當(dāng)釋放鼠標(biāo)時(shí),也同時(shí)釋放筆觸變量的引用 CurrentStroke = null; } private void MyPresenter_MouseMove(object sender, MouseEventArgs e) { if (CurrentStroke != null) { // 每移動(dòng)一次鼠標(biāo),都收集對(duì)應(yīng)的點(diǎn)。 CurrentStroke.StylusPoints.Add(e.StylusDevice.GetStylusPoints(MyPresenter)); } } } }我試了運(yùn)行結(jié)果是正確 的,有需要的試試。
?
轉(zhuǎn)載于:https://www.cnblogs.com/learnWindowsPhone/archive/2012/04/24/2468948.html
總結(jié)
以上是生活随笔為你收集整理的windows phone画板程序的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
                            
                        - 上一篇: 2012年4月18日 新的开始
 - 下一篇: 【解决】insert 语句无效果,在查询