Version 4.7.1: Fixed MapOverlay Foreground and Stroke.

This commit is contained in:
ClemensF 2018-03-29 19:35:52 +02:00
parent 9566c2d708
commit de4ba0765a
13 changed files with 84 additions and 111 deletions

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2018 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("4.7.0")]
[assembly: AssemblyFileVersion("4.7.0")]
[assembly: AssemblyVersion("4.7.1")]
[assembly: AssemblyFileVersion("4.7.1")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2018 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("4.7.0")]
[assembly: AssemblyFileVersion("4.7.0")]
[assembly: AssemblyVersion("4.7.1")]
[assembly: AssemblyFileVersion("4.7.1")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2018 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("4.7.0")]
[assembly: AssemblyFileVersion("4.7.0")]
[assembly: AssemblyVersion("4.7.1")]
[assembly: AssemblyFileVersion("4.7.1")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2018 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("4.7.0")]
[assembly: AssemblyFileVersion("4.7.0")]
[assembly: AssemblyVersion("4.7.1")]
[assembly: AssemblyFileVersion("4.7.1")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2005
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MapControl", "MapControl", "{52AECE49-F314-4F76-98F2-FA800F07824B}"
EndProject

View file

@ -4,9 +4,12 @@
#if WINDOWS_UWP
using Windows.UI.Text;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Media;
#else
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;
#endif
@ -17,6 +20,21 @@ namespace MapControl
/// </summary>
public partial class MapOverlay : MapPanel
{
public MapOverlay()
{
Loaded += (s, e) =>
{
if (Stroke == null)
{
SetBinding(StrokeProperty, new Binding
{
Source = this,
Path = new PropertyPath("Foreground")
});
}
};
}
public double FontSize
{
get { return (double)GetValue(FontSizeProperty); }

View file

@ -43,29 +43,27 @@ namespace MapControl
label.VerticalAlignment = VerticalAlignment.Top;
label.TextAlignment = TextAlignment.Center;
label.SetBinding(TextBlock.ForegroundProperty,
GetBindingExpression(ForegroundProperty)?.ParentBinding ??
new Binding
{
Source = this,
Path = new PropertyPath("Foreground")
});
label.SetBinding(TextBlock.ForegroundProperty, new Binding
{
Source = this,
Path = new PropertyPath("Foreground")
});
line.SetBinding(Shape.StrokeProperty,
GetBindingExpression(StrokeProperty)?.ParentBinding ??
new Binding
{
Source = this,
Path = new PropertyPath("Stroke")
});
line.SetBinding(Shape.StrokeThicknessProperty,
GetBindingExpression(StrokeThicknessProperty)?.ParentBinding ??
new Binding
{
Source = this,
Path = new PropertyPath("StrokeThickness")
});
line.SetBinding(Shape.StrokeProperty, new Binding
{
Source = this,
Path = new PropertyPath("Stroke")
});
line.SetBinding(Shape.StrokeThicknessProperty, new Binding
{
Source = this,
Path = new PropertyPath("StrokeThickness")
});
Children.Add(line);
Children.Add(label);
@ -106,13 +104,15 @@ namespace MapControl
var x2 = size.Width - Padding.Right - StrokeThickness / 2d;
var y1 = size.Height / 2d;
var y2 = size.Height - Padding.Bottom - StrokeThickness / 2d;
var points = new PointCollection();
points.Add(new Point(x1, y1));
points.Add(new Point(x1, y2));
points.Add(new Point(x2, y2));
points.Add(new Point(x2, y1));
line.Points = points;
line.Points = new PointCollection
{
new Point(x1, y1),
new Point(x1, y2),
new Point(x2, y2),
new Point(x2, y1)
};
line.Measure(size);
if (FontFamily != null)

View file

@ -35,21 +35,17 @@ namespace MapControl
Data = new PathGeometry()
};
path.SetBinding(Shape.StrokeProperty,
GetBindingExpression(StrokeProperty)?.ParentBinding ??
new Binding
{
Source = this,
Path = new PropertyPath("Stroke")
});
path.SetBinding(Shape.StrokeProperty, new Binding
{
Source = this,
Path = new PropertyPath("Stroke")
});
path.SetBinding(Shape.StrokeThicknessProperty,
GetBindingExpression(StrokeThicknessProperty)?.ParentBinding ??
new Binding
{
Source = this,
Path = new PropertyPath("StrokeThickness")
});
path.SetBinding(Shape.StrokeThicknessProperty, new Binding
{
Source = this,
Path = new PropertyPath("StrokeThickness")
});
Children.Add(path);
}
@ -135,13 +131,11 @@ namespace MapControl
RenderTransform = renderTransform
};
label.SetBinding(TextBlock.ForegroundProperty,
GetBindingExpression(ForegroundProperty)?.ParentBinding ??
new Binding
{
Source = this,
Path = new PropertyPath("Foreground")
});
label.SetBinding(TextBlock.ForegroundProperty, new Binding
{
Source = this,
Path = new PropertyPath("Foreground")
});
Children.Add(label);
}

View file

@ -58,35 +58,13 @@ namespace MapControl
protected override void SetParentMap(MapBase parentMap)
{
if (GetBindingExpression(ForegroundProperty) != null)
if (parentMap != null && Foreground == null)
{
ClearValue(ForegroundProperty);
}
if (GetBindingExpression(StrokeProperty) != null)
{
ClearValue(StrokeProperty);
}
if (parentMap != null)
{
if (Foreground == null)
SetBinding(ForegroundProperty, new Binding
{
SetBinding(ForegroundProperty, new Binding
{
Source = parentMap,
Path = new PropertyPath("Foreground")
});
}
if (Stroke == null)
{
SetBinding(StrokeProperty, new Binding
{
Source = parentMap,
Path = new PropertyPath("Foreground")
});
}
Source = parentMap,
Path = new PropertyPath("Foreground")
});
}
base.SetParentMap(parentMap);

View file

@ -7,8 +7,8 @@ using System.Runtime.InteropServices;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2018 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("4.7.0")]
[assembly: AssemblyFileVersion("4.7.0")]
[assembly: AssemblyVersion("4.7.1")]
[assembly: AssemblyFileVersion("4.7.1")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]

View file

@ -70,8 +70,12 @@ namespace MapControl
{
Brush = Stroke,
Thickness = StrokeThickness,
DashStyle = new DashStyle(StrokeDashArray, StrokeDashOffset),
DashCap = StrokeDashCap
LineJoin = StrokeLineJoin,
MiterLimit = StrokeMiterLimit,
StartLineCap = StrokeStartLineCap,
EndLineCap = StrokeEndLineCap,
DashCap = StrokeDashCap,
DashStyle = new DashStyle(StrokeDashArray, StrokeDashOffset)
};
for (var lat = latLabelStart; lat <= boundingBox.North; lat += lineDistance)

View file

@ -4,8 +4,6 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Shapes;
namespace MapControl
@ -50,24 +48,5 @@ namespace MapControl
public static readonly DependencyProperty StrokeMiterLimitProperty = Shape.StrokeMiterLimitProperty.AddOwner(
typeof(MapOverlay), new FrameworkPropertyMetadata { AffectsRender = true });
protected override void SetParentMap(MapBase parentMap)
{
if (GetBindingExpression(StrokeProperty) != null)
{
ClearValue(StrokeProperty);
}
if (parentMap != null && Stroke == null)
{
SetBinding(StrokeProperty, new Binding
{
Source = parentMap,
Path = new PropertyPath("Foreground")
});
}
base.SetParentMap(parentMap);
}
}
}

View file

@ -8,8 +8,8 @@ using System.Windows;
[assembly: AssemblyCompany("Clemens Fischer")]
[assembly: AssemblyCopyright("© 2018 Clemens Fischer")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("4.7.0")]
[assembly: AssemblyFileVersion("4.7.0")]
[assembly: AssemblyVersion("4.7.1")]
[assembly: AssemblyFileVersion("4.7.1")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]