Index: Core/Common/src/Core.Common.Controls.Swf/Charting/Chart.cs =================================================================== diff -u -r79d36eef280b0a5cbb64ab4b20df234dece1df4a -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Common/src/Core.Common.Controls.Swf/Charting/Chart.cs (.../Chart.cs) (revision 79d36eef280b0a5cbb64ab4b20df234dece1df4a) +++ Core/Common/src/Core.Common.Controls.Swf/Charting/Chart.cs (.../Chart.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using System.IO; @@ -7,7 +8,6 @@ using Core.Common.Controls.Swf.Charting.Series; using Core.Common.Controls.Swf.Properties; using Core.Common.Utils.Collections; -using Core.Common.Utils.Collections.Generic; using log4net; using Steema.TeeChart.Drawing; using Steema.TeeChart.Export; @@ -24,14 +24,14 @@ internal readonly Steema.TeeChart.Chart chart; private readonly ILog log = LogManager.GetLogger(typeof(Chart)); - private IEventedList series; + private readonly List seriesList; private bool chartSeriesStacked; private ChartGraphics graphics; public Chart() { chart = new Steema.TeeChart.Chart(); - Series = new EventedList(); + seriesList = new List(); SetDefaultValues(); } @@ -121,26 +121,12 @@ } } - public IEventedList Series + public IEnumerable Series { get { - return series; + return seriesList.AsReadOnly(); } - set - { - if (series != null) - { - series.CollectionChanged -= SeriesCollectionChanged; - } - - series = value; - - if (series != null) - { - series.CollectionChanged += SeriesCollectionChanged; - } - } } public IChartAxis LeftAxis @@ -209,6 +195,54 @@ public bool AllowSeriesTypeChange { get; set; } + public int GetIndexOfChartSeries(ChartSeries series) + { + return seriesList.IndexOf(series); + } + + public void AddChartSeries(ChartSeries series) + { + if (!seriesList.Contains(series)) + { + series.Chart = this; + seriesList.Add(series); + chart.Series.Add(series.series); + } + } + + public void InsertChartSeries(ChartSeries series, int index) + { + if (seriesList.Contains(series)) + { + chart.Series.MoveTo(series.series, index); + } + else + { + series.Chart = this; + seriesList.Insert(index, series); + chart.Series.Add(series.series); + chart.Series.MoveTo(series.series, index); + } + } + + public bool RemoveChartSeries(ChartSeries series) + { + if (seriesList.Remove(series)) + { + chart.Series.Remove(series.series); + return true; + } + return false; + } + + public void RemoveAllChartSeries() + { + foreach (var series in seriesList.ToArray()) + { + RemoveChartSeries(series); + } + } + public void ExportAsImage(IWin32Window owner) { var dialog = new SaveFileDialog @@ -247,8 +281,8 @@ if (ext == ".svg") { - var hatchStyleIgnored = Series.OfType().Any(cs => cs.UseHatch) || - Series.OfType().Any(cs => cs.UseHatch); + var hatchStyleIgnored = seriesList.OfType().Any(cs => cs.UseHatch) || + seriesList.OfType().Any(cs => cs.UseHatch); if (hatchStyleIgnored) { log.WarnFormat(Resources.Chart_ExportAsImage_Hatch_style_is_not_supported_for_exports_and_will_be_ignored_); Index: Core/Common/src/Core.Common.Controls.Swf/Charting/ChartView.cs =================================================================== diff -u -r79d36eef280b0a5cbb64ab4b20df234dece1df4a -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Common/src/Core.Common.Controls.Swf/Charting/ChartView.cs (.../ChartView.cs) (revision 79d36eef280b0a5cbb64ab4b20df234dece1df4a) +++ Core/Common/src/Core.Common.Controls.Swf/Charting/ChartView.cs (.../ChartView.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -1,14 +1,16 @@ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Linq; using System.Windows.Forms; + using Core.Common.Controls.Swf.Charting.Customized; using Core.Common.Controls.Swf.Charting.Tools; using Core.Common.Controls.Swf.Properties; -using Core.Common.Utils; using Core.Common.Utils.Collections; using Core.Common.Utils.Collections.Generic; + using Steema.TeeChart; using Steema.TeeChart.Drawing; using Steema.TeeChart.Tools; @@ -34,6 +36,7 @@ public event EventHandler ToolsActiveChanged; private const int DisabledBackgroundAlpha = 20; + private readonly ICollection tools; private int selectedPointIndex = -1; private bool wheelZoom = true; private bool afterResize = true; @@ -52,10 +55,8 @@ InitializeComponent(); Chart = new Chart(); - Tools = new EventedList(); + tools = new HashSet(); - Tools.CollectionChanged += ToolsCollectionChanged; - teeChart.Zoomed += TeeChartZoomed; teeChart.UndoneZoom += TeeChartUndoneZoom; teeChart.Scroll += TeeChartScroll; @@ -81,20 +82,20 @@ teeChart.Legend.Alignment = LegendAlignments.Bottom; teeChart.Chart.Header.Color = Color.Black; // To avoid blue titles everywhere - Tools.Add(new ExportChartAsImageChartTool(this) + AddTool(new ExportChartAsImageChartTool { Active = true, Enabled = true }); } - public IWin32Window Owner { get; set; } - public bool IsMouseDown { get; private set; } [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public TimeNavigatableLabelFormatProvider DateTimeLabelFormatProvider { get; set; } + public IWin32Window Owner { get; set; } + [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public IChart Chart @@ -118,7 +119,7 @@ chart = value; - teeChart.Chart = ((Chart) chart).chart; + teeChart.Chart = ((Chart)chart).chart; if (zoomUsingMouseWheelTool != null) { @@ -164,7 +165,7 @@ series.DataSource = null; } CleanAnnotations(); - Chart.Series.Clear(); + Chart.RemoveAllChartSeries(); } else { @@ -223,7 +224,13 @@ [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public IEventedList Tools { get; private set; } + public IEnumerable Tools + { + get + { + return tools; + } + } /// /// Set and get the selected Point Index (of the active series) @@ -277,7 +284,7 @@ public IChartViewTool GetTool() { - return Tools.FirstOrDefault(t => t is T); + return tools.FirstOrDefault(t => t is T); } /// @@ -290,7 +297,7 @@ public void EnableDelete(bool enable) { - foreach (var selectTool in Tools.OfType()) + foreach (var selectTool in tools.OfType()) { selectTool.HandleDelete = enable; } @@ -318,6 +325,14 @@ } } + private void AddTool(IChartViewTool tool) + { + tool.ChartView = this; + tools.Add(tool); + + tool.ActiveChanged += OnToolsActiveChanged; + } + private void TeeChartMouseDown(object sender, MouseEventArgs e) { IsMouseDown = true; @@ -335,7 +350,7 @@ var axis = teeChart.Axes[i]; if (axis.Tag is Annotation) { - var annotation = (Annotation) axis.Tag; + var annotation = (Annotation)axis.Tag; teeChart.Tools.Remove(annotation); axis.Tag = null; } @@ -552,7 +567,7 @@ var contextMenu = new ContextMenuStrip(); if (e.Button == MouseButtons.Right) { - foreach (IChartViewContextMenuTool tool in Tools.Where(tool => tool is IChartViewContextMenuTool && tool.Active)) + foreach (IChartViewContextMenuTool tool in tools.OfType().Where(tool => tool.Active)) { tool.OnBeforeContextMenu(contextMenu); } @@ -563,33 +578,6 @@ IsMouseDown = false; } - private void ToolsCollectionChanged(object sender, NotifyCollectionChangingEventArgs e) - { - var chartTool = e.Item as IChartViewTool; - if (e.Action == NotifyCollectionChangeAction.Remove) - { - var tool = e.Item as Tool; - var index = teeChart.Tools.IndexOf(tool); - - if (index >= 0) - { - teeChart.Tools.Remove(tool); - } - - if (chartTool != null) - { - chartTool.ActiveChanged -= OnToolsActiveChanged; - } - } - if (e.Action == NotifyCollectionChangeAction.Add) - { - if (chartTool != null) - { - chartTool.ActiveChanged += OnToolsActiveChanged; - } - } - } - private void OnToolsActiveChanged(object sender, EventArgs e) { if (ToolsActiveChanged != null) @@ -648,41 +636,29 @@ public EditPointTool NewEditPointTool() { - var tool = new EditPointTool(teeChart) - { - ChartView = this - }; - Tools.Add(tool); + var tool = new EditPointTool(teeChart); + AddTool(tool); return tool; } public IAddPointTool NewAddPointTool() { - var tool = new AddPointTool(teeChart.Chart) - { - ChartView = this - }; - Tools.Add(tool); + var tool = new AddPointTool(teeChart.Chart); + AddTool(tool); return tool; } public RulerTool NewRulerTool() { - var tool = new RulerTool(teeChart) - { - ChartView = this - }; - Tools.Add(tool); + var tool = new RulerTool(teeChart); + AddTool(tool); return tool; } public SelectPointTool NewSelectPointTool() { - var tool = new SelectPointTool(teeChart.Chart) - { - ChartView = this - }; - Tools.Add(tool); + var tool = new SelectPointTool(teeChart.Chart); + AddTool(tool); tool.SelectionChanged += ToolSelectionChanged; return tool; } Index: Core/Common/src/Core.Common.Controls.Swf/Charting/IChart.cs =================================================================== diff -u -r79d36eef280b0a5cbb64ab4b20df234dece1df4a -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Common/src/Core.Common.Controls.Swf/Charting/IChart.cs (.../IChart.cs) (revision 79d36eef280b0a5cbb64ab4b20df234dece1df4a) +++ Core/Common/src/Core.Common.Controls.Swf/Charting/IChart.cs (.../IChart.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -1,6 +1,10 @@ using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Drawing; using System.Windows.Forms; + +using Core.Common.Controls.Swf.Charting.Series; using Core.Common.Utils.Collections.Generic; namespace Core.Common.Controls.Swf.Charting @@ -37,7 +41,7 @@ /// /// Series that are on the chart /// - IEventedList Series { get; } + IEnumerable Series { get; } /// /// Left axis of the chart @@ -84,7 +88,38 @@ /// bool AllowSeriesTypeChange { get; set; } + + int GetIndexOfChartSeries(ChartSeries series); + /// + /// Adds the chart series to the chart. + /// + /// The series. + /// Duplicates are prevented from being added. + void AddChartSeries(ChartSeries series); + + /// + /// Inserts the chart series. + /// + /// The series. + /// The index. + /// When is + /// less than 0 or greater than the number of series within the chart. + void InsertChartSeries(ChartSeries series, int index); + + /// + /// Removes the chart series from the chart. + /// + /// The series. + /// True if removal was successful; false otherwise + bool RemoveChartSeries(ChartSeries series); + + /// + /// Removes all chart series form the chart. + /// + void RemoveAllChartSeries(); + + /// /// Opens export dialog /// void ExportAsImage(IWin32Window owner); Index: Core/Common/src/Core.Common.Controls.Swf/Charting/IChartView.cs =================================================================== diff -u -r79d36eef280b0a5cbb64ab4b20df234dece1df4a -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Common/src/Core.Common.Controls.Swf/Charting/IChartView.cs (.../IChartView.cs) (revision 79d36eef280b0a5cbb64ab4b20df234dece1df4a) +++ Core/Common/src/Core.Common.Controls.Swf/Charting/IChartView.cs (.../IChartView.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -1,6 +1,6 @@ using System; +using System.Collections.Generic; using System.Windows.Forms; -using Core.Common.Utils.Collections.Generic; namespace Core.Common.Controls.Swf.Charting { @@ -34,7 +34,7 @@ /// /// A collection of tools /// - IEventedList Tools { get; } + IEnumerable Tools { get; } /// /// Set and get the selected Point Index (of the active series) Index: Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/ChartViewSeriesToolBase.cs =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/ChartViewSeriesToolBase.cs (.../ChartViewSeriesToolBase.cs) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/ChartViewSeriesToolBase.cs (.../ChartViewSeriesToolBase.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -188,7 +188,7 @@ if (ChartView != null && ChartView.Chart != null) { var matchingSeries = - ChartView.Chart.Series.OfType().FirstOrDefault( + ChartView.Chart.Series.FirstOrDefault( cs => ReferenceEquals(cs.series, internalSeries)); if (matchingSeries != null) @@ -197,7 +197,7 @@ } matchingSeries = - ChartView.Chart.Series.OfType().FirstOrDefault(cs => cs.Title == internalSeries.Title); + ChartView.Chart.Series.FirstOrDefault(cs => cs.Title == internalSeries.Title); if (matchingSeries != null) { Index: Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/ExportChartAsImageChartTool.cs =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/ExportChartAsImageChartTool.cs (.../ExportChartAsImageChartTool.cs) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/ExportChartAsImageChartTool.cs (.../ExportChartAsImageChartTool.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -9,11 +9,6 @@ public event EventHandler ActiveChanged; private bool active; - public ExportChartAsImageChartTool(IChartView chartView) - { - ChartView = chartView; - } - public IChartView ChartView { get; set; } public bool Active Index: Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/RulerTool.cs =================================================================== diff -u -r4f50d51f0faba8e846bbaedcf64e39a814b8d975 -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/RulerTool.cs (.../RulerTool.cs) (revision 4f50d51f0faba8e846bbaedcf64e39a814b8d975) +++ Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/RulerTool.cs (.../RulerTool.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -1,7 +1,6 @@ using System; using System.Drawing; using System.Drawing.Drawing2D; -using System.Globalization; using System.Linq; using System.Windows.Forms; using Core.Common.Controls.Swf.Charting.Customized; Index: Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/SelectPointTool.cs =================================================================== diff -u -r622c20f6fc0b693b67a3e57b2ece939823002c62 -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/SelectPointTool.cs (.../SelectPointTool.cs) (revision 622c20f6fc0b693b67a3e57b2ece939823002c62) +++ Core/Common/src/Core.Common.Controls.Swf/Charting/Tools/SelectPointTool.cs (.../SelectPointTool.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -1,15 +1,15 @@ using System; +using System.Collections.Generic; using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Reflection; using System.Windows.Forms; + using Core.Common.Controls.Swf.Charting.Series; using Core.Common.Controls.Swf.Properties; -using Core.Common.Utils.Collections; -using Core.Common.Utils.Collections.Generic; -using log4net; + using Steema.TeeChart; using Steema.TeeChart.Drawing; using Steema.TeeChart.Styles; @@ -64,18 +64,17 @@ /// public class SelectPointTool : ChartViewSeriesToolBase { - public event NotifyCollectionChangedEventHandler CollectionChanged; - private static readonly ILog log = LogManager.GetLogger(typeof(SelectPointTool)); - private readonly IEventedList selectedPoints = new EventedList(); + public event EventHandler SelectedChartPointsChanged; + private readonly ICollection selectedPoints = new HashSet(); private readonly bool dragging = false; + private readonly int Point = -1; + private readonly Steema.TeeChart.Styles.PointerStyles selectedPointerStyle = Steema.TeeChart.Styles.PointerStyles.Diamond; private bool drawLine = true; private bool fullRepaint = true; private Point mouseLocation; - private readonly int Point = -1; private Color selectedPointerColor = SystemColors.Highlight; - private readonly Steema.TeeChart.Styles.PointerStyles selectedPointerStyle = Steema.TeeChart.Styles.PointerStyles.Diamond; private int size = 10; private NearestPointStyles style = NearestPointStyles.Circle; @@ -84,7 +83,6 @@ { Pen.Style = DashStyle.Dot; Pen.Color = Color.White; - selectedPoints.CollectionChanged += SelectedPointsCollectionChanged; HandleDelete = true; } @@ -203,16 +201,14 @@ /// public void AddPointAtIndexToSelection(IChartSeries series, int pointIndex) { - var teeChartSeries = ((ChartSeries) series).series; - if (!selectedPoints.Any(p => p.Series == teeChartSeries && p.PointIndex == pointIndex)) - { - selectedPoints.Add(new SelectPoint(teeChartSeries, pointIndex)); - } + var teeChartSeries = ((ChartSeries)series).series; + SelectChartPoint(teeChartSeries, pointIndex); } public void ClearSelection() { selectedPoints.Clear(); + FireSelectedChartPointsChangedEvent(); SelectedPointIndex = -1; } @@ -271,7 +267,7 @@ protected override void OnMouseUp(MouseEventArgs e) { - selectedPoints.Clear(); + ClearSelection(); AddClickedPoint(e.X, e.Y); Invalidate(); } @@ -334,14 +330,24 @@ } } - private void SelectedPointsCollectionChanged(object sender, NotifyCollectionChangingEventArgs e) + private void SelectChartPoint(Steema.TeeChart.Styles.Series teeChartSeries, int pointIndex) { - if (CollectionChanged != null) + if (!selectedPoints.Any(p => p.Series == teeChartSeries && p.PointIndex == pointIndex)) { - CollectionChanged(this, e); + var selectPoint = new SelectPoint(teeChartSeries, pointIndex); + selectedPoints.Add(selectPoint); + FireSelectedChartPointsChangedEvent(); } } + private void FireSelectedChartPointsChangedEvent() + { + if (SelectedChartPointsChanged != null) + { + SelectedChartPointsChanged(this, EventArgs.Empty); + } + } + private void PaintHint() { if (selectedPoints.Count > 0) @@ -367,17 +373,17 @@ // Local copy to prevent compiler warning CS1690 (https://msdn.microsoft.com/en-us/library/x524dkh4.aspx) var chartRect = Chart.ChartRect; - if (! chartRect.Contains(x, y)) //outside chart area + if (!chartRect.Contains(x, y)) //outside chart area { continue; } g.Pen = Pen; g.Brush = Brush; - g.FillRectangle(brush, (int) (x - size*0.5), (int) (y - size*0.5), size, size); + g.FillRectangle(brush, (int)(x - size * 0.5), (int)(y - size * 0.5), size, size); -/* + /* g.Rectangle(new Rectangle(2, 2, totalWidth - 1, totaHeight - 1)); @@ -477,7 +483,7 @@ SelectedPointIndex = TeeChartHelper.GetNearestPoint(clickedSeries, mouseLocation, 4); if (SelectedPointIndex > -1) { - selectedPoints.Add(new SelectPoint(clickedSeries, SelectedPointIndex)); + SelectChartPoint(clickedSeries, SelectedPointIndex); } } } Index: Core/Common/test/Core.Common.Controls.Swf.Test/Charting/ChartTest.cs =================================================================== diff -u -rd6e6eadf4a2521df75b6d371bacbb181a43058a3 -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Common/test/Core.Common.Controls.Swf.Test/Charting/ChartTest.cs (.../ChartTest.cs) (revision d6e6eadf4a2521df75b6d371bacbb181a43058a3) +++ Core/Common/test/Core.Common.Controls.Swf.Test/Charting/ChartTest.cs (.../ChartTest.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -18,7 +18,7 @@ Assert.IsNull(chartSeries.Chart); - chart.Series.Add(chartSeries); + chart.AddChartSeries(chartSeries); Assert.AreSame(chart, chartSeries.Chart); } @@ -43,7 +43,7 @@ { UseHatch = true }; - chart.Series.Add(areaSeries); + chart.AddChartSeries(areaSeries); TestHelper.AssertLogMessageIsGenerated(() => SaveDeleteAndAssertExport("test.svg", chart), "Gearceerde stijl wordt niet ondersteund voor exporteren en zal genegeerd worden.", 1); } Index: Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/Charting/ChartLegendView.cs =================================================================== diff -u -r44fce3b0d8942914f2678d8e33ca99646cf8062f -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/Charting/ChartLegendView.cs (.../ChartLegendView.cs) (revision 44fce3b0d8942914f2678d8e33ca99646cf8062f) +++ Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/Charting/ChartLegendView.cs (.../ChartLegendView.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -114,19 +114,20 @@ } } - private IEnumerable GetSeriesToChange() + private IEnumerable GetSeriesToChange() { - var seriesToChange = new List(); + var seriesToChange = new List(); if (treeView.SelectedNode == null) { return seriesToChange; } var nodeItem = treeView.SelectedNode.Tag; - if (nodeItem is IChart) + var nodeChart = nodeItem as IChart; + if (nodeChart != null) { - seriesToChange.AddRange(((IChart) nodeItem).Series); + seriesToChange.AddRange(nodeChart.Series); } if (nodeItem is ChartSeries) { @@ -136,7 +137,7 @@ return seriesToChange; } - private void ChangeSeries(object sender, IChartSeries originalSeries) + private void ChangeSeries(object sender, ChartSeries originalSeries) { if (!chart.AllowSeriesTypeChange) { @@ -146,24 +147,24 @@ var series = GetNewChartSeries(sender as ToolStripButton, originalSeries); var parentNode = treeView.SelectedNode != null ? treeView.SelectedNode.Parent : null; - var index = chart.Series.IndexOf(originalSeries); + var index = chart.GetIndexOfChartSeries(originalSeries); if (index < 0) { - chart.Series.Add(series); + chart.AddChartSeries(series); } else { - chart.Series.Insert(index, series); + chart.InsertChartSeries(series, index); } - chart.Series.Remove(originalSeries); + chart.RemoveChartSeries(originalSeries); if (parentNode != null) { treeView.SelectedNode = parentNode.GetNodeByTag(series); } } - private IChartSeries GetNewChartSeries(ToolStripButton toolStripButton, IChartSeries originalSeries) + private ChartSeries GetNewChartSeries(ToolStripButton toolStripButton, ChartSeries originalSeries) { if (originalSeries is IPolygonChartSeries) { @@ -172,22 +173,22 @@ if (toolStripButton == toolStripButtonAreaSeries) { - return ChartSeriesFactory.CreateAreaSeries(originalSeries); + return (ChartSeries)ChartSeriesFactory.CreateAreaSeries(originalSeries); } if (toolStripButton == toolStripButtonBarSeries) { - return ChartSeriesFactory.CreateBarSeries(originalSeries); + return (ChartSeries)ChartSeriesFactory.CreateBarSeries(originalSeries); } if (toolStripButton == toolStripButtonLineSeries) { - return ChartSeriesFactory.CreateLineSeries(originalSeries); + return (ChartSeries)ChartSeriesFactory.CreateLineSeries(originalSeries); } if (toolStripButton == toolStripButtonPointSeries) { - return ChartSeriesFactory.CreatePointSeries(originalSeries); + return (ChartSeries)ChartSeriesFactory.CreatePointSeries(originalSeries); } throw new NotImplementedException(); Index: Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/Charting/ChartSeriesTreeNodePresenter.cs =================================================================== diff -u -r44fce3b0d8942914f2678d8e33ca99646cf8062f -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/Charting/ChartSeriesTreeNodePresenter.cs (.../ChartSeriesTreeNodePresenter.cs) (revision 44fce3b0d8942914f2678d8e33ca99646cf8062f) +++ Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/Charting/ChartSeriesTreeNodePresenter.cs (.../ChartSeriesTreeNodePresenter.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -7,14 +7,13 @@ namespace Core.Plugins.CommonTools.Gui.Forms.Charting { - internal class ChartSeriesTreeNodePresenter : TreeViewNodePresenterBase - { + internal class ChartSeriesTreeNodePresenter : TreeViewNodePresenterBase { public override bool CanRenameNode(ITreeNode node) { return true; } - public override void OnNodeRenamed(IChartSeries chartSeries, string newName) + public override void OnNodeRenamed(ChartSeries chartSeries, string newName) { if (chartSeries == null || chartSeries.Title == newName) { @@ -24,7 +23,7 @@ chartSeries.Title = newName; } - public override void UpdateNode(ITreeNode parentNode, ITreeNode node, IChartSeries chartSeries) + public override void UpdateNode(ITreeNode parentNode, ITreeNode node, ChartSeries chartSeries) { node.Text = chartSeries.Title; node.Tag = chartSeries; @@ -43,14 +42,14 @@ } } - public override DragOperations CanDrag(IChartSeries nodeData) + public override DragOperations CanDrag(ChartSeries nodeData) { return DragOperations.Move; } - protected override bool RemoveNodeData(object parentNodeData, IChartSeries chartSeries) + protected override bool RemoveNodeData(object parentNodeData, ChartSeries chartSeries) { - chartSeries.Chart.Series.Remove(chartSeries); + chartSeries.Chart.RemoveChartSeries(chartSeries); return true; } Index: Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/Charting/ChartTreeNodePresenter.cs =================================================================== diff -u -r44fce3b0d8942914f2678d8e33ca99646cf8062f -r2da9b71bbdefaeed62c47b673671b7d76502a363 --- Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/Charting/ChartTreeNodePresenter.cs (.../ChartTreeNodePresenter.cs) (revision 44fce3b0d8942914f2678d8e33ca99646cf8062f) +++ Core/Plugins/src/Core.Plugins.CommonTools.Gui/Forms/Charting/ChartTreeNodePresenter.cs (.../ChartTreeNodePresenter.cs) (revision 2da9b71bbdefaeed62c47b673671b7d76502a363) @@ -1,7 +1,7 @@ using System.Collections; -using System.Linq; using Core.Common.Controls; using Core.Common.Controls.Swf.Charting; +using Core.Common.Controls.Swf.Charting.Series; using Core.Common.Controls.Swf.TreeViewControls; using Core.Plugins.CommonTools.Gui.Properties; @@ -33,7 +33,7 @@ public override IEnumerable GetChildNodeObjects(IChart chart) { - return chart.Series.Cast(); + return chart.Series; } public override bool CanInsert(object item, ITreeNode sourceNode, ITreeNode targetNode) @@ -53,7 +53,7 @@ public override void OnDragDrop(object item, object itemParent, IChart target, DragOperations operation, int position) { - var series = item as IChartSeries; + var series = item as ChartSeries; if (series == null) { @@ -63,14 +63,14 @@ var chart = itemParent as IChart; if (chart != null) { - chart.Series.Remove(series); + chart.RemoveChartSeries(series); } else { - target.Series.Remove(series); + target.RemoveChartSeries(series); } - target.Series.Insert(position, series); + target.InsertChartSeries(series, position); } } } \ No newline at end of file