- Timestamp:
- 07/03/12 16:46:35 (12 years ago)
- Location:
- branches/GP-MoveOperators
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MoveOperators
- Property svn:mergeinfo changed
/trunk/sources merged: 8084,8088-8090,8092-8100,8102-8113,8115,8117-8132,8134-8146,8148-8156,8158-8160,8163-8170,8173-8176,8178-8190,8192-8205
- Property svn:mergeinfo changed
-
branches/GP-MoveOperators/HeuristicLab.Clients.Hive.Views/3.3/StateLog/StateLogGanttChartListView.cs
r7728 r8206 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.Drawing; 24 25 using System.Linq; 26 using System.Windows.Forms; 27 using System.Windows.Forms.DataVisualization.Charting; 25 28 using HeuristicLab.Core.Views; 26 29 using HeuristicLab.MainForm; … … 31 34 [Content(typeof(StateLogListList), true)] 32 35 public sealed partial class StateLogGanttChartListView : ItemView { 36 private IList<LegendItem> invisibleLegendItems; 37 33 38 public new StateLogListList Content { 34 39 get { return (StateLogListList)base.Content; } … … 38 43 public StateLogGanttChartListView() { 39 44 InitializeComponent(); 45 invisibleLegendItems = new List<LegendItem>(); 40 46 } 41 47 42 48 protected override void DeregisterContentEvents() { 43 49 // Deregister your event handlers here 50 ganttChart.chart.MouseMove -= new System.Windows.Forms.MouseEventHandler(chart_MouseDown); 51 ganttChart.chart.MouseDown -= new System.Windows.Forms.MouseEventHandler(chart_MouseDown); 52 ganttChart.chart.CustomizeLegend -= new EventHandler<CustomizeLegendEventArgs>(chart_CustomizeLegend); 44 53 base.DeregisterContentEvents(); 45 54 } … … 48 57 base.RegisterContentEvents(); 49 58 // Register your event handlers here 59 ganttChart.chart.MouseMove += new System.Windows.Forms.MouseEventHandler(chart_MouseMove); 60 ganttChart.chart.MouseDown += new System.Windows.Forms.MouseEventHandler(chart_MouseDown); 61 ganttChart.chart.CustomizeLegend += new EventHandler<CustomizeLegendEventArgs>(chart_CustomizeLegend); 50 62 } 51 63 … … 75 87 for (int i = Content.Count - 1; i >= 0; i--) { 76 88 for (int j = 0; j < Content[i].Count - 1; j++) { 77 if (Content[i][j].State != TaskState.Offline )89 if (Content[i][j].State != TaskState.Offline && invisibleLegendItems.All(x => x.Name != Content[i][j].State.ToString())) 78 90 AddData(ganttChart, i.ToString(), Content[i][j], Content[i][j + 1], upperLimit); 79 91 } 80 if (Content[i].Count > 0 ) {92 if (Content[i].Count > 0 && invisibleLegendItems.All(x => x.Name != Content[i][Content[i].Count - 1].State.ToString())) { 81 93 AddData(ganttChart, i.ToString(), Content[i][Content[i].Count - 1], null, upperLimit); 82 94 } … … 113 125 base.SetEnabledStateOfControls(); 114 126 } 127 128 #region Events 129 void chart_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { 130 HitTestResult result = ganttChart.chart.HitTest(e.X, e.Y); 131 if (result.ChartElementType == ChartElementType.LegendItem) 132 Cursor = Cursors.Hand; 133 else 134 Cursor = Cursors.Default; 135 } 136 137 private void chart_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { 138 HitTestResult result = ganttChart.chart.HitTest(e.X, e.Y); 139 if (result.ChartElementType == ChartElementType.LegendItem) 140 ToggleLegendItemVisibility(result.Object as LegendItem); 141 ganttChart.Reset(); 142 OnContentChanged(); 143 } 144 145 private void chart_CustomizeLegend(object sender, CustomizeLegendEventArgs e) { 146 foreach (var item in e.LegendItems) 147 foreach (var cell in item.Cells) 148 cell.ForeColor = invisibleLegendItems.Any(x => x.Name == item.Name) ? Color.Gray : Color.Black; 149 } 150 #endregion 151 152 #region Helpers 153 private void ToggleLegendItemVisibility(LegendItem legendItem) { 154 var item = invisibleLegendItems.FirstOrDefault(x => x.Name == legendItem.Name); 155 if (item != null) invisibleLegendItems.Remove(item); 156 else invisibleLegendItems.Add(legendItem); 157 } 158 #endregion 115 159 } 116 160 }
Note: See TracChangeset
for help on using the changeset viewer.