代码改变世界

随笔分类 -  One Code

如何在ASP.NET Core中实现CORS跨域

2016-12-02 10:40 by 微软一站式示例代码库, 4048 阅读, 收藏, 编辑

随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来操作应用程序。

 

目前Surface Dial 可以支持的终端硬件有三款:

  • Surface Studio
  • Surface Book
  • Surface Pro 4

有上述之一硬件的小伙伴们可以尝试一下这款新鲜的产品。

 

下面,我用一款简单的UWP程序来介绍如何给Surface Dial这款外设开发自定义的交互逻辑。

 

前期准备:

  • 请确保您的计算机操作系统是最新的Win10 Anniversary Update版本
  • 请确保您的Visual Studio是VS2015 update3 版本
  • Surface Dial设备(可选)
  • Surface Studio, Surface Book 以及 Surface Pro 4 都是可选项,如果没有,并不影响案例代码的运行

 

运行例子:

如果您有surface dial设备,并且拥有Surface Studio, Surface Book或者Surface Pro4其中的任一一款终端,请在Visual Studio里面运行我们的案例代码,并且将Surface Dail吸附在屏幕上。您将会看到下面这个界面。

此时,您可以选择Surface Dial,界面中的滑动条会跟着您的转动而变化,点击Surface Dial的按钮,界面中的开关控件会打开或者关闭。

 

使用代码:

您可以使用代码去自定义Surface Dail在您的应用程序里的旋转和点击操作。

控制Surface Dail的核心类是RadialController ,可以在Windows.UI.Input这个名字空间下找到该类。您可以调用RadialController.CreateForCurrentView() 来获取该类的实体。

 

RadialController类实体对外公布了几个事件,在这个例子里我们只关注ButtonClicked 事件和 RotationChanged事件。前者会在Surface Dail被点击的时候调用,而后者则是响应旋转操作。

 

下面是例子里的核心代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public sealed partial class MainPage : Page
{
    RadialController rdController = null;
    public MainPage()
    {
        this.InitializeComponent();
 
        // get controller
        rdController = RadialController.CreateForCurrentView();
 
        // process click event
        rdController.ButtonClicked += RdController_ButtonClicked;
 
        // process rotate event
        rdController.RotationChanged += RdController_RotationChanged;
    }
 
    private void RdController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
    {
        // change the slider according to the delta degree from rotating
        var deltaRatio = args.RotationDeltaInDegrees / 360.0f;
        this.slider.Value += this.slider.Maximum * deltaRatio;
    }
 
    private void RdController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
    {
        // switch the toggle to opposite status
        this.btnToggle.IsOn = !this.btnToggle.IsOn;
    }
}

 

最后,您可以通过访问 How to implement custom interactions for Surface Dial 来下载完整的代码案例。

 

在ASP.NET Core中使用Angular2,以及与Angular2的Token base身份认证

2016-11-17 09:12 by 微软一站式示例代码库, 7126 阅读, 收藏, 编辑

随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来操作应用程序。

 

目前Surface Dial 可以支持的终端硬件有三款:

  • Surface Studio
  • Surface Book
  • Surface Pro 4

有上述之一硬件的小伙伴们可以尝试一下这款新鲜的产品。

 

下面,我用一款简单的UWP程序来介绍如何给Surface Dial这款外设开发自定义的交互逻辑。

 

前期准备:

  • 请确保您的计算机操作系统是最新的Win10 Anniversary Update版本
  • 请确保您的Visual Studio是VS2015 update3 版本
  • Surface Dial设备(可选)
  • Surface Studio, Surface Book 以及 Surface Pro 4 都是可选项,如果没有,并不影响案例代码的运行

 

运行例子:

如果您有surface dial设备,并且拥有Surface Studio, Surface Book或者Surface Pro4其中的任一一款终端,请在Visual Studio里面运行我们的案例代码,并且将Surface Dail吸附在屏幕上。您将会看到下面这个界面。

此时,您可以选择Surface Dial,界面中的滑动条会跟着您的转动而变化,点击Surface Dial的按钮,界面中的开关控件会打开或者关闭。

 

使用代码:

您可以使用代码去自定义Surface Dail在您的应用程序里的旋转和点击操作。

控制Surface Dail的核心类是RadialController ,可以在Windows.UI.Input这个名字空间下找到该类。您可以调用RadialController.CreateForCurrentView() 来获取该类的实体。

 

RadialController类实体对外公布了几个事件,在这个例子里我们只关注ButtonClicked 事件和 RotationChanged事件。前者会在Surface Dail被点击的时候调用,而后者则是响应旋转操作。

 

下面是例子里的核心代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public sealed partial class MainPage : Page
{
    RadialController rdController = null;
    public MainPage()
    {
        this.InitializeComponent();
 
        // get controller
        rdController = RadialController.CreateForCurrentView();
 
        // process click event
        rdController.ButtonClicked += RdController_ButtonClicked;
 
        // process rotate event
        rdController.RotationChanged += RdController_RotationChanged;
    }
 
    private void RdController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
    {
        // change the slider according to the delta degree from rotating
        var deltaRatio = args.RotationDeltaInDegrees / 360.0f;
        this.slider.Value += this.slider.Maximum * deltaRatio;
    }
 
    private void RdController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
    {
        // switch the toggle to opposite status
        this.btnToggle.IsOn = !this.btnToggle.IsOn;
    }
}

 

最后,您可以通过访问 How to implement custom interactions for Surface Dial 来下载完整的代码案例。

 

在ASP.NET Core中实现一个Token base的身份认证

2016-11-16 09:57 by 微软一站式示例代码库, 6026 阅读, 收藏, 编辑
摘要: 注:本文提到的代码示例下载地址> How to achieve a bearer token authentication and authorization in ASP.NET Core 在ASP.NET Core中实现一个Token base的身份认证 以前在web端的身份认证都是基于Cook 阅读全文

如何用TypeScript开发微信小程序

2016-11-14 10:18 by 微软一站式示例代码库, 14299 阅读, 收藏, 编辑

随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来操作应用程序。

 

目前Surface Dial 可以支持的终端硬件有三款:

  • Surface Studio
  • Surface Book
  • Surface Pro 4

有上述之一硬件的小伙伴们可以尝试一下这款新鲜的产品。

 

下面,我用一款简单的UWP程序来介绍如何给Surface Dial这款外设开发自定义的交互逻辑。

 

前期准备:

  • 请确保您的计算机操作系统是最新的Win10 Anniversary Update版本
  • 请确保您的Visual Studio是VS2015 update3 版本
  • Surface Dial设备(可选)
  • Surface Studio, Surface Book 以及 Surface Pro 4 都是可选项,如果没有,并不影响案例代码的运行

 

运行例子:

如果您有surface dial设备,并且拥有Surface Studio, Surface Book或者Surface Pro4其中的任一一款终端,请在Visual Studio里面运行我们的案例代码,并且将Surface Dail吸附在屏幕上。您将会看到下面这个界面。

此时,您可以选择Surface Dial,界面中的滑动条会跟着您的转动而变化,点击Surface Dial的按钮,界面中的开关控件会打开或者关闭。

 

使用代码:

您可以使用代码去自定义Surface Dail在您的应用程序里的旋转和点击操作。

控制Surface Dail的核心类是RadialController ,可以在Windows.UI.Input这个名字空间下找到该类。您可以调用RadialController.CreateForCurrentView() 来获取该类的实体。

 

RadialController类实体对外公布了几个事件,在这个例子里我们只关注ButtonClicked 事件和 RotationChanged事件。前者会在Surface Dail被点击的时候调用,而后者则是响应旋转操作。

 

下面是例子里的核心代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public sealed partial class MainPage : Page
{
    RadialController rdController = null;
    public MainPage()
    {
        this.InitializeComponent();
 
        // get controller
        rdController = RadialController.CreateForCurrentView();
 
        // process click event
        rdController.ButtonClicked += RdController_ButtonClicked;
 
        // process rotate event
        rdController.RotationChanged += RdController_RotationChanged;
    }
 
    private void RdController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
    {
        // change the slider according to the delta degree from rotating
        var deltaRatio = args.RotationDeltaInDegrees / 360.0f;
        this.slider.Value += this.slider.Maximum * deltaRatio;
    }
 
    private void RdController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
    {
        // switch the toggle to opposite status
        this.btnToggle.IsOn = !this.btnToggle.IsOn;
    }
}

 

最后,您可以通过访问 How to implement custom interactions for Surface Dial 来下载完整的代码案例。

 

如何在ASP.NET Core中应用Entity Framework

2016-11-01 10:45 by 微软一站式示例代码库, 4038 阅读, 收藏, 编辑
摘要: 首先我们需要知道,在ASP.NET Core中是无法使用经典的.NET Framework版本的Entity Framework的,本节我将为大家演示如何在ASP.NET Core中应用.NET Core版本的Entity Framework 阅读全文

如何在ASP.NET Core中实现一个基础的身份认证

2016-10-31 13:08 by 微软一站式示例代码库, 7139 阅读, 收藏, 编辑

随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来操作应用程序。

 

目前Surface Dial 可以支持的终端硬件有三款:

  • Surface Studio
  • Surface Book
  • Surface Pro 4

有上述之一硬件的小伙伴们可以尝试一下这款新鲜的产品。

 

下面,我用一款简单的UWP程序来介绍如何给Surface Dial这款外设开发自定义的交互逻辑。

 

前期准备:

  • 请确保您的计算机操作系统是最新的Win10 Anniversary Update版本
  • 请确保您的Visual Studio是VS2015 update3 版本
  • Surface Dial设备(可选)
  • Surface Studio, Surface Book 以及 Surface Pro 4 都是可选项,如果没有,并不影响案例代码的运行

 

运行例子:

如果您有surface dial设备,并且拥有Surface Studio, Surface Book或者Surface Pro4其中的任一一款终端,请在Visual Studio里面运行我们的案例代码,并且将Surface Dail吸附在屏幕上。您将会看到下面这个界面。

此时,您可以选择Surface Dial,界面中的滑动条会跟着您的转动而变化,点击Surface Dial的按钮,界面中的开关控件会打开或者关闭。

 

使用代码:

您可以使用代码去自定义Surface Dail在您的应用程序里的旋转和点击操作。

控制Surface Dail的核心类是RadialController ,可以在Windows.UI.Input这个名字空间下找到该类。您可以调用RadialController.CreateForCurrentView() 来获取该类的实体。

 

RadialController类实体对外公布了几个事件,在这个例子里我们只关注ButtonClicked 事件和 RotationChanged事件。前者会在Surface Dail被点击的时候调用,而后者则是响应旋转操作。

 

下面是例子里的核心代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public sealed partial class MainPage : Page
{
    RadialController rdController = null;
    public MainPage()
    {
        this.InitializeComponent();
 
        // get controller
        rdController = RadialController.CreateForCurrentView();
 
        // process click event
        rdController.ButtonClicked += RdController_ButtonClicked;
 
        // process rotate event
        rdController.RotationChanged += RdController_RotationChanged;
    }
 
    private void RdController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
    {
        // change the slider according to the delta degree from rotating
        var deltaRatio = args.RotationDeltaInDegrees / 360.0f;
        this.slider.Value += this.slider.Maximum * deltaRatio;
    }
 
    private void RdController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
    {
        // switch the toggle to opposite status
        this.btnToggle.IsOn = !this.btnToggle.IsOn;
    }
}

 

最后,您可以通过访问 How to implement custom interactions for Surface Dial 来下载完整的代码案例。

 

如何用Azure Web App Services接入微信公众号

2016-10-19 13:25 by 微软一站式示例代码库, 1288 阅读, 收藏, 编辑

随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来操作应用程序。

 

目前Surface Dial 可以支持的终端硬件有三款:

  • Surface Studio
  • Surface Book
  • Surface Pro 4

有上述之一硬件的小伙伴们可以尝试一下这款新鲜的产品。

 

下面,我用一款简单的UWP程序来介绍如何给Surface Dial这款外设开发自定义的交互逻辑。

 

前期准备:

  • 请确保您的计算机操作系统是最新的Win10 Anniversary Update版本
  • 请确保您的Visual Studio是VS2015 update3 版本
  • Surface Dial设备(可选)
  • Surface Studio, Surface Book 以及 Surface Pro 4 都是可选项,如果没有,并不影响案例代码的运行

 

运行例子:

如果您有surface dial设备,并且拥有Surface Studio, Surface Book或者Surface Pro4其中的任一一款终端,请在Visual Studio里面运行我们的案例代码,并且将Surface Dail吸附在屏幕上。您将会看到下面这个界面。

此时,您可以选择Surface Dial,界面中的滑动条会跟着您的转动而变化,点击Surface Dial的按钮,界面中的开关控件会打开或者关闭。

 

使用代码:

您可以使用代码去自定义Surface Dail在您的应用程序里的旋转和点击操作。

控制Surface Dail的核心类是RadialController ,可以在Windows.UI.Input这个名字空间下找到该类。您可以调用RadialController.CreateForCurrentView() 来获取该类的实体。

 

RadialController类实体对外公布了几个事件,在这个例子里我们只关注ButtonClicked 事件和 RotationChanged事件。前者会在Surface Dail被点击的时候调用,而后者则是响应旋转操作。

 

下面是例子里的核心代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public sealed partial class MainPage : Page
{
    RadialController rdController = null;
    public MainPage()
    {
        this.InitializeComponent();
 
        // get controller
        rdController = RadialController.CreateForCurrentView();
 
        // process click event
        rdController.ButtonClicked += RdController_ButtonClicked;
 
        // process rotate event
        rdController.RotationChanged += RdController_RotationChanged;
    }
 
    private void RdController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
    {
        // change the slider according to the delta degree from rotating
        var deltaRatio = args.RotationDeltaInDegrees / 360.0f;
        this.slider.Value += this.slider.Maximum * deltaRatio;
    }
 
    private void RdController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
    {
        // switch the toggle to opposite status
        this.btnToggle.IsOn = !this.btnToggle.IsOn;
    }
}

 

最后,您可以通过访问 How to implement custom interactions for Surface Dial 来下载完整的代码案例。

 

如何创建一个简单的Visual Studio Code扩展

2016-10-12 17:48 by 微软一站式示例代码库, 5212 阅读, 收藏, 编辑

随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来操作应用程序。

 

目前Surface Dial 可以支持的终端硬件有三款:

  • Surface Studio
  • Surface Book
  • Surface Pro 4

有上述之一硬件的小伙伴们可以尝试一下这款新鲜的产品。

 

下面,我用一款简单的UWP程序来介绍如何给Surface Dial这款外设开发自定义的交互逻辑。

 

前期准备:

  • 请确保您的计算机操作系统是最新的Win10 Anniversary Update版本
  • 请确保您的Visual Studio是VS2015 update3 版本
  • Surface Dial设备(可选)
  • Surface Studio, Surface Book 以及 Surface Pro 4 都是可选项,如果没有,并不影响案例代码的运行

 

运行例子:

如果您有surface dial设备,并且拥有Surface Studio, Surface Book或者Surface Pro4其中的任一一款终端,请在Visual Studio里面运行我们的案例代码,并且将Surface Dail吸附在屏幕上。您将会看到下面这个界面。

此时,您可以选择Surface Dial,界面中的滑动条会跟着您的转动而变化,点击Surface Dial的按钮,界面中的开关控件会打开或者关闭。

 

使用代码:

您可以使用代码去自定义Surface Dail在您的应用程序里的旋转和点击操作。

控制Surface Dail的核心类是RadialController ,可以在Windows.UI.Input这个名字空间下找到该类。您可以调用RadialController.CreateForCurrentView() 来获取该类的实体。

 

RadialController类实体对外公布了几个事件,在这个例子里我们只关注ButtonClicked 事件和 RotationChanged事件。前者会在Surface Dail被点击的时候调用,而后者则是响应旋转操作。

 

下面是例子里的核心代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public sealed partial class MainPage : Page
{
    RadialController rdController = null;
    public MainPage()
    {
        this.InitializeComponent();
 
        // get controller
        rdController = RadialController.CreateForCurrentView();
 
        // process click event
        rdController.ButtonClicked += RdController_ButtonClicked;
 
        // process rotate event
        rdController.RotationChanged += RdController_RotationChanged;
    }
 
    private void RdController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
    {
        // change the slider according to the delta degree from rotating
        var deltaRatio = args.RotationDeltaInDegrees / 360.0f;
        this.slider.Value += this.slider.Maximum * deltaRatio;
    }
 
    private void RdController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
    {
        // switch the toggle to opposite status
        this.btnToggle.IsOn = !this.btnToggle.IsOn;
    }
}

 

最后,您可以通过访问 How to implement custom interactions for Surface Dial 来下载完整的代码案例。

 

如何用Unity创建一个的简单的HoloLens 3D程序

2016-10-08 15:35 by 微软一站式示例代码库, 4169 阅读, 收藏, 编辑

随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来操作应用程序。

 

目前Surface Dial 可以支持的终端硬件有三款:

  • Surface Studio
  • Surface Book
  • Surface Pro 4

有上述之一硬件的小伙伴们可以尝试一下这款新鲜的产品。

 

下面,我用一款简单的UWP程序来介绍如何给Surface Dial这款外设开发自定义的交互逻辑。

 

前期准备:

  • 请确保您的计算机操作系统是最新的Win10 Anniversary Update版本
  • 请确保您的Visual Studio是VS2015 update3 版本
  • Surface Dial设备(可选)
  • Surface Studio, Surface Book 以及 Surface Pro 4 都是可选项,如果没有,并不影响案例代码的运行

 

运行例子:

如果您有surface dial设备,并且拥有Surface Studio, Surface Book或者Surface Pro4其中的任一一款终端,请在Visual Studio里面运行我们的案例代码,并且将Surface Dail吸附在屏幕上。您将会看到下面这个界面。

此时,您可以选择Surface Dial,界面中的滑动条会跟着您的转动而变化,点击Surface Dial的按钮,界面中的开关控件会打开或者关闭。

 

使用代码:

您可以使用代码去自定义Surface Dail在您的应用程序里的旋转和点击操作。

控制Surface Dail的核心类是RadialController ,可以在Windows.UI.Input这个名字空间下找到该类。您可以调用RadialController.CreateForCurrentView() 来获取该类的实体。

 

RadialController类实体对外公布了几个事件,在这个例子里我们只关注ButtonClicked 事件和 RotationChanged事件。前者会在Surface Dail被点击的时候调用,而后者则是响应旋转操作。

 

下面是例子里的核心代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public sealed partial class MainPage : Page
{
    RadialController rdController = null;
    public MainPage()
    {
        this.InitializeComponent();
 
        // get controller
        rdController = RadialController.CreateForCurrentView();
 
        // process click event
        rdController.ButtonClicked += RdController_ButtonClicked;
 
        // process rotate event
        rdController.RotationChanged += RdController_RotationChanged;
    }
 
    private void RdController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
    {
        // change the slider according to the delta degree from rotating
        var deltaRatio = args.RotationDeltaInDegrees / 360.0f;
        this.slider.Value += this.slider.Maximum * deltaRatio;
    }
 
    private void RdController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
    {
        // switch the toggle to opposite status
        this.btnToggle.IsOn = !this.btnToggle.IsOn;
    }
}

 

最后,您可以通过访问 How to implement custom interactions for Surface Dial 来下载完整的代码案例。

 

如何在Microsoft Edge浏览器中添加一个Hello World插件

2016-09-30 14:28 by 微软一站式示例代码库, 10324 阅读, 收藏, 编辑

随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来操作应用程序。

 

目前Surface Dial 可以支持的终端硬件有三款:

  • Surface Studio
  • Surface Book
  • Surface Pro 4

有上述之一硬件的小伙伴们可以尝试一下这款新鲜的产品。

 

下面,我用一款简单的UWP程序来介绍如何给Surface Dial这款外设开发自定义的交互逻辑。

 

前期准备:

  • 请确保您的计算机操作系统是最新的Win10 Anniversary Update版本
  • 请确保您的Visual Studio是VS2015 update3 版本
  • Surface Dial设备(可选)
  • Surface Studio, Surface Book 以及 Surface Pro 4 都是可选项,如果没有,并不影响案例代码的运行

 

运行例子:

如果您有surface dial设备,并且拥有Surface Studio, Surface Book或者Surface Pro4其中的任一一款终端,请在Visual Studio里面运行我们的案例代码,并且将Surface Dail吸附在屏幕上。您将会看到下面这个界面。

此时,您可以选择Surface Dial,界面中的滑动条会跟着您的转动而变化,点击Surface Dial的按钮,界面中的开关控件会打开或者关闭。

 

使用代码:

您可以使用代码去自定义Surface Dail在您的应用程序里的旋转和点击操作。

控制Surface Dail的核心类是RadialController ,可以在Windows.UI.Input这个名字空间下找到该类。您可以调用RadialController.CreateForCurrentView() 来获取该类的实体。

 

RadialController类实体对外公布了几个事件,在这个例子里我们只关注ButtonClicked 事件和 RotationChanged事件。前者会在Surface Dail被点击的时候调用,而后者则是响应旋转操作。

 

下面是例子里的核心代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public sealed partial class MainPage : Page
{
    RadialController rdController = null;
    public MainPage()
    {
        this.InitializeComponent();
 
        // get controller
        rdController = RadialController.CreateForCurrentView();
 
        // process click event
        rdController.ButtonClicked += RdController_ButtonClicked;
 
        // process rotate event
        rdController.RotationChanged += RdController_RotationChanged;
    }
 
    private void RdController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
    {
        // change the slider according to the delta degree from rotating
        var deltaRatio = args.RotationDeltaInDegrees / 360.0f;
        this.slider.Value += this.slider.Maximum * deltaRatio;
    }
 
    private void RdController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
    {
        // switch the toggle to opposite status
        this.btnToggle.IsOn = !this.btnToggle.IsOn;
    }
}

 

最后,您可以通过访问 How to implement custom interactions for Surface Dial 来下载完整的代码案例。

 

如何在HoloLens中创建一个2D的Hello World程序

2016-09-19 16:35 by 微软一站式示例代码库, 2054 阅读, 收藏, 编辑

随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来操作应用程序。

 

目前Surface Dial 可以支持的终端硬件有三款:

  • Surface Studio
  • Surface Book
  • Surface Pro 4

有上述之一硬件的小伙伴们可以尝试一下这款新鲜的产品。

 

下面,我用一款简单的UWP程序来介绍如何给Surface Dial这款外设开发自定义的交互逻辑。

 

前期准备:

  • 请确保您的计算机操作系统是最新的Win10 Anniversary Update版本
  • 请确保您的Visual Studio是VS2015 update3 版本
  • Surface Dial设备(可选)
  • Surface Studio, Surface Book 以及 Surface Pro 4 都是可选项,如果没有,并不影响案例代码的运行

 

运行例子:

如果您有surface dial设备,并且拥有Surface Studio, Surface Book或者Surface Pro4其中的任一一款终端,请在Visual Studio里面运行我们的案例代码,并且将Surface Dail吸附在屏幕上。您将会看到下面这个界面。

此时,您可以选择Surface Dial,界面中的滑动条会跟着您的转动而变化,点击Surface Dial的按钮,界面中的开关控件会打开或者关闭。

 

使用代码:

您可以使用代码去自定义Surface Dail在您的应用程序里的旋转和点击操作。

控制Surface Dail的核心类是RadialController ,可以在Windows.UI.Input这个名字空间下找到该类。您可以调用RadialController.CreateForCurrentView() 来获取该类的实体。

 

RadialController类实体对外公布了几个事件,在这个例子里我们只关注ButtonClicked 事件和 RotationChanged事件。前者会在Surface Dail被点击的时候调用,而后者则是响应旋转操作。

 

下面是例子里的核心代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public sealed partial class MainPage : Page
{
    RadialController rdController = null;
    public MainPage()
    {
        this.InitializeComponent();
 
        // get controller
        rdController = RadialController.CreateForCurrentView();
 
        // process click event
        rdController.ButtonClicked += RdController_ButtonClicked;
 
        // process rotate event
        rdController.RotationChanged += RdController_RotationChanged;
    }
 
    private void RdController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
    {
        // change the slider according to the delta degree from rotating
        var deltaRatio = args.RotationDeltaInDegrees / 360.0f;
        this.slider.Value += this.slider.Maximum * deltaRatio;
    }
 
    private void RdController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
    {
        // switch the toggle to opposite status
        this.btnToggle.IsOn = !this.btnToggle.IsOn;
    }
}

 

最后,您可以通过访问 How to implement custom interactions for Surface Dial 来下载完整的代码案例。

 

TypeScript 2.0候选版(RC)已出,哪些新特性值得我们关注?

2016-09-01 14:30 by 微软一站式示例代码库, 652 阅读, 收藏, 编辑

随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来操作应用程序。

 

目前Surface Dial 可以支持的终端硬件有三款:

  • Surface Studio
  • Surface Book
  • Surface Pro 4

有上述之一硬件的小伙伴们可以尝试一下这款新鲜的产品。

 

下面,我用一款简单的UWP程序来介绍如何给Surface Dial这款外设开发自定义的交互逻辑。

 

前期准备:

  • 请确保您的计算机操作系统是最新的Win10 Anniversary Update版本
  • 请确保您的Visual Studio是VS2015 update3 版本
  • Surface Dial设备(可选)
  • Surface Studio, Surface Book 以及 Surface Pro 4 都是可选项,如果没有,并不影响案例代码的运行

 

运行例子:

如果您有surface dial设备,并且拥有Surface Studio, Surface Book或者Surface Pro4其中的任一一款终端,请在Visual Studio里面运行我们的案例代码,并且将Surface Dail吸附在屏幕上。您将会看到下面这个界面。

此时,您可以选择Surface Dial,界面中的滑动条会跟着您的转动而变化,点击Surface Dial的按钮,界面中的开关控件会打开或者关闭。

 

使用代码:

您可以使用代码去自定义Surface Dail在您的应用程序里的旋转和点击操作。

控制Surface Dail的核心类是RadialController ,可以在Windows.UI.Input这个名字空间下找到该类。您可以调用RadialController.CreateForCurrentView() 来获取该类的实体。

 

RadialController类实体对外公布了几个事件,在这个例子里我们只关注ButtonClicked 事件和 RotationChanged事件。前者会在Surface Dail被点击的时候调用,而后者则是响应旋转操作。

 

下面是例子里的核心代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public sealed partial class MainPage : Page
{
    RadialController rdController = null;
    public MainPage()
    {
        this.InitializeComponent();
 
        // get controller
        rdController = RadialController.CreateForCurrentView();
 
        // process click event
        rdController.ButtonClicked += RdController_ButtonClicked;
 
        // process rotate event
        rdController.RotationChanged += RdController_RotationChanged;
    }
 
    private void RdController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
    {
        // change the slider according to the delta degree from rotating
        var deltaRatio = args.RotationDeltaInDegrees / 360.0f;
        this.slider.Value += this.slider.Maximum * deltaRatio;
    }
 
    private void RdController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
    {
        // switch the toggle to opposite status
        this.btnToggle.IsOn = !this.btnToggle.IsOn;
    }
}

 

最后,您可以通过访问 How to implement custom interactions for Surface Dial 来下载完整的代码案例。

 

C# 7.0 新功能代码范例

2016-09-01 14:12 by 微软一站式示例代码库, 676 阅读, 收藏, 编辑

随着Surface Studio的发布,微软发布了与之相配套的外设硬件Surface Dial,用户可以将Surface Dail吸附在Surface Studio的屏幕上面,用旋转和点击的实体操作来操作应用程序。

 

目前Surface Dial 可以支持的终端硬件有三款:

  • Surface Studio
  • Surface Book
  • Surface Pro 4

有上述之一硬件的小伙伴们可以尝试一下这款新鲜的产品。

 

下面,我用一款简单的UWP程序来介绍如何给Surface Dial这款外设开发自定义的交互逻辑。

 

前期准备:

  • 请确保您的计算机操作系统是最新的Win10 Anniversary Update版本
  • 请确保您的Visual Studio是VS2015 update3 版本
  • Surface Dial设备(可选)
  • Surface Studio, Surface Book 以及 Surface Pro 4 都是可选项,如果没有,并不影响案例代码的运行

 

运行例子:

如果您有surface dial设备,并且拥有Surface Studio, Surface Book或者Surface Pro4其中的任一一款终端,请在Visual Studio里面运行我们的案例代码,并且将Surface Dail吸附在屏幕上。您将会看到下面这个界面。

此时,您可以选择Surface Dial,界面中的滑动条会跟着您的转动而变化,点击Surface Dial的按钮,界面中的开关控件会打开或者关闭。

 

使用代码:

您可以使用代码去自定义Surface Dail在您的应用程序里的旋转和点击操作。

控制Surface Dail的核心类是RadialController ,可以在Windows.UI.Input这个名字空间下找到该类。您可以调用RadialController.CreateForCurrentView() 来获取该类的实体。

 

RadialController类实体对外公布了几个事件,在这个例子里我们只关注ButtonClicked 事件和 RotationChanged事件。前者会在Surface Dail被点击的时候调用,而后者则是响应旋转操作。

 

下面是例子里的核心代码片段:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
public sealed partial class MainPage : Page
{
    RadialController rdController = null;
    public MainPage()
    {
        this.InitializeComponent();
 
        // get controller
        rdController = RadialController.CreateForCurrentView();
 
        // process click event
        rdController.ButtonClicked += RdController_ButtonClicked;
 
        // process rotate event
        rdController.RotationChanged += RdController_RotationChanged;
    }
 
    private void RdController_RotationChanged(RadialController sender, RadialControllerRotationChangedEventArgs args)
    {
        // change the slider according to the delta degree from rotating
        var deltaRatio = args.RotationDeltaInDegrees / 360.0f;
        this.slider.Value += this.slider.Maximum * deltaRatio;
    }
 
    private void RdController_ButtonClicked(RadialController sender, RadialControllerButtonClickedEventArgs args)
    {
        // switch the toggle to opposite status
        this.btnToggle.IsOn = !this.btnToggle.IsOn;
    }
}

 

最后,您可以通过访问 How to implement custom interactions for Surface Dial 来下载完整的代码案例。

 

官方站点:
点击右上角即可分享
微信分享提示