WPF Development Surface Dial Example Tutorials

Source: Internet
Author: User
Some time ago, the giant hard released a new input device surface Dial, with surface studio used to be simply cool to no friends.

I was fortunate to be involved in the company's business training, the biggest harvest is to discover that WPF can also develop dial, WPF can actually use the UWP api!

Not suspense, the key is a nuget named "Uwpdesktop", which adds this nuget to our WPF program. The WPF tuning UWP that was written in the previous article also took advantage of this nuget.

Since our existing solution is to take WPF, so the new intermittent I go straight to the topic, asked the foreigner this thing aids magnetic WPF, the answer is yes. How to use it, there is no demo, there is really, then trouble you copy to me,,, and then have the following demo

I'll just stick to the code.

Public MainWindow () {InitializeComponent ();//setradialcontrollerconfiguration (); var interop = (Iradialc Ontrollerinterop) 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<storagefile> (AddMenuItemFromImage);// Declare input handlers for the Radialcontroller.radialcontRoller.        Rotationchanged + = radialcontroller_rotationchanged; }

And there's a very 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, which the individual feels is iffy, the top GUID feature (this is called feature?). Is written dead, asked the engineer said this does not change, this is not very pit, if not have a demo, how do I know how to write,,,

As a weak chicken, here I also have 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));

I always feel that reading is so bad, can not understand, perhaps I have never seen, to this method is not familiar?

Microsoft engineers gave me this Demo I found that there are two bugs (he himself also said not finished, is dirty Demo), one is setradialcontrollerconfiguration This method exception, can not be used, resulting in unable to initialize Dial menu, Every time you start the app, it goes to the menu.

Add one, the other is the focus issue, when the long press dial selected other menus, such as volume, and then return to our demo, found at this time dial still control is the volume

Because I am too weak, not much to say, at the end attached to the Dr.neil of the demo of their own research, but also hope that you comment on the answer to my doubts

Link: Password: h722



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.