This commit is contained in:
ClemensF 2020-04-16 23:15:03 +02:00
parent 3ffb613f80
commit 310f0cca9a
21 changed files with 51 additions and 86 deletions

View file

@ -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);
}

View file

@ -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)

View file

@ -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();

View file

@ -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;