using System.Windows; using System.Windows.Media; using Microsoft.Research.DynamicDataDisplay.DataSources; using Microsoft.Research.DynamicDataDisplay.PointMarkers; namespace Microsoft.Research.DynamicDataDisplay { public class MarkerPointsGraph : PointsGraphBase { /// /// Initializes a new instance of the class. /// public MarkerPointsGraph() { } /// /// Initializes a new instance of the class. /// /// The data source. public MarkerPointsGraph(IPointDataSource dataSource) { DataSource = dataSource; } public PointMarker Marker { get { return (PointMarker)GetValue(MarkerProperty); } set { SetValue(MarkerProperty, value); } } public static readonly DependencyProperty MarkerProperty = DependencyProperty.Register( "Marker", typeof(PointMarker), typeof(MarkerPointsGraph), new FrameworkPropertyMetadata { DefaultValue = null, AffectsRender = true } ); protected override void OnRenderCore(DrawingContext dc, RenderState state) { if (DataSource == null) return; if (Marker == null) return; Rect bounds = Rect.Empty; using (IPointEnumerator enumerator = DataSource.GetEnumerator(GetContext())) { Point point = new Point(); while (enumerator.MoveNext()) { enumerator.GetCurrent(ref point); enumerator.ApplyMappings(Marker); Point screenPoint = point.Transform(state.Visible, state.Output); bounds = Rect.Union(bounds, point); Marker.Render(dc, screenPoint); } } ContentBounds = bounds; } } }