0

我想實現我的桌面上this program(其中有一個觸摸屏顯示器),運行Windows Phone模擬器在Visual Studio 2013年現在着墨在Windows的Silverlight 8.1的應用程序

(模擬器8.1 WVGA 4英寸512 MB)我改變了MyIP_MouseLeftButtonDown和MyIP_MouseMove函數來輸出一些調試數據,如下所示:

  1.  private void MyIP_MouseLeftButtonDown(object sender, MouseEventArgs e) 
         { 
          MyIP.CaptureMouse(); 
          StylusPointCollection MyStylusPointCollection = new StylusPointCollection(); 
    
          MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(MyIP));// MyIP is required here because it is the object with reference to which we get our stylus point's coordinates 
          NewStroke = new Stroke(MyStylusPointCollection); 
          Debug.WriteLine("Mouse Down"+MyStylusPointCollection.Count); 
    
          MyIP.Strokes.Add(NewStroke); 
         } 
    
    
         private void MyIP_MouseMove(object sender, MouseEventArgs e) 
         { 
          StylusPointCollection MyStylusPointCollection = new StylusPointCollection(); 
          MyStylusPointCollection.Add(e.StylusDevice.GetStylusPoints(MyIP)); 
          Debug.WriteLine("Mouse Move" + MyStylusPointCollection.Count); 
    
          if (NewStroke != null) 
           NewStroke.StylusPoints.Add(MyStylusPointCollection); 
         } 
    

    現在運行該應用時有2種情況

    當我用鼠標在畫布上寫字時,在第一筆畫中僅捕獲一個點並且未捕捉到動作。當鼠標按鈕被釋放,然後再次按下以啓動第二次中風時,整個中風都會受到控制。輸出和畫布(附圖)是:

    鼠標DOWN1
    鼠標Move1
    鼠標DOWN1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    enter image description here

  2. 當我用我的手指在畫布上寫,整個第一行程被抓獲,然後在第二行程也被抓獲。輸出和帆布(附圖)是:

    鼠標DOWN1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標移動1
    鼠標移動1
    鼠標移動1 < --------第二杆開始
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標Move1
    鼠標移動1
    鼠標移動1
    鼠標移動1
    enter image description here

有人能告訴我爲什麼鼠標不能正常工作嗎?

回答

0

在我的Ink使用體驗中,似乎有時Move事件沒有足夠快地到達。這意味着鼠標焦點會丟失,而沒有累積一些報告。例如:

鼠標DOWN1
鼠標Move1
... [鼠標移動]不是報道,但點得到積累...
[鼠標失落]是不是和上次的座標處理的報道鼠標移動到失落點。

您可以嘗試添加LostMouseCapture事件偵聽器,在哪裏添加鼠標丟失的最後一個點/段?

相關問題