using RealTimeGraphX.EventArguments; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; namespace RealTimeGraphX { /// /// Represents an base class. /// /// /// public class GraphSurfaceComponentBase : Control, IGraphSurfaceComponent { /// /// Gets or sets the surface. /// public IGraphSurface Surface { get { return (IGraphSurface)GetValue(SurfaceProperty); } set { SetValue(SurfaceProperty, value); } } public static readonly DependencyProperty SurfaceProperty = DependencyProperty.Register("Surface", typeof(IGraphSurface), typeof(GraphSurfaceComponentBase), new PropertyMetadata(null, (d, e) => (d as GraphSurfaceComponentBase).OnSurfaceChanged())); /// /// Called when the property has been changed. /// protected virtual void OnSurfaceChanged() { if (!this.IsInDesignMode() && Surface != null) { Surface.InputChanged -= Surface_InputChanged; Surface.InputChanged += Surface_InputChanged; if (Surface.Input != null) { OnSurfacePainterChanged(Surface.Input); } } } /// /// Handles the InputChanged event of the Surface. /// /// The source of the event. /// The instance containing the event data. private void Surface_InputChanged(object sender, InputChangedEventArgs e) { OnSurfacePainterChanged(e.Input); } /// /// Called when surface painter has changed. /// /// The painter. protected virtual void OnSurfacePainterChanged(IGraphPainter painter) { //Do Nothing.. } /// /// Invokes the specified method on the component dispatcher. /// /// The action. protected void InvokeUI(Action action) { Dispatcher.BeginInvoke(action); } } }