资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

WPF如何开发SurfaceDial-创新互联

这篇文章主要介绍了WPF如何开发Surface Dial,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

站在用户的角度思考问题,与客户深入沟通,找到禹王台网站设计与禹王台网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:做网站、网站建设、企业官网、英文网站、手机端网站、网站推广、主机域名虚拟主机、企业邮箱。业务覆盖禹王台地区。

示例:

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; ;
        }

还有个很关键的类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);
    }

这个类提供了CreateForWindow方法可以让我们创建RadialController对象,个人觉得这个接口很玄乎,上边的Guid特性(这个是叫特性吧?)是写死的,问了工程师说这个不用改,这不就很坑了,如果不是有个demo,我怎么知道怎么写,,,

作为弱鸡,这里我也有问题请教大家:

1.这些特性的作用,平时自己写代码貌似只用过【datacontract】


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

2.MainWindow中代码

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

总觉得阅读性这么差呢,看不懂,或许是我从未见过,对这个方法不熟?

微软工程师给我的这个Demo我发现有两个Bug(他本人也表示还没写完,是Dirty Demo),一个是SetRadialControllerConfiguration这个方法里异常,不能用,导致不能初始化Dial的菜单,每次启动应用都会往菜单里

添加一项;另一个是焦点问题,当长按dial选择了其他菜单,例如音量,再返回我们的demo,发现此时dial仍然控制的是音量

感谢你能够认真阅读完这篇文章,希望小编分享的“WPF如何开发Surface Dial”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联行业资讯频道,更多相关知识等着你来学习!


本文标题:WPF如何开发SurfaceDial-创新互联
URL地址:http://cdkjz.cn/article/dpjhjs.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220