Exemple #1
0
 public static void RemoveMarkers(Canvas canvas)
 {
     for (int i = canvas.Children.Count - 1; i >= 0; i--)
     {
         UIElement element = canvas.Children[i];
         if (element is MarkerControl)
         {
             MarkerControl marker = element as MarkerControl;
             canvas.Children.Remove(marker);
         }
     }
 }
        static void OnImageChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            MarkerControl c = (MarkerControl)source;
            ImageSource   s = e.NewValue as ImageSource;

            c.image.Source = s;

            double left = -s.Width / 2.0;
            double top  = -s.Height;

            c.canvas.Margin = new Thickness(left, top, left, top);
        }
Exemple #3
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;

                //     }
            }
        }
Exemple #4
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 = 4;
                    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;
                }
            }
        }