public bool AddDataSource(IGraphDataSource graphDataSource) { if (graphDataProviders.Count == MaxDataSources) { // Maximum number of data sources has already been reached return(false); } var provider = new GraphDataProvider { DataSource = graphDataSource, IsGraphed = true }; provider.PenData = graphDataPens.FirstOrDefault(p => !usedPens.Contains(p)); if (!(graphDataSource is IHiddenGraphDataSource)) { this.usedPens.Add(provider.PenData); } this.graphDataProviders.Add(provider); provider.DataChanged += OnProviderDataChanged; var shape = new GraphShape { Stroke = provider.PenData.Brush, StrokeDashCap = PenLineCap.Round, StrokeLineJoin = PenLineJoin.Round }; shape.SetBinding(Shape.StrokeThicknessProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.StrokeThicknessProperty) }); shape.SetBinding(Shape.StrokeDashArrayProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.StrokeDashArrayProperty) }); shape.SetBinding(Shape.FillProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.FillProperty) }); shape.SetBinding(Panel.ZIndexProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.ZIndexProperty) }); this.shapeTable.Add(provider, shape); if (this.canvas != null) { this.canvas.Children.Add(shape); } OnProviderDataChanged(provider, EventArgs.Empty); return(true); }
public void RemoveDataSource(IGraphDataSource graphDataSource) { var provider = this.graphDataProviders.FirstOrDefault(s => s.DataSource == graphDataSource); if (provider == null) { return; } provider.DataChanged -= OnProviderDataChanged; this.graphDataProviders.Remove(provider); this.usedPens.Remove(provider.PenData); // If we still have providers, recompute the Y axis range, scanning all sources, since the range // may now be way too big. // If there are now no providers, just leave the Y axis alone. if (graphDataProviders.Count > 0 && !this.SideBar.YAxisChangedByUser) { RecomputeYAxisRange(); } if (this.graphGrid != null) { this.graphGrid.InvalidateVisual(); } if (this.canvas != null) { this.canvas.Children.Remove(this.shapeTable[provider]); } this.shapeTable.Remove(provider); if (this.graphDataProviders.Count == 0) { this.timeEnd = MinimumGraphTime; this.timeStart = 0; this.DataRangeStop = 0; RaiseTimeRangeChanged(); } }
/// <summary> /// Stores a binding between a render data source and a render data target /// </summary> public Binding( IGraphDataSource source, IGraphDataTarget target ) { m_Source = source; m_Target = target; }
/// <summary> /// Binds a source to a target /// </summary> /// <param name="source">Data source</param> /// <param name="target">Target to bind to. Must belong to this node</param> public void Bind( IGraphDataSource source, IGraphDataTarget target ) { Arguments.CheckNotNull( source, "source" ); Arguments.CheckNotNull( target, "target" ); m_Bindings.Add( new Binding( source, target ) ); }
/// <summary> /// Removes a data source /// </summary> /// <param name="source">Data source</param> public void Remove( IGraphDataSource source ) { Arguments.CheckNotNull( source, "source" ); m_Sources.Remove( source.Name ); }
/// <summary> /// Adds a new data source /// </summary> /// <param name="source">Data source</param> public void Add( IGraphDataSource source ) { Arguments.CheckNotNull( source, "source" ); m_Sources.Add( source.Name, source ); }
public void RemoveDataSource(IGraphDataSource graphDataSource) { var provider = this.graphDataProviders.FirstOrDefault(s => s.DataSource == graphDataSource); if (provider == null) return; provider.DataChanged -= OnProviderDataChanged; this.graphDataProviders.Remove(provider); this.usedPens.Remove(provider.PenData); // If we still have providers, recompute the Y axis range, scanning all sources, since the range // may now be way too big. // If there are now no providers, just leave the Y axis alone. if (graphDataProviders.Count > 0 && !this.SideBar.YAxisChangedByUser) { RecomputeYAxisRange(); } if (this.graphGrid != null) { this.graphGrid.InvalidateVisual(); } if (this.canvas != null) { this.canvas.Children.Remove(this.shapeTable[provider]); } this.shapeTable.Remove(provider); if (this.graphDataProviders.Count == 0) { this.timeEnd = MinimumGraphTime; this.timeStart = 0; this.DataRangeStop = 0; RaiseTimeRangeChanged(); } }
public bool AddDataSource(IGraphDataSource graphDataSource) { if (graphDataProviders.Count == MaxDataSources) { // Maximum number of data sources has already been reached return false; } var provider = new GraphDataProvider { DataSource = graphDataSource, IsGraphed = true }; provider.PenData = graphDataPens.FirstOrDefault(p => !usedPens.Contains(p)); if (!(graphDataSource is IHiddenGraphDataSource)) { this.usedPens.Add(provider.PenData); } this.graphDataProviders.Add(provider); provider.DataChanged += OnProviderDataChanged; var shape = new GraphShape { Stroke = provider.PenData.Brush, StrokeDashCap = PenLineCap.Round, StrokeLineJoin = PenLineJoin.Round }; shape.SetBinding(Shape.StrokeThicknessProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.StrokeThicknessProperty) }); shape.SetBinding(Shape.StrokeDashArrayProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.StrokeDashArrayProperty) }); shape.SetBinding(Shape.FillProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.FillProperty) }); shape.SetBinding(Panel.ZIndexProperty, new Binding { Source = provider, Path = new PropertyPath(GraphDataProvider.ZIndexProperty) }); this.shapeTable.Add(provider, shape); if (this.canvas != null) { this.canvas.Children.Add(shape); } OnProviderDataChanged(provider, EventArgs.Empty); return true; }