Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/27/11 15:51:15 (13 years ago)
Author:
jhelm
Message:

#1329: Applied some changes to the ScheduleView. Added TaskNr properties to ScheduledTask to make specific selection of tasks in the view possible.

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  
        11HeuristicLab.Encodings.ScheduleEncoding.Views-3.3.csproj.user
         2Plugin.cs
        23bin
        34obj
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/GanttChart.cs

    r6406 r6482  
    1111    private IDictionary<int, Color> jobColors = new SortedDictionary<int, Color>();
    1212    private IDictionary<string, int> rowNames = new Dictionary<string, int>();
    13    
     13
    1414
    1515    public GanttChart() {
     
    2121      if (!jobColors.ContainsKey(jobNr)) {
    2222        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));
    2424        chart.Legends[0].CustomItems.Clear();
    2525        if (jobColors.Count > 1) {
     
    2828            chart.Legends[0].CustomItems.Add(c, "Job#" + (i++));
    2929          }
    30         }   
     30        }
    3131      }
    3232    }
     
    3939    }
    4040
    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) {
    4242      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);
    4445      point.Color = jobColors[jobNr];
    4546      point.AxisLabel = rowName;
     
    5657
    5758    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);
    7369        }
    7470      }
    7571    }
     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
    7695  }
    7796}
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/HeuristicLab.Encodings.ScheduleEncoding.Views-3.3.csproj

    r6406 r6482  
    5656      <DependentUpon>GanttChart.cs</DependentUpon>
    5757    </Compile>
     58    <Compile Include="JobDataPoint.cs" />
    5859    <Compile Include="Plugin.cs" />
    5960    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/Properties

    • Property svn:ignore set to
      AssemblyInfo.cs
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/ScheduleView.Designer.cs

    r6406 r6482  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.ganttChart = new GanttChart();
     47      this.ganttChart = new HeuristicLab.Encodings.ScheduleEncoding.Views.GanttChart();
    4848      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    4949      this.SuspendLayout();
  • branches/Scheduling/HeuristicLab.Encodings.ScheduleEncoding.Views/3.3/ScheduleView.cs

    r6412 r6482  
    7272        foreach (ScheduledTask t in content.Resources[resCount].Tasks) {
    7373          int categoryNr = 0;
    74           string toolTip = "Task#";// +t.TaskNr;
     74          string toolTip = "Task#" + t.TaskNr;
    7575          string categoryName = "ScheduleTasks";
    7676          if (t is ScheduledTask) {
     
    7979            toolTip = categoryName + " - " + toolTip;
    8080          }
    81           ganttChart.AddJobColor(categoryNr);
    8281          ganttChart.AddData("Resource" + r.Index,
    8382            categoryNr,
     83            t.TaskNr,
    8484            t.StartTime,
    8585            t.EndTime,
     
    8888        resCount++;
    8989      }
     90    }
     91
     92    private void RefreshChartInformations(Schedule content) {
     93
    9094    }
    9195
Note: See TracChangeset for help on using the changeset viewer.