using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.Windows.Forms.DataVisualization.Charting; namespace HeuristicLab.Clients.Hive.Views.ExperimentManager { public partial class GanttChart : UserControl { private IDictionary categories = new Dictionary(); public GanttChart() { InitializeComponent(); } public void AddCategory(string name, Color color) { categories[name] = color; chart.Legends[0].CustomItems.Add(color, name); } public void AddData(int id, string category, DateTime start, DateTime end, string tooltip, bool showLabel = true) { var point = CreateDataPoint(id, start, end, showLabel ? category : string.Empty, categories[category]); point.ToolTip = tooltip; chart.Series[0].Points.Add(point); } private static DataPoint CreateDataPoint(double x, DateTime start, DateTime end, string text, Color color) { var point = new DataPoint(x, new double[] { start.ToOADate(), end.ToOADate() }); point.Color = color; point.Label = text; return point; } public void Reset() { chart.Series[0].Points.Clear(); categories.Clear(); chart.Legends[0].CustomItems.Clear(); } } }