mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-04-04 22:18:56 +00:00
Use C# 7
This commit is contained in:
parent
3ffb613f80
commit
310f0cca9a
21 changed files with 51 additions and 86 deletions
|
|
@ -16,16 +16,9 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public abstract class AzimuthalProjection : MapProjection
|
||||
{
|
||||
public override bool IsNormalCylindrical
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public override Rect BoundingBoxToRect(BoundingBox boundingBox)
|
||||
{
|
||||
var cbbox = boundingBox as CenteredBoundingBox;
|
||||
|
||||
if (cbbox != null)
|
||||
if (boundingBox is CenteredBoundingBox cbbox)
|
||||
{
|
||||
var center = LocationToMap(cbbox.Center);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ namespace MapControl
|
|||
CrsId = "EPSG:4326";
|
||||
}
|
||||
|
||||
public override bool IsNormalCylindrical
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override Vector GetRelativeScale(Location location)
|
||||
{
|
||||
return new Vector(
|
||||
|
|
|
|||
|
|
@ -388,8 +388,7 @@ namespace MapControl
|
|||
{
|
||||
Children.Remove(oldLayer);
|
||||
|
||||
var mapLayer = oldLayer as IMapLayer;
|
||||
if (mapLayer != null)
|
||||
if (oldLayer is IMapLayer mapLayer)
|
||||
{
|
||||
if (mapLayer.MapBackground != null)
|
||||
{
|
||||
|
|
@ -406,8 +405,7 @@ namespace MapControl
|
|||
{
|
||||
Children.Insert(0, newLayer);
|
||||
|
||||
var mapLayer = newLayer as IMapLayer;
|
||||
if (mapLayer != null)
|
||||
if (newLayer is IMapLayer mapLayer)
|
||||
{
|
||||
if (mapLayer.MapBackground != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -228,9 +228,7 @@ namespace MapControl
|
|||
element.Height = rect.Height;
|
||||
element.Arrange(rect);
|
||||
|
||||
var rotateTransform = element.RenderTransform as RotateTransform;
|
||||
|
||||
if (rotateTransform != null)
|
||||
if (element.RenderTransform is RotateTransform rotateTransform)
|
||||
{
|
||||
rotateTransform.Angle = parentMap.ViewTransform.Rotation;
|
||||
}
|
||||
|
|
@ -293,9 +291,7 @@ namespace MapControl
|
|||
|
||||
private static void ParentMapPropertyChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var mapElement = obj as IMapElement;
|
||||
|
||||
if (mapElement != null)
|
||||
if (obj is IMapElement mapElement)
|
||||
{
|
||||
mapElement.ParentMap = e.NewValue as MapBase;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace MapControl
|
|||
/// </summary>
|
||||
public virtual bool IsNormalCylindrical
|
||||
{
|
||||
get { return true; }
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ namespace MapControl
|
|||
|
||||
protected override void InsertItem(int index, IEnumerable<Location> polygon)
|
||||
{
|
||||
var observablePolygon = polygon as INotifyCollectionChanged;
|
||||
|
||||
if (observablePolygon != null)
|
||||
if (polygon is INotifyCollectionChanged observablePolygon)
|
||||
{
|
||||
CollectionChangedEventManager.AddListener(observablePolygon, this);
|
||||
}
|
||||
|
|
@ -38,9 +36,7 @@ namespace MapControl
|
|||
|
||||
protected override void SetItem(int index, IEnumerable<Location> polygon)
|
||||
{
|
||||
var observablePolygon = this[index] as INotifyCollectionChanged;
|
||||
|
||||
if (observablePolygon != null)
|
||||
if (this[index] is INotifyCollectionChanged observablePolygon)
|
||||
{
|
||||
CollectionChangedEventManager.RemoveListener(observablePolygon, this);
|
||||
}
|
||||
|
|
@ -50,9 +46,7 @@ namespace MapControl
|
|||
|
||||
protected override void RemoveItem(int index)
|
||||
{
|
||||
var observablePolygon = this[index] as INotifyCollectionChanged;
|
||||
|
||||
if (observablePolygon != null)
|
||||
if (this[index] is INotifyCollectionChanged observablePolygon)
|
||||
{
|
||||
CollectionChangedEventManager.RemoveListener(observablePolygon, this);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@ namespace MapControl
|
|||
CrsId = "EPSG:3857";
|
||||
}
|
||||
|
||||
public override bool IsNormalCylindrical
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override bool IsWebMercator
|
||||
{
|
||||
get { return true; }
|
||||
|
|
|
|||
|
|
@ -25,6 +25,11 @@ namespace MapControl
|
|||
CrsId = "EPSG:3395";
|
||||
}
|
||||
|
||||
public override bool IsNormalCylindrical
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override double MaxLatitude
|
||||
{
|
||||
get { return maxLatitude; }
|
||||
|
|
|
|||
|
|
@ -17,12 +17,7 @@ namespace MapControl.Caching
|
|||
|
||||
public ImageFileCache(StorageFolder folder)
|
||||
{
|
||||
if (folder == null)
|
||||
{
|
||||
throw new ArgumentNullException("The parameter rootFolder must not be null.");
|
||||
}
|
||||
|
||||
this.folder = folder;
|
||||
this.folder = folder ?? throw new ArgumentNullException("The parameter rootFolder must not be null.");
|
||||
|
||||
Debug.WriteLine("Created ImageFileCache in " + folder.Path);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,12 +53,9 @@ namespace MapControl
|
|||
|
||||
private static MapBase FindParentMap(FrameworkElement element)
|
||||
{
|
||||
var parent = VisualTreeHelper.GetParent(element) as FrameworkElement;
|
||||
|
||||
return parent == null ? null
|
||||
: ((parent as MapBase)
|
||||
?? (MapBase)element.GetValue(ParentMapProperty)
|
||||
?? FindParentMap(parent));
|
||||
return VisualTreeHelper.GetParent(element) is FrameworkElement parent
|
||||
? ((parent as MapBase) ?? (MapBase)element.GetValue(ParentMapProperty) ?? FindParentMap(parent))
|
||||
: null;
|
||||
}
|
||||
|
||||
private static void SetViewPosition(FrameworkElement element, Point? viewPosition)
|
||||
|
|
|
|||
|
|
@ -21,16 +21,14 @@ namespace MapControl
|
|||
|
||||
protected void DataCollectionPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
INotifyCollectionChanged collection;
|
||||
|
||||
if ((collection = e.OldValue as INotifyCollectionChanged) != null)
|
||||
if (e.OldValue is INotifyCollectionChanged oldCollection)
|
||||
{
|
||||
collection.CollectionChanged -= DataCollectionChanged;
|
||||
oldCollection.CollectionChanged -= DataCollectionChanged;
|
||||
}
|
||||
|
||||
if ((collection = e.NewValue as INotifyCollectionChanged) != null)
|
||||
if (e.NewValue is INotifyCollectionChanged newCollection)
|
||||
{
|
||||
collection.CollectionChanged += DataCollectionChanged;
|
||||
newCollection.CollectionChanged += DataCollectionChanged;
|
||||
}
|
||||
|
||||
UpdateData();
|
||||
|
|
|
|||
|
|
@ -18,9 +18,7 @@ namespace MapControl
|
|||
|
||||
if (fadeIn && FadeDuration > TimeSpan.Zero)
|
||||
{
|
||||
var bitmap = image as BitmapImage;
|
||||
|
||||
if (bitmap?.UriSource != null)
|
||||
if (image is BitmapImage bitmap && bitmap.UriSource != null)
|
||||
{
|
||||
bitmap.ImageOpened += BitmapImageOpened;
|
||||
bitmap.ImageFailed += BitmapImageFailed;
|
||||
|
|
|
|||
|
|
@ -160,9 +160,8 @@ namespace MapControl.Caching
|
|||
throw new ArgumentNullException("The parameter key must not be null.");
|
||||
}
|
||||
|
||||
var imageCacheItem = value as ImageCacheItem;
|
||||
|
||||
if (imageCacheItem == null)
|
||||
if (!(value is ImageCacheItem imageCacheItem))
|
||||
{
|
||||
throw new ArgumentException("The parameter value must be a MapControl.Caching.ImageCacheItem instance.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,16 +35,14 @@ namespace MapControl
|
|||
|
||||
protected void DataCollectionPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
INotifyCollectionChanged collection;
|
||||
|
||||
if ((collection = e.OldValue as INotifyCollectionChanged) != null)
|
||||
if (e.OldValue is INotifyCollectionChanged oldCollection)
|
||||
{
|
||||
CollectionChangedEventManager.RemoveListener(collection, this);
|
||||
CollectionChangedEventManager.RemoveListener(oldCollection, this);
|
||||
}
|
||||
|
||||
if ((collection = e.NewValue as INotifyCollectionChanged) != null)
|
||||
if (e.NewValue is INotifyCollectionChanged newCollection)
|
||||
{
|
||||
CollectionChangedEventManager.AddListener(collection, this);
|
||||
CollectionChangedEventManager.AddListener(newCollection, this);
|
||||
}
|
||||
|
||||
UpdateData();
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ namespace MapControl
|
|||
|
||||
if (fadeIn && FadeDuration > TimeSpan.Zero)
|
||||
{
|
||||
var bitmap = image as BitmapSource;
|
||||
|
||||
if (bitmap != null && !bitmap.IsFrozen && bitmap.IsDownloading)
|
||||
if (image is BitmapSource bitmap && !bitmap.IsFrozen && bitmap.IsDownloading)
|
||||
{
|
||||
bitmap.DownloadCompleted += BitmapDownloadCompleted;
|
||||
bitmap.DownloadFailed += BitmapDownloadFailed;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue