想要瞭解更多關於筆劃的奧秘嗎?<|reserved003|>文本帶您探索這看似簡單卻深藏玄機的文字結構。
優化您的 Windows 應用程式以進行手寫筆輸入
提供標準指標裝置功能及最佳 Windows Ink 體驗
在 Windows 應用程式中加入手寫筆功能,讓使用者體驗更自然的數位書寫和繪圖。本主題將聚焦於 Windows Ink 平台的配置和使用。
手寫筆功能的靈活性允許應用程式根據用户需求定製不同的體驗。
![]()
![]()
功能 描述 抓取筆墨輸入 捕捉手寫筆的位置和移動,並將其轉換為數位筆劃。 生成和儲存筆墨資料 管理和儲存使用者的書寫和繪圖資料。 手寫辨識 將手寫筆跡轉換為可編輯的文字。 Windows Ink 平台提供了高度的靈活性,能夠根據您的需求支援各種功能。例如,您可以將 InkCanvas UWP 控制項添加到您的應用程式中,以實現基本的筆跡功能。預設設定下,InkCanvas 僅支援來自手寫筆的筆墨輸入,並使用黑色鋼珠筆的筆畫和橡皮擦筆尖的擦除功能。
手寫筆功能的靈活性允許應用程式根據用户需求定製不同的體驗。
為了添加更多自訂功能,您需要訪問對應的 InkPresenter 物件。通過操作 InkPresenter,您可以設定和調整應用程式的筆墨行為。
自訂筆墨筆劃屬性
您可以動態地設定筆墨筆劃屬性,這樣筆劃在被轉譯到 InkCanvas 上時就能更好地滿足您的需求。例如,您可以根據使用者的偏好設定或應用程式的特定需求來改變筆劃的色彩。
![]()
![]()
延伸閲讀…
啟用多種輸入裝置
通過設定 InkPresenter 的 InputDeviceTypes 屬性,您可以允許畫筆、滑鼠和其他輸入裝置的輸入被解釋為筆墨筆劃。預設情況下,InkPresenter 僅支援手寫筆輸入,但您可以根據應用程式的需求來擴展這一功能。
自訂筆墨筆劃屬性
您可以動態地設定筆墨筆劃屬性,這樣筆劃在被轉譯到 InkCanvas 上時就能更好地滿足您的需求。例如,您可以根據使用者的偏好設定或應用程式的特定需求來改變筆劃的色彩。
延伸閲讀…
處理選取色彩的變更
為了反映使用者的選擇,您需要監聽色彩選取變化並相應地更新筆墨屬性。這樣可以確保筆劃在應用程式中的顯示始終如一。
支援選取和擦除功能
設定 InkPresenter 以解譯畫筆及滑鼠輸入
Initializing the InkPresenter
- Defining InkPresenter behavior
To set up the InkPresenter to interpret input from both pen and mouse, we must first create an instance of the InkPresenter class and configure it to handle all modified input.- Setting the InputProcessingConfiguration
We achieve this by setting the InkPresenter’s InputProcessingConfiguration.RightDragAction to InkInputRightDragAction.LeaveUnprocessed. This informs the InkPresenter to pass through and reach the InkUnprocessedInput class, allowing you to handle a series of pointer events.- Assigning event handlers
For the unprocessed input, we will assign event handlers to the InkPresenter for the PointerPressed, PointerMoved, and PointerReleased events. It is within these event handlers that we implement the selection functionality.- Handling StrokeStarted and StrokesErased events
Finally, we will also assign event handlers for the InkPresenter’s StrokeStarted and StrokesErased events. These event handlers are used to clear the UI selection when a new stroke begins or existing strokes are erased.Conclusion
By setting up the InkPresenter with the appropriate configurations and event handlers, we can effectively capture and interpret input from both pen and mouse, and handle the selection and erasure of ink strokes in our application.