Пример #1
0
        private void DrawRecursive(Canvas canvas, TileSchema schema, ITransform transform, MemoryCache <MemoryStream> memoryCache, Extent extent, int level)
        {
            IList <TileInfo> tiles = schema.GetTilesInView(extent, level);

            foreach (TileInfo tile in tiles)
            {
                MemoryStream image = memoryCache.Find(tile.Index);
                if (image == null)
                {
                    if (level > 0)
                    {
                        DrawRecursive(canvas, schema, transform, memoryCache, tile.Extent.Intersect(extent), level - 1);
                    }
                }
                else
                {
                    Rect   dest    = MapTransformHelper.WorldToMap(tile.Extent, transform);
                    double opacity = DrawImage(canvas, image, dest, tile);
                    if ((opacity < 1) && (level > 0))
                    {
                        DrawRecursive(canvas, schema, transform, memoryCache, tile.Extent.Intersect(extent), level - 1);
                    }
                }
            }
        }
        private void MapControl_MouseMove(object sender, System.Windows.Input.MouseEventArgs e)
        {
            if (renderer.ActiveMarker != null)
            {
                ActiveMarkerText        = renderer.ActiveMarker.Text;
                ActiveMarkerDescription = renderer.ActiveMarker.Description;
            }
            else
            {
                ActiveMarkerText        = null;
                ActiveMarkerDescription = null;
            }

            updateInfo(e.GetPosition(this));

            if (isCtrlDown)
            {
                DrawBbox(e.GetPosition(this));
                return;
            }
            if (!this.mouseDown)
            {
                return;
            }
            if (this.previousMousePosition == new Point())
            {
                return; // It turns out that sometimes MouseMove+Pressed is called before MouseDown
            }

            this.currentMousePosition = e.GetPosition(this); //Needed for both MouseMove and MouseWheel event
            MapTransformHelper.Pan(this.transform, this.currentMousePosition, this.previousMousePosition);
            this.previousMousePosition = this.currentMousePosition;
            this.Refresh();
        }
Пример #3
0
        private void DrawCircle(Canvas canvas, TileSchema schema, ITransform transform, List <BruTile.UI.Ellipse> cache, Extent extent, int level)
        {
            foreach (var ellipse in cache)
            {
                double xt = ellipse.X;
                double yt = ellipse.Y;

                double radiust = transform.RadiusToMap(ellipse.Radius);
                Circle circle  = new Circle()
                {
                    Width           = radiust,
                    Height          = radiust,
                    StrokeThickness = 2,
                };
                if (ellipse.Type == Ellipse.ZoneType.Red_Zone)
                {
                    circle.Stroke = Brushes.Red;
                    // circle.Fill = Brushes.Red;
                }
                else
                {
                    //  circle.Fill = Brushes.Blue;
                    circle.Stroke = Brushes.Blue;
                }
                if (!canvas.Children.Contains(circle))
                {
                    canvas.Children.Add(circle);
                }

                Rect  dest = MapTransformHelper.WorldToMap(extent, transform);
                Point p    = transform.WorldToMap(xt, yt);

                if (dest.Contains(p))
                {
                    Canvas.SetZIndex(circle, 200);
                    Canvas.SetLeft(circle, p.X);
                    Canvas.SetTop(circle, p.Y);
                }
            }
        }
Пример #4
0
        public void DrawLines(Canvas canvas, TileSchema schema, ITransform transform, List <Marker> cachemarker, Extent extent, DateTimeOffset time, int level)
        {
            cachemarker.Sort(delegate(Marker p1, Marker p2) { return(p1.timeOffset.CompareTo(p2.timeOffset)); });

            for (int i = 0; i < cachemarker.Count - 1; i++)
            {
                if (cachemarker.Count == 0 || cachemarker[i].timeOffset > time || (!MapControl.warmuplog && cachemarker[i].ElapsedTime <= 0))
                {
                    continue;
                }
                Point p    = transform.WorldToMap(cachemarker[i].X, cachemarker[i].Y);
                Point p2   = transform.WorldToMap(cachemarker[i + 1].X, cachemarker[i + 1].Y);
                var   line = new System.Windows.Shapes.Line();
                //if (cachemarker[i].Type == "Vehicle leave")
                //    line.Stroke = Brushes.Blue;
                //else
                line.Stroke          = System.Windows.Media.Brushes.Red;
                line.X1              = p.X;
                line.X2              = p2.X;
                line.Y1              = p.Y;
                line.Y2              = p2.Y;
                line.StrokeThickness = 2;
                line.Visibility      = Visibility.Collapsed;
                if (!canvas.Children.Contains(line))
                {
                    canvas.Children.Add(line);
                }
                Rect dest = MapTransformHelper.WorldToMap(extent, transform);

                //if (dest.Contains(p) && dest.Contains(p2))
                //{
                Canvas.SetZIndex(line, 200);
                //  }
                line.Visibility = Visibility.Visible;
            }
        }
Пример #5
0
        //private void DrawMarkers(Canvas canvas, TileSchema schema, ITransform transform, List<Marker> cache, Extent extent, int level)
        //{

        //    foreach (Marker m in cache)
        //    {
        //        if (m.UIElement == null)
        //        {
        //            if (!m.Visible) continue;

        //            if (m.Points != null)
        //            {
        //                MarkerControl2 c = new MarkerControl2();
        //                c.Over += new RoutedEventHandler(c_Over);
        //                c.Leave += new RoutedEventHandler(c_Leave);
        //                c.Points = new PointCollection(m.Points);

        //                c.Text = m.Text;
        //                c.Description = m.Description;

        //                m.UIElement = c;
        //            }
        //            else
        //            {
        //                MarkerControl c = new MarkerControl();
        //                c.Over += new RoutedEventHandler(c_Over);
        //                c.Leave += new RoutedEventHandler(c_Leave);
        //                if (markerImages != null)
        //                {
        //                    if (markerImages.ContainsKey(m.ImageIndex))
        //                    {
        //                        c.Image = markerImages[m.ImageIndex];
        //                    }
        //                    else if (markerImages.ContainsKey(-1))
        //                    {
        //                        c.Image = markerImages[-1];
        //                    }
        //                }

        //                c.Text = m.Text;
        //                c.Description = m.Description;

        //                m.UIElement = c;
        //            }
        //        }


        //        //MarkerControl marker = m.UIElement as MarkerControl;
        //        UIElement marker = m.UIElement as UIElement;
        //        marker.Visibility = Visibility.Collapsed;

        //        if (!m.Visible)
        //        {
        //            continue;
        //        }

        //        if (!canvas.Children.Contains(marker))
        //        {
        //            canvas.Children.Add(marker);
        //        }

        //        Rect dest = MapTransformHelper.WorldToMap(extent, transform);
        //        Point p = transform.WorldToMap(m.X, m.Y);
        //        //if (dest.Contains(p))
        //        //{
        //            Canvas.SetZIndex(marker, m.ZIndex);
        //            Canvas.SetLeft(marker, p.X);
        //            Canvas.SetTop(marker, p.Y);

        //        //if (m.Points != null)
        //        //{
        //        //    if (!(marker.RenderTransform is ScaleTransform))
        //        //    {
        //        //        marker.RenderTransform = new ScaleTransform(1.0 / transform.Resolution, 1.0 / transform.Resolution);
        //        //    }
        //        //    else
        //        //    {
        //        //        ((ScaleTransform)marker.RenderTransform).ScaleX = 1.0 / transform.Resolution;
        //        //        ((ScaleTransform)marker.RenderTransform).ScaleY = 1.0 / transform.Resolution;
        //        //    }
        //        //}

        //        double factor = 1;
        //            if (!(marker.RenderTransform is ScaleTransform))
        //            {
        //                marker.RenderTransform = new ScaleTransform(1.0 / transform.Resolution * factor, 1.0 / transform.Resolution * factor);
        //            }
        //            else
        //            {
        //                ((ScaleTransform)marker.RenderTransform).ScaleX = 1.0 / transform.Resolution * factor;
        //                ((ScaleTransform)marker.RenderTransform).ScaleY = 1.0 / transform.Resolution * factor;
        //            }


        //            marker.Visibility = Visibility.Visible;

        //     //     }
        //    }
        //}

        #endregion

        private void DrawEvents(Canvas canvas, TileSchema schema, ITransform transform, List <Marker> cache, Extent extent, DateTimeOffset time, int level)
        {
            foreach (Marker m in cache)
            {
                if (cache.Count == 0 || m.timeOffset > time || m.timeOffset < MapControl.PlaneDepartureTime)
                {
                    continue;
                }

                if (m.UIElement == null)
                {
                    if (!m.Visible)
                    {
                        continue;
                    }

                    if (m.Points != null)
                    {
                        MarkerControl2 c = new MarkerControl2();
                        c.Over  += new RoutedEventHandler(c_Over);
                        c.Leave += new RoutedEventHandler(c_Leave);
                        c.Points = new PointCollection(m.Points);

                        c.Text        = m.Text;
                        c.Description = m.Description;

                        m.UIElement = c;
                    }
                    else
                    {
                        MarkerControl c = new MarkerControl();
                        c.Over  += new RoutedEventHandler(c_Over);
                        c.Leave += new RoutedEventHandler(c_Leave);
                        if (markerImages != null)
                        {
                            if (markerImages.ContainsKey(m.ImageIndex))
                            {
                                c.Image = markerImages[m.ImageIndex];
                            }
                            else if (markerImages.ContainsKey(-1))
                            {
                                c.Image = markerImages[-1];
                            }
                        }

                        c.Text        = m.Text;
                        c.Description = m.Description;

                        m.UIElement = c;
                    }
                }


                //MarkerControl marker = m.UIElement as MarkerControl;
                UIElement marker = m.UIElement as UIElement;
                marker.Visibility = Visibility.Collapsed;

                if (!m.Visible)
                {
                    continue;
                }

                if (!canvas.Children.Contains(marker))
                {
                    canvas.Children.Add(marker);
                }

                Rect  dest = MapTransformHelper.WorldToMap(extent, transform);
                Point p    = transform.WorldToMap(m.X, m.Y);
                //if (dest.Contains(p))
                //{
                Canvas.SetZIndex(marker, m.ZIndex);
                Canvas.SetLeft(marker, p.X);
                Canvas.SetTop(marker, p.Y);

                if (m.Points != null)
                {
                    if (!(marker.RenderTransform is ScaleTransform))
                    {
                        marker.RenderTransform = new ScaleTransform(1.0 / transform.Resolution, 1.0 / transform.Resolution);
                    }
                    else
                    {
                        ((ScaleTransform)marker.RenderTransform).ScaleX = 1.0 / transform.Resolution;
                        ((ScaleTransform)marker.RenderTransform).ScaleY = 1.0 / transform.Resolution;
                    }
                }

                //double factor = 1;
                //if (!(marker.RenderTransform is ScaleTransform))
                //{
                //    marker.RenderTransform = new ScaleTransform(1.0 / transform.Resolution * factor, 1.0 / transform.Resolution * factor);
                //}
                //else
                //{
                //    ((ScaleTransform)marker.RenderTransform).ScaleX = 1.0 / transform.Resolution * factor;
                //    ((ScaleTransform)marker.RenderTransform).ScaleY = 1.0 / transform.Resolution * factor;
                //}


                marker.Visibility = Visibility.Visible;

                //     }
            }
        }