Esempio n. 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);
         }
         else if (element is System.Windows.Shapes.Line)
         {
             System.Windows.Shapes.Line line = element as System.Windows.Shapes.Line;
             canvas.Children.Remove(line);
         }
         else if (element is System.Windows.Shapes.Ellipse)
         {
             System.Windows.Shapes.Ellipse ellipse = element as System.Windows.Shapes.Ellipse;
             canvas.Children.Remove(ellipse);
         }
         else if (element is MarkerControl2)
         {
             MarkerControl2 marker = element as MarkerControl2;
             canvas.Children.Remove(marker);
         }
     }
 }
        static void OnPointsChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            MarkerControl2  c = (MarkerControl2)sender;
            PointCollection p = e.NewValue as PointCollection;

            if (p != null)
            {
                c.poly.BeginInit();
                c.poly.Points = p;
                c.poly.EndInit();
            }
        }
Esempio n. 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;

                //     }
            }
        }
Esempio n. 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;
                }
            }
        }