public OrbitIcon(IMapIcon mapIcon, MapTab mapTab)
        {
            this.mapIcon = mapIcon;
            this.mapTab = mapTab;
            InitializeComponent();
            ParentIcon = mapIcon.ParentIcon;

            maxOrbitRadius = mapIcon.Body.Children.Max(c => c.OrbitDistance)*MapTab.MapScale;

            foreach (var child in mapIcon.Body.Children) {
                var orbitRadius = child.OrbitDistance;
                var ellipse = new Ellipse();
                ellipse.Stroke = new SolidColorBrush(Colors.White);
                ellipse.StrokeThickness = strokeSize/mapTab.ZoomControl.Zoom;
                Canvas.SetLeft(ellipse, maxOrbitRadius - child.OrbitDistance*MapTab.MapScale);
                Canvas.SetTop(ellipse, maxOrbitRadius - child.OrbitDistance*MapTab.MapScale);
                ellipse.Width = orbitRadius*2*MapTab.MapScale;
                ellipse.Height = orbitRadius*2*MapTab.MapScale;
                LayoutRoot.Children.Add(ellipse);
            }

            Canvas.SetZIndex(this, -1);

            if (mapIcon.Body.OrbitNestingLevel == 0) {
                // orbit doesn't move, just set the position once
                Canvas.SetLeft(this, mapIcon.X - maxOrbitRadius);
                Canvas.SetTop(this, mapIcon.Y - maxOrbitRadius);
            }

            Update();
        }
 public TransitIcon(Transit transit, MapTab mapTab)
 {
     this.transit = transit;
     this.mapTab = mapTab;
     InitializeComponent();
     Arrow.Width = 20; //todo: optimization: make the path already have the right size
     Arrow.Height = 20;
     Canvas.SetZIndex(this, 1000);
     Canvas.SetZIndex(PlottedRouteLine, -2);
     Canvas.SetZIndex(PlaceOrderLine, -1);
     DataContext = transit;
 }
        public StarIcon(CelestialObject star, MapTab mapTab)
        {
            this.mapTab = mapTab;
            if (star.CelestialObjectType != CelestialObjectType.Star) throw new Exception("body not star");

            InitializeComponent();
            Body = star;
            Label.Text = star.Name;
            Canvas.SetZIndex(this, 30);
            X = Body.X*MapTab.MapScale;
            Y = Body.Y*MapTab.MapScale;
            Ellipse.Fill = Body.Brush;
            Ellipse.Width = Body.Size;
            Ellipse.Height = Body.Size;
            Update();
        }
        public LinkIcon(CelestialObject starA, CelestialObject starB, MapTab mapTab)
        {
            this.mapTab = mapTab;
            InitializeComponent();

            var left = Math.Min(starA.X, starB.X)*MapTab.MapScale;
            var top = Math.Min(starB.Y, starA.Y)*MapTab.MapScale;

            Line.X1 = starA.X*MapTab.MapScale - left;
            Line.Y1 = starA.Y*MapTab.MapScale - top;
            Line.X2 = starB.X*MapTab.MapScale - left;
            Line.Y2 = starB.Y*MapTab.MapScale - top;

            Canvas.SetLeft(this, left);
            Canvas.SetTop(this, top);
            Canvas.SetZIndex(this, -10);

            Update();
        }