Changeset 5636 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/StateLogGanttChartListView.cs
- Timestamp:
- 03/08/11 14:54:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/StateLogGanttChartListView.cs
r5597 r5636 20 20 #endregion 21 21 22 using System; 22 23 using System.Drawing; 24 using System.Linq; 23 25 using HeuristicLab.Core; 24 26 using HeuristicLab.Core.Views; 25 27 using HeuristicLab.MainForm; 26 using HeuristicLab.Services.Hive.Common.DataTransfer;27 28 28 29 namespace HeuristicLab.Clients.Hive.Views { 29 30 [View("StateLogGanttChartList View")] 30 [Content(typeof(IItemList<StateLog ItemList>), IsDefaultView = true)]31 [Content(typeof(IItemList<StateLogList>), IsDefaultView = true)] 31 32 public sealed partial class StateLogGanttChartListView : ItemView { 32 public new IItemList<StateLog ItemList> Content {33 get { return (IItemList<StateLog ItemList>)base.Content; }33 public new IItemList<StateLogList> Content { 34 get { return (IItemList<StateLogList>)base.Content; } 34 35 set { base.Content = value; } 35 36 } … … 61 62 // Add code when content has been changed and is not null 62 63 ganttChart.Reset(); 63 ganttChart.AddCategory(JobState.Offline.ToString(), Color.Brown); 64 ganttChart.AddCategory(JobState.Waiting.ToString(), Color.Yellow); 65 ganttChart.AddCategory(JobState.Transferring.ToString(), Color.Blue); 66 ganttChart.AddCategory(JobState.Calculating.ToString(), Color.Green); 67 ganttChart.AddCategory(JobState.Finished.ToString(), Color.DarkGreen); 68 ganttChart.AddCategory(JobState.Aborted.ToString(), Color.Orange); 69 ganttChart.AddCategory(JobState.Failed.ToString(), Color.Red); 64 SetupCategories(ganttChart); 65 66 DateTime maxValue = Content.Max(x => x.Max(y => y.DateTime)); 67 var upperLimit = DateTime.FromOADate(Math.Min(DateTime.Now.AddSeconds(10).ToOADate(), maxValue.AddSeconds(10).ToOADate())); 70 68 71 69 for (int i = 0; i < Content.Count; i++) { 72 70 for (int j = 0; j < Content[i].Count - 1; j++) { 73 string tooltip = string.Format("State: {0}\n{1} - {2}", Content[i][j].State, Content[i][j].DateTime, Content[i][j+1].DateTime); 74 if (!string.IsNullOrEmpty(Content[i][j].Exception)) 75 tooltip += "\n" + Content[i][j].Exception; 76 ganttChart.AddData(i + 1, Content[i][j].State.ToString(), Content[i][j].DateTime, Content[i][j + 1].DateTime, tooltip, false); 71 if(Content[i][j].State != JobState.Offline && Content[i][j].State != JobState.Finished) 72 AddData(ganttChart, i.ToString(), Content[i][j], Content[i][j+1], upperLimit); 73 } 74 if(Content[i].Count > 0) { 75 AddData(ganttChart, i.ToString(), Content[i][Content[i].Count - 1], null, upperLimit); 77 76 } 78 77 } … … 80 79 } 81 80 81 public static void SetupCategories(GanttChart ganttChart) { 82 ganttChart.AddCategory(JobState.Offline.ToString(), Color.Gainsboro); 83 ganttChart.AddCategory(JobState.Waiting.ToString(), Color.NavajoWhite); 84 ganttChart.AddCategory(JobState.Transferring.ToString(), Color.CornflowerBlue); 85 ganttChart.AddCategory(JobState.Calculating.ToString(), Color.DarkGreen); 86 ganttChart.AddCategory(JobState.Finished.ToString(), Color.White); 87 ganttChart.AddCategory(JobState.Aborted.ToString(), Color.Orange); 88 ganttChart.AddCategory(JobState.Failed.ToString(), Color.Red); 89 } 90 91 //private void AddData(int i, int j, DateTime upperLimit) { 92 // DateTime until = j < Content[i].Count - 1 ? Content[i][j + 1].DateTime : upperLimit; 93 // TimeSpan duration = until - Content[i][j].DateTime; 94 // string tooltip = string.Format("State: {0}\nDuration: {1}\n{2} - {3}", Content[i][j].State, Content[i][j].DateTime, duration, until); 95 // if (!string.IsNullOrEmpty(Content[i][j].Exception)) 96 // tooltip += "\n" + Content[i][j].Exception; 97 // ganttChart.AddData(i + 1, Content[i][j].State.ToString(), Content[i][j].DateTime, until, tooltip, false); 98 //} 99 100 public static void AddData(GanttChart ganttChart, string name, StateLog from, StateLog to, DateTime upperLimit) { 101 DateTime until = to != null ? to.DateTime : upperLimit; 102 TimeSpan duration = until - from.DateTime; 103 string tooltip = string.Format("State: {0}\nDuration: {1}\n{2} - {3}", from.State, from.DateTime, duration, until); 104 if (!string.IsNullOrEmpty(from.Exception)) 105 tooltip += "\n" + from.Exception; 106 ganttChart.AddData(name, from.State.ToString(), from.DateTime, until, tooltip, false); 107 } 108 82 109 protected override void SetEnabledStateOfControls() { 83 110 base.SetEnabledStateOfControls();
Note: See TracChangeset
for help on using the changeset viewer.