当前位置: 首页>>代码示例>>C#>>正文


C# Distance.BestMeasureAs方法代码示例

本文整理汇总了C#中Distance.BestMeasureAs方法的典型用法代码示例。如果您正苦于以下问题:C# Distance.BestMeasureAs方法的具体用法?C# Distance.BestMeasureAs怎么用?C# Distance.BestMeasureAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Distance的用法示例。


在下文中一共展示了Distance.BestMeasureAs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RefreshFromDistance

        private void RefreshFromDistance(Distance newDistance)
        {
            if (newDistance == null)
            {
                if (WherigoObject == null)
                {
                    // Shows the control in a state displaying that the distance is undefined.
                    DistanceText.Text = "In Range";
                    VisualStateManager.GoToState(this, this.UnknownState.Name, true);
                }
                else
                {
                    // Shows some context: the thing's container, if there is one.
                    if (WherigoObject.Container == null)
                    {
                        // No clue, let's just show "In Range".
                        DistanceText.Text = "In Range";
                        VisualStateManager.GoToState(this, this.UnknownState.Name, true);
                    }
                    else
                    {
                        // We have a name.
                        DistanceText.Text = "By " + WherigoObject.Container.Name;
                        VisualStateManager.GoToState(this, this.UnknownState.Name, true);
                    }
                }
            }
            else
            {
                // Tries to retrieve the new distance value.
                // In some rare cases this may fail.
                double distanceValue = 0;
                try
                {
                    distanceValue = newDistance.Value;
                }
                catch (InvalidOperationException)
                {
                    // This probably means that an error occurred while computing
                    // or retrieving the value. Let's display "Unknown" as a distance
                    // text.
                    DistanceText.Text = "Unknown";
                    return;
                }

                // Are we inside or outside?
                if (distanceValue == 0)
                {
                    DistanceText.Text = "Here";
                    VisualStateManager.GoToState(this, this.InsideState.Name, true);
                }
                else
                {
                    DistanceText.Text = newDistance.BestMeasureAs(DistanceUnit.Meters);
                    VisualStateManager.GoToState(this, this.OutsideState.Name, true);
                }

            }
        }
开发者ID:chier01,项目名称:WF.Player.WinPhone,代码行数:59,代码来源:DistanceControl.xaml.cs


注:本文中的Distance.BestMeasureAs方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。