- Timestamp:
- 06/27/11 15:51:15 (13 years ago)
- Location:
- branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3
- Files:
-
- 1 added
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3
- Property svn:ignore
-
old new 1 1 HeuristicLab.Encodings.ScheduleEncoding.Views-3.3.csproj.user 2 Plugin.cs 2 3 bin 3 4 obj
-
- Property svn:ignore
-
branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/GanttChart.cs
r6406 r6482 11 11 private IDictionary<int, Color> jobColors = new SortedDictionary<int, Color>(); 12 12 private IDictionary<string, int> rowNames = new Dictionary<string, int>(); 13 13 14 14 15 15 public GanttChart() { … … 21 21 if (!jobColors.ContainsKey(jobNr)) { 22 22 Random r = new Random(jobNr + 1); 23 jobColors[jobNr] = Color.FromArgb (r.Next(256),r.Next(256),r.Next(256));23 jobColors[jobNr] = Color.FromArgb(r.Next(256), r.Next(256), r.Next(256)); 24 24 chart.Legends[0].CustomItems.Clear(); 25 25 if (jobColors.Count > 1) { … … 28 28 chart.Legends[0].CustomItems.Add(c, "Job#" + (i++)); 29 29 } 30 } 30 } 31 31 } 32 32 } … … 39 39 } 40 40 41 public void AddData(string rowName, int jobNr, double start, double end, string tooltip, bool showLabel = true) {41 public void AddData(string rowName, int jobNr, int taskNr, double start, double end, string tooltip, bool showLabel = true) { 42 42 AddRowName(rowName); 43 var point = new DataPoint(rowNames[rowName], new double[] { start, end }); 43 AddJobColor(jobNr); 44 JobDataPoint point = new JobDataPoint(rowNames[rowName], new double[] { start, end }, jobNr, taskNr); 44 45 point.Color = jobColors[jobNr]; 45 46 point.AxisLabel = rowName; … … 56 57 57 58 void chart_MouseClick(object sender, MouseEventArgs e) { 58 var pos = e.Location; 59 var results = chart.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint); 60 foreach (DataPoint dp in chart.Series[0].Points) { 61 Color newColor = Color.FromArgb(255, dp.Color); 62 dp.Color = newColor; 63 } 64 foreach (var result in results) { 65 if (result.ChartElementType == ChartElementType.DataPoint) { 66 Color currentColor = chart.Series[0].Points[result.PointIndex].Color; 67 foreach (DataPoint dp in result.Series.Points) { 68 if (dp.Color != currentColor) { 69 Color newColor = Color.FromArgb(0, dp.Color); 70 dp.Color = newColor; 71 } 72 } 59 Point pos = e.Location; 60 HitTestResult[] results = chart.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint); 61 ResetDataColors(); 62 63 foreach (HitTestResult result in results) { 64 if (result.ChartElementType == ChartElementType.DataPoint && result.Object.GetType() == typeof(JobDataPoint)) { 65 int currentJobNr = (result.Object as JobDataPoint).JobNr; 66 int currentTaskNr = (result.Object as JobDataPoint).TaskNr; 67 68 HighlightTaskAndJob(currentJobNr, currentTaskNr); 73 69 } 74 70 } 75 71 } 72 73 public void ResetDataColors() { 74 foreach (DataPoint dp in chart.Series[0].Points) { 75 if (dp.GetType() == typeof(JobDataPoint)) 76 dp.Color = jobColors[(dp as JobDataPoint).JobNr]; 77 } 78 } 79 80 public void HighlightTaskAndJob(int jobNr, int taskNr) { 81 foreach (DataPoint dp in chart.Series[0].Points) { 82 if (dp.GetType() == typeof(JobDataPoint) && ((dp as JobDataPoint).JobNr == jobNr) && ((dp as JobDataPoint).TaskNr == taskNr)) { 83 Color newColor = Color.FromArgb(255, dp.Color); 84 dp.Color = newColor; 85 } else if (dp.GetType() == typeof(JobDataPoint) && ((dp as JobDataPoint).JobNr == jobNr)) { 86 Color newColor = Color.FromArgb(180, dp.Color); 87 dp.Color = newColor; 88 } else if (dp.GetType() == typeof(JobDataPoint) && !((dp as JobDataPoint).JobNr == jobNr)) { 89 Color newColor = Color.FromArgb(0, dp.Color); 90 dp.Color = newColor; 91 } 92 } 93 } 94 76 95 } 77 96 } -
branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/HeuristicLab.Encodings.ScheduleEncoding.Views-3.3.csproj
r6406 r6482 56 56 <DependentUpon>GanttChart.cs</DependentUpon> 57 57 </Compile> 58 <Compile Include="JobDataPoint.cs" /> 58 59 <Compile Include="Plugin.cs" /> 59 60 <Compile Include="Properties\AssemblyInfo.cs" /> -
branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/Properties
-
Property
svn:ignore
set to
AssemblyInfo.cs
-
Property
svn:ignore
set to
-
branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/ScheduleView.Designer.cs
r6406 r6482 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.ganttChart = new GanttChart();47 this.ganttChart = new HeuristicLab.Encodings.ScheduleEncoding.Views.GanttChart(); 48 48 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 49 49 this.SuspendLayout(); -
branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/ScheduleView.cs
r6412 r6482 72 72 foreach (ScheduledTask t in content.Resources[resCount].Tasks) { 73 73 int categoryNr = 0; 74 string toolTip = "Task#" ;// +t.TaskNr;74 string toolTip = "Task#" + t.TaskNr; 75 75 string categoryName = "ScheduleTasks"; 76 76 if (t is ScheduledTask) { … … 79 79 toolTip = categoryName + " - " + toolTip; 80 80 } 81 ganttChart.AddJobColor(categoryNr);82 81 ganttChart.AddData("Resource" + r.Index, 83 82 categoryNr, 83 t.TaskNr, 84 84 t.StartTime, 85 85 t.EndTime, … … 88 88 resCount++; 89 89 } 90 } 91 92 private void RefreshChartInformations(Schedule content) { 93 90 94 } 91 95
Note: See TracChangeset
for help on using the changeset viewer.