Ejemplo n.º 1
0
        private void UpdateRadar()
        {
            float   radarAngle = MathHelper.ToRadians(-(float)((radarCanvas.RenderTransform as System.Windows.Media.RotateTransform).Angle));
            Vector2 v0         = Vector2.Zero;
            Vector2 v1         = new Vector2(60, -60);
            Vector2 v2         = new Vector2(-60, -60);

            v1 = Vector2Helper.RotateVector(radarAngle, v1);
            v2 = Vector2Helper.RotateVector(radarAngle, v2);
            Triangle radarHeadingTriangle = new Triangle(v0, v1, v2);

            //****comment in for Radar Heading Debug Lines****//
            //Dispatcher.BeginInvoke(delegate()
            //{
            //    var l1 = radarCanvas.Children[0] as System.Windows.Shapes.Line;
            //    var l2 = radarCanvas.Children[1] as System.Windows.Shapes.Line;
            //    l1.X2 = v1.X;
            //    l1.Y2 = v1.Y;
            //    l2.X2 = v2.X;
            //    l2.Y2 = v2.Y;
            //});
            //****comment in for Radar Heading Debug Lines****//

            foreach (LocationsVM.Location l in myVM.SelectedNearbyLocations)
            {
                if (radarHeadingTriangle.IsPointIn(l.RadarPoint))
                {
                    l.RadarPointRepresenter.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/images/yellow-dot.png", UriKind.Relative));
                }
                else
                {
                    l.RadarPointRepresenter.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("/images/white-dot.png", UriKind.Relative));
                }
            }
        }
Ejemplo n.º 2
0
            /// <summary>
            /// Calculates the HeadingAngle according to device (motion or compass) position angle
            /// and sets the HeadingAngle property of this Location
            /// </summary>
            /// <param name="deviceRotationAngle">device position angle in degrees</param>
            internal void CalculateHeadingAngle(double deviceRotationAngle)
            {
                double locationAngle = MathHelper.ToDegrees(Vector2Helper.AngleVectorToVector(RadarPoint, new Vector2(0, -45)));

                HeadingAngle = deviceRotationAngle - locationAngle
                               + Convert.ToInt32(RadarPoint.X > 0 && RadarPoint.Y < 0) * 90
                               - Convert.ToInt32(RadarPoint.X > 0 && RadarPoint.Y > 0) * 90;
            }