Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/26/12 09:51:13 (12 years ago)
Author:
jkarder
Message:

#1331: merged r8086:8330 from trunk

Location:
branches/ScatterSearch (trunk integration)
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/ScatterSearch (trunk integration)

  • branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.Views/3.3/HiveTasks/OptimizerHiveTaskView.cs

    r7582 r8331  
    3131  [Content(typeof(OptimizerHiveTask), true)]
    3232  public partial class OptimizerHiveTaskView : HiveTaskView {
     33    private Progress progress;
    3334    private ProgressView progressView;
    3435
     
    4445    public OptimizerHiveTaskView() {
    4546      InitializeComponent();
     47      progress = new Progress() {
     48        CanBeCanceled = false,
     49        ProgressState = ProgressState.Finished
     50      };
    4651    }
    4752
     
    5762      base.RegisterContentEvents();
    5863      Content.IsControllableChanged += new EventHandler(Content_IsControllableChanged);
     64      progressView = new ProgressView(this, progress);
    5965    }
    6066
    6167    protected override void DeregisterContentEvents() {
    6268      Content.IsControllableChanged -= new EventHandler(Content_IsControllableChanged);
     69      if (progressView != null) {
     70        progressView.Content = null;
     71        progressView.Dispose();
     72        progressView = null;
     73      }
    6374      base.DeregisterContentEvents();
    6475    }
     
    7485      var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeTaskAsync);
    7586      task.ContinueWith((t) => {
    76         FinishProgressView();
     87        progress.Finish();
    7788        ErrorHandling.ShowErrorDialog(this, "An error occured while resuming the task.", t.Exception);
    7889      }, TaskContinuationOptions.OnlyOnFaulted);
     
    8293      var task = System.Threading.Tasks.Task.Factory.StartNew(PauseTaskAsync);
    8394      task.ContinueWith((t) => {
    84         FinishProgressView();
     95        progress.Finish();
    8596        ErrorHandling.ShowErrorDialog(this, "An error occured while pausing the task.", t.Exception);
    8697      }, TaskContinuationOptions.OnlyOnFaulted);
     
    90101      var task = System.Threading.Tasks.Task.Factory.StartNew(StopTaskAsync);
    91102      task.ContinueWith((t) => {
    92         FinishProgressView();
     103        progress.Finish();
    93104        ErrorHandling.ShowErrorDialog(this, "An error occured while stopping the task.", t.Exception);
    94105      }, TaskContinuationOptions.OnlyOnFaulted);
     
    97108
    98109    private void PauseTaskAsync() {
    99       IProgress prog = new Progress();
    100       prog.Status = "Pausing task. Please be patient for the command to take effect.";
    101       SetProgressView(prog);
     110      progress.Status = "Pausing task. Please be patient for the command to take effect.";
     111      progress.ProgressState = ProgressState.Started;
    102112      Content.Pause();
    103       FinishProgressView();
     113      progress.Finish();
    104114    }
    105115
    106116    private void StopTaskAsync() {
    107       IProgress prog = new Progress();
    108       prog.Status = "Stopping task. Please be patient for the command to take effect.";
    109       SetProgressView(prog);
     117      progress.Status = "Stopping task. Please be patient for the command to take effect.";
     118      progress.ProgressState = ProgressState.Started;
    110119      Content.Stop();
    111       FinishProgressView();
     120      progress.Finish();
    112121    }
    113122
    114123    private void ResumeTaskAsync() {
    115       IProgress prog = new Progress();
    116       prog.Status = "Resuming task. Please be patient for the command to take effect.";
    117       SetProgressView(prog);
     124      progress.Status = "Resuming task. Please be patient for the command to take effect.";
     125      progress.ProgressState = ProgressState.Started;
    118126      Content.Restart();
    119       FinishProgressView();
    120     }
    121 
    122     private void SetProgressView(IProgress progress) {
    123       if (InvokeRequired) {
    124         Invoke(new Action<IProgress>(SetProgressView), progress);
    125       } else {
    126         if (progressView == null) {
    127           progressView = new ProgressView(this, progress);
    128         } else {
    129           progressView.Progress = progress;
    130         }
    131       }
    132     }
    133 
    134     private void FinishProgressView() {
    135       if (InvokeRequired) {
    136         Invoke(new Action(FinishProgressView));
    137       } else {
    138         if (progressView != null) {
    139           progressView.Finish();
    140           progressView = null;
    141           SetEnabledStateOfControls();
    142         }
    143       }
     127      progress.Finish();
    144128    }
    145129
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.Views/3.3/Plugin.cs.frame

    r7259 r8331  
    2727
    2828namespace HeuristicLab.Clients.Hive.Views {
    29   [Plugin("HeuristicLab.Clients.Hive.Views", "3.3.6.$WCREV$")]
     29  [Plugin("HeuristicLab.Clients.Hive.Views", "3.3.7.$WCREV$")]
    3030  [PluginFile("HeuristicLab.Clients.Hive.Views-3.3.dll", PluginFileType.Assembly)]
    3131  [PluginDependency("HeuristicLab.Clients.Hive", "3.3")]
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.Views/3.3/Properties/AssemblyInfo.cs.frame

    r7260 r8331  
    5555// [assembly: AssemblyVersion("1.0.*")]
    5656[assembly: AssemblyVersion("3.3.0.0")]
    57 [assembly: AssemblyFileVersion("3.3.6.$WCREV$")]
     57[assembly: AssemblyFileVersion("3.3.7.$WCREV$")]
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.Views/3.3/StateLog/StateLogGanttChartListView.cs

    r7728 r8331  
    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}
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.Views/3.3/TreeView/HiveTaskItemTreeView.cs

    r8086 r8331  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using System.Windows.Forms;
     
    4241    }
    4342
    44     #region Register Content Events
    45     protected override void DeregisterContentEvents() {
    46       // TODO: Deregister your event handlers on the Content here
    47       base.DeregisterContentEvents();
    48     }
    49     protected override void RegisterContentEvents() {
    50       base.RegisterContentEvents();
    51       // TODO: Register your event handlers on the Content here
    52     }
    53     #endregion
    54 
    55     protected override void OnContentChanged() {
    56       base.OnContentChanged();
    57       if (Content == null) {
    58         // TODO: Put code here when content is null
    59       } else {
    60         // TODO: Put code here when content has been changed and is not null
    61       }
    62     }
    63 
    64     protected override void SetEnabledStateOfControls() {
    65       base.SetEnabledStateOfControls();
    66       // TODO: Put code here to enable or disable controls based on whether the Content is/not null or the view is ReadOnly
    67     }
    68 
    69     #region Event Handlers
    70     // TODO: Put event handlers here
    71     #endregion
    72 
    73     #region Child Control Events
    74     protected override void addButton_Click(object sender, EventArgs e) {
     43    protected override void AddItem() {
    7544      IOptimizer optimizer = CreateItem<IOptimizer>();
    7645      if (optimizer != null) {
     
    8857    }
    8958
    90     protected override void removeButton_Click(object sender, EventArgs e) {
    91       base.removeButton_Click(sender, e);
    92 
    93       if (treeView.SelectedNode != null) {
    94         var selectedItem = (HiveTask)treeView.SelectedNode.Tag;
    95         var parentItem = GetParentItem(selectedItem);
    96         if (parentItem == null) {
    97           Content.Remove((HiveTask)treeView.SelectedNode.Tag);
    98         } else {
    99           var experiment = parentItem.ItemTask.Item as Experiment;
    100           if (experiment != null) {
    101             experiment.Optimizers.Remove(((OptimizerTask)selectedItem.ItemTask).Item);
    102           }
     59    protected override void RemoveItem(HiveTask item) {
     60      var parentItem = GetParentItem(item);
     61      if (parentItem == null) {
     62        Content.Remove(item);
     63      } else {
     64        var experiment = parentItem.ItemTask.Item as Experiment;
     65        if (experiment != null) {
     66          experiment.Optimizers.Remove(((OptimizerTask)item.ItemTask).Item);
    10367        }
    10468      }
    10569    }
    106     #endregion
    10770
    10871    protected override ICollection<IItemTreeNodeAction<HiveTask>> GetTreeNodeItemActions(HiveTask selectedItem) {
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.Views/3.3/TreeView/ItemTreeView.cs

    r8086 r8331  
    3636  [View("ItemTree View")]
    3737  [Content(typeof(ItemCollection<>), IsDefaultView = false)]
    38   public partial class ItemTreeView<T> : ItemView where T : class, IItemTree<T> {
     38  public abstract partial class ItemTreeView<T> : ItemView where T : class, IItemTree<T> {
    3939    public new ItemCollection<T> Content {
    4040      get { return (ItemCollection<T>)base.Content; }
     
    360360
    361361    protected virtual void addButton_Click(object sender, EventArgs e) {
    362       T item = CreateItem<T>();
    363       if (item != null)
    364         Content.Add(item);
     362      AddItem();
    365363    }
    366364
    367365    protected virtual void removeButton_Click(object sender, EventArgs e) {
    368366      if (treeView.SelectedNode != null) {
     367        RemoveItem(treeView.SelectedNode.Tag as T);
    369368        detailsViewHost.Content = null;
    370369      }
    371370    }
     371
     372    protected abstract void AddItem();
     373
     374    protected abstract void RemoveItem(T item);
    372375
    373376    protected virtual void showDetailsCheckBox_CheckedChanged(object sender, EventArgs e) {
Note: See TracChangeset for help on using the changeset viewer.