zoukankan      html  css  js  c++  java
  • Windows Phone 十九、罗盘

    磁力计概述

    拥有磁力计硬件支持的设备可以根据磁力计来确定相对于北极的角度

    磁力计的访问 API 定义在 Compass 类中

    调用方式和加速计类似

    1     <Grid Background="White">
    2         <Image Source="compass.png" RenderTransformOrigin="0.5,0.5">
    3             <Image.RenderTransform>
    4                 <CompositeTransform x:Name="rotate" Rotation="1"/>
    5             </Image.RenderTransform>
    6         </Image>
    7     </Grid>
     1         protected override void OnNavigatedTo(NavigationEventArgs e)
     2         {
     3             Compass c = Compass.GetDefault();
     4             if (c == null)
     5             {
     6                 // 不支持罗盘
     7                 return;
     8             }
     9             c.ReadingChanged += async (p1, p2) =>
    10             {
    11                 // 修改图片的旋转角度;
    12                 System.Diagnostics.Debug.WriteLine(p2.Reading.HeadingTrueNorth.Value);
    13                 await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
    14                 {
    15                     rotate.Rotation = -p2.Reading.HeadingTrueNorth.Value;
    16                 });
    17             };
    18             c.ReportInterval = c.MinimumReportInterval * 10;
    19         }
  • 相关阅读:
    关于codeblocks插件(持续更新)
    自定义gvim配色方案qiucz.vim的源码
    mark it
    poj 1032
    poj 1028
    最小公倍数是lcm
    problems
    hdu 1067
    某些题的做法。。。
    突然明白了什么
  • 原文地址:https://www.cnblogs.com/includeling/p/4601357.html
Copyright © 2011-2022 走看看