Example #1
0
 public LayersContainer()
 {
     _map                = null;
     _boundaries         = null;
     _layers             = null;
     _childrenDictionary = new Dictionary <ILayer, UIElement>();
     _currentTransform   = Transform.Identity;
     _currentTransform.Freeze();
     _cumulativeTransform = new MatrixTransform(Matrix.Identity);
     this.Background      = Brushes.Transparent;// Needed to get the mouse events
 }
Example #2
0
        public virtual bool IsInMap(LatLonBoundaries rectangle)
        {
            LatLonBoundaries mapBoundaries = this.Map.Boundaries;

            if (this.Map.RotateReference)
            {
                var rectangleCenter = mapBoundaries.Center.GetNewCoordinates(rectangle.Center);
                rectangle     = new LatLonBoundaries(rectangleCenter.Latitude, rectangleCenter.Longitude, rectangle.LatitudeSpan, rectangle.LongitudeSpan);
                mapBoundaries = new LatLonBoundaries(0, 0, mapBoundaries.LatitudeSpan, mapBoundaries.LongitudeSpan);
            }
            return(rectangle.Intersects(mapBoundaries));
        }
Example #3
0
 protected virtual void updateCache()
 {
     if (this.MapBoundaries != _cacheBoundaries || this.MapSize != _cacheSize)
     {
         // Warning: This is not thread-safe!
         _cacheBoundaries = this.MapBoundaries;
         _cacheSize       = this.MapSize;
         _cacheYMin       = latitudeToY(_cacheBoundaries.BottomLatitude);
         _cacheYMax       = latitudeToY(_cacheBoundaries.TopLatitude);
         _cacheYFactor    = _cacheSize.Height / _cacheBoundaries.LatitudeSpan;
         _cacheR          = this.R / _cacheBoundaries.LongitudeSpan;
     }
 }
Example #4
0
 public virtual bool IsInMap(LatLonBoundaries rectangle)
 {
     return(rectangle.Intersects(this.Map.Boundaries));
 }
Example #5
0
        protected override void OnInitialized(EventArgs e)
        {
            base.OnInitialized(e);

            PropertyChangedEventHandler boudariesChanged = delegate(object s3, PropertyChangedEventArgs e3)
            {
                RedrawType redrawType;
                if (_boundaries != null)
                {
                    redrawType = _previousBoundaries != null && _previousBoundaries.Contains(_boundaries)
                       ? RedrawType.ZoomIn
                       : RedrawType.ZoomOut;
                }
                else
                {
                    redrawType = RedrawType.Reset;
                }
                _previousBoundaries = new LatLonBoundaries(_boundaries);
                draw(redrawType);
            };
            PropertyChangedEventHandler mapPropertyChanged = delegate(object s2, PropertyChangedEventArgs e2)
            {
                switch (e2.PropertyName)
                {
                case nameof(IMap.Layers):
                    if (_layers != null)
                    {
                        _layers.CollectionChanged -= onLayersChanged;
                    }
                    _layers = Current.Map?.Layers;
                    if (_layers != null)
                    {
                        _layers.CollectionChanged += onLayersChanged;
                    }
                    onLayersChanged(this, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));
                    break;

                case nameof(IMap.Boundaries):
                    if (_boundaries != null)
                    {
                        _boundaries.PropertyChanged -= boudariesChanged;
                    }
                    _boundaries = Current.Map?.Boundaries;
                    if (_layers != null)
                    {
                        _boundaries.PropertyChanged += boudariesChanged;
                    }
                    boudariesChanged(this, null);
                    break;
                }
            };

            _map = this.DataContext as IMap;
            if (_map != null)
            {
                _map.Container        = this;
                _map.PropertyChanged += mapPropertyChanged;
            }
            mapPropertyChanged(this, new PropertyChangedEventArgs(nameof(IMap.Layers)));
            mapPropertyChanged(this, new PropertyChangedEventArgs(nameof(IMap.Boundaries)));

            Current.AnimationStepChanged += delegate(CurrentPropertyChangedEventArgs <long> asc)
            {
                if (Current.Map == _map)
                {
                    draw(RedrawType.AnimationStepChanged);
                }
            };
            Current.DisplayTypeChanged += delegate(CurrentPropertyChangedEventArgs <DisplayType> asc)
            {
                if (Current.Map == _map)
                {
                    draw(RedrawType.DisplayTypeChanged);
                }
            };
        }