public override void ApplyFluidTheme(IDataFluidTheme theme) { if (LayerData.GeoType == VectorLayer.GEOTYPE_LINEAR) { foreach (var featurePair in Features) { var feature = featurePair.Key; var geometry = featurePair.Value.Geometry as PathGeometry; var poly = new Geometry.PointString(feature.GeoData); double length = poly.Length(); if (length < 10) { continue; } double velocity = theme.GetVelocity(feature); double time = length / velocity; double space = 1 / theme.GetDensity(feature); int spotCount = (int)(length / space) + 1; var color = theme.GetColor(feature); for (int i = 0; i < spotCount; i++) { var pointAnimation = new PointAnimationUsingPath { PathGeometry = geometry, Duration = new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000))), RepeatBehavior = RepeatBehavior.Forever, BeginTime = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000)) }; var colorAnimation = new ColorAnimation( fromValue: color.Item1, toValue: color.Item2, duration: new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000)))) { RepeatBehavior = RepeatBehavior.Forever, BeginTime = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000)) }; double radius = theme.GetDiameter(feature) / 2; var fill = new SolidColorBrush(color.Item1); var spot = new EllipseGeometry(new Point(), radius, radius); var spotDrawing = new GeometryDrawing(fill, null, spot); this.AddOverlayChildren(spotDrawing); spot.BeginAnimation(EllipseGeometry.CenterProperty, pointAnimation); fill.BeginAnimation(SolidColorBrush.ColorProperty, colorAnimation); } } } }
public override void ApplyFluidTheme(IDataFluidTheme theme) { if (LayerData.GeoType == "2") { foreach (var feature in Features) { var f = feature.Key; var geometry = feature.Value.Geometry as PathGeometry; var poly = new Geometry.Polyline(f.GeoData); double length = poly.Length; if (length < 10) { continue; } double velocity = theme.GetVelocity(f); double time = length / velocity; double space = 1 / theme.GetDensity(f); int spotCount = (int)(length / space) + 1; var color = theme.GetColor(f); for (int i = 0; i < spotCount; i++) { PointAnimationUsingPath paup = new PointAnimationUsingPath(); paup.PathGeometry = geometry; paup.Duration = new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000))); paup.RepeatBehavior = RepeatBehavior.Forever; paup.BeginTime = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000)); ColorAnimation ca = new ColorAnimation(color.Item1, color.Item2, new Duration(new TimeSpan(0, 0, 0, 0, (int)(time * 1000)))); ca.RepeatBehavior = RepeatBehavior.Forever; ca.BeginTime = new TimeSpan(0, 0, 0, 0, (int)(time / spotCount * i * 1000)); double radius = theme.GetDiameter(f) / 2; var fill = new SolidColorBrush(color.Item1); EllipseGeometry spot = new EllipseGeometry(new Point(), radius, radius); GeometryDrawing spotDrawing = new GeometryDrawing(fill, null, spot); this.AddOverlayChildren(spotDrawing); spot.BeginAnimation(EllipseGeometry.CenterProperty, paup); fill.BeginAnimation(SolidColorBrush.ColorProperty, ca); } } } }