Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to develop Surface Dial by WPF

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces WPF how to develop Surface Dial, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Example:

Public MainWindow () {InitializeComponent (); / / SetRadialControllerConfiguration (); var interop = (IRadialControllerInterop) System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMarshal .GetActivationFactory (typeof (RadialController)); Guid guid = typeof (RadialController) .GetInterface ("IRadialController"). GUID; Window window = Window.GetWindow (this); var wih = new WindowInteropHelper (window); IntPtr hWnd = wih.Handle / / Create a reference to the RadialController.radialController = interop.CreateForWindow (hWnd, ref guid); string iconFileName = "Assets\\ dial_icon_custom_item.png"; string filePath = System.IO.Path.Combine (AppDomain.CurrentDomain.BaseDirectory, iconFileName); var getItemImageOperation = StorageFile.GetFileFromPathAsync (filePath); getItemImageOperation.Completed + = new AsyncOperationCompletedHandler (AddMenuItemFromImage); / / Declare input handlers for the RadialController.radialController.RotationChanged + = RadialController_RotationChanged;;}

There is also a critical class RadialControllerInterfaces.cs

[System.Runtime.InteropServices.Guid ("787cdaac-3186-476d-87e4-b9374a7b9970")] [System.Runtime.InteropServices.InterfaceType (System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIInspectable)] interface IRadialControllerConfigurationInterop {RadialControllerConfiguration GetForWindow (IntPtr hwnd, [System.Runtime.InteropServices.In] ref Guid riid) } [System.Runtime.InteropServices.Guid ("1B0535C9-57AD-45C1-9D79-AD5C34360513")] [System.Runtime.InteropServices.InterfaceType (System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIInspectable)] interface IRadialControllerInterop {RadialController CreateForWindow (IntPtr hwnd, [System.Runtime.InteropServices.In] ref Guid riid);}

This class provides a CreateForWindow method that allows us to create RadialController objects. Personally, I think this interface is very mysterious, the above Guid feature (this is called a feature, right? ) is written dead, asked the engineer that this does not need to change, this is not very crappy, if there is not a demo, how do I know how to write

As a weak chicken, I also have some questions to ask you:

1. The role of these features, usually write their own code seems to have only used [datacontract]

[System.Runtime.InteropServices.Guid ("1B0535C9-57AD-45C1-9D79-AD5C34360513")] [System.Runtime.InteropServices.InterfaceType (System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIInspectable)]

Code in 2.MainWindow

Var interop = (IRadialControllerInterop) System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeMarshal .GetActivationFactory (typeof (RadialController))

Always feel that the reading is so poor, do not understand, maybe I have never seen it, unfamiliar with this method?

The Demo given to me by the Microsoft engineer, I found that there are two Bug (he also said that it is not finished yet, it is Dirty Demo). One is that there is an exception in the SetRadialControllerConfiguration method, which cannot be used, so that the menu of Dial cannot be initialized. Every time the application is started, it will be added to the menu.

Add one item; the other is the focus problem. When you press dial to select other menus, such as volume, and then return to our demo, we find that dial still controls the volume.

Thank you for reading this article carefully. I hope the article "how to develop Surface Dial with WPF" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report