Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8107


Ignore:
Timestamp:
06/25/12 17:02:06 (12 years ago)
Author:
jkarder
Message:

#1709:

  • implemented filtering according to the legend items
  • added zoom support
Location:
trunk/sources
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive.Views/3.3/StateLog/StateLogGanttChartListView.cs

    r7728 r8107  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.Drawing;
    2425using System.Linq;
     26using System.Windows.Forms;
     27using System.Windows.Forms.DataVisualization.Charting;
    2528using HeuristicLab.Core.Views;
    2629using HeuristicLab.MainForm;
     
    3134  [Content(typeof(StateLogListList), true)]
    3235  public sealed partial class StateLogGanttChartListView : ItemView {
     36    private IList<LegendItem> invisibleLegendItems;
     37
    3338    public new StateLogListList Content {
    3439      get { return (StateLogListList)base.Content; }
     
    3843    public StateLogGanttChartListView() {
    3944      InitializeComponent();
     45      invisibleLegendItems = new List<LegendItem>();
    4046    }
    4147
    4248    protected override void DeregisterContentEvents() {
    4349      // 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);
    4453      base.DeregisterContentEvents();
    4554    }
     
    4857      base.RegisterContentEvents();
    4958      // 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);
    5062    }
    5163
     
    7587          for (int i = Content.Count - 1; i >= 0; i--) {
    7688            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()))
    7890                AddData(ganttChart, i.ToString(), Content[i][j], Content[i][j + 1], upperLimit);
    7991            }
    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())) {
    8193              AddData(ganttChart, i.ToString(), Content[i][Content[i].Count - 1], null, upperLimit);
    8294            }
     
    113125      base.SetEnabledStateOfControls();
    114126    }
     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
    115159  }
    116160}
  • trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/GanttChart.Designer.cs

    r7967 r8107  
    3636                  | System.Windows.Forms.AnchorStyles.Left)
    3737                  | System.Windows.Forms.AnchorStyles.Right)));
     38      chartArea1.AxisX.ScaleView.SmallScrollMinSizeType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Milliseconds;
     39      chartArea1.AxisY.ScaleView.SmallScrollMinSizeType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Milliseconds;
     40      chartArea1.CursorX.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Milliseconds;
     41      chartArea1.CursorY.IntervalType = System.Windows.Forms.DataVisualization.Charting.DateTimeIntervalType.Milliseconds;
    3842      chartArea1.Name = "ChartArea1";
    3943      this.chart.ChartAreas.Add(chartArea1);
  • trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/GanttChart.cs

    r7410 r8107  
    3535    public GanttChart() {
    3636      InitializeComponent();
     37      chart.CustomizeAllChartAreas();
    3738    }
    3839
Note: See TracChangeset for help on using the changeset viewer.