Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/01/10 17:34:36 (14 years ago)
Author:
mkommend
Message:

enable disable action buttons (ticket #867)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphView.cs

    r2899 r2901  
    4646      this.graphVisualizationInfoView.Controller.OnShowContextMenu += new EventHandler<EntityMenuEventArgs>(Controller_OnShowContextMenu);
    4747      this.graphVisualizationInfoView.Controller.Model.Selection.OnNewSelection += new EventHandler(Controller_SelectionChanged);
     48      foreach (ITool tool in this.graphVisualizationInfoView.Controller.Tools) {
     49        tool.OnToolActivate += new EventHandler<ToolEventArgs>(tool_OnToolActivate);
     50        tool.OnToolDeactivate += new EventHandler<ToolEventArgs>(tool_OnToolDeactivate);
     51      }
    4852    }
    4953
     
    183187    #endregion
    184188
     189    private void tool_OnToolActivate(object sender, ToolEventArgs e) {
     190      Button button = GetButtonForTool(e.Properties.Name);
     191      if (button != null)
     192        button.Enabled = false;
     193    }
     194
     195    private void tool_OnToolDeactivate(object sender, ToolEventArgs e) {
     196      Button button = GetButtonForTool(e.Properties.Name);
     197      if (button != null)
     198        button.Enabled = true;
     199    }
     200
     201    private Button GetButtonForTool(string toolName) {
     202      Button button = null;
     203      switch (toolName) {
     204        case ControllerBase.SelectionToolName:
     205          button = this.selectButton;
     206          break;
     207        case ControllerBase.PanToolName:
     208          button = this.panButton;
     209          break;
     210        case ControllerBase.ConnectionToolName:
     211          button = this.connectButton;
     212          break;
     213        case ControllerBase.ZoomAreaToolName:
     214          button = this.zoomAreaButton;
     215          break;
     216      }
     217      return button;
     218    }
     219
    185220    private void selectButton_Click(object sender, EventArgs e) {
    186221      ITool tool = this.graphVisualizationInfoView.Controller.Tools.Where(t => t.Name == ControllerBase.SelectionToolName).First();
    187222      tool.IsSuspended = false;
    188       tool = this.graphVisualizationInfoView.Controller.Tools.Where(t => t.Name == ControllerBase.PanToolName).First();
    189       this.graphVisualizationInfoView.Controller.DeactivateTool(tool);
     223      this.graphVisualizationInfoView.Controller.DeactivateAllTools();
    190224    }
    191225
    192226    private void panButton_Click(object sender, EventArgs e) {
    193       ITool tool = this.graphVisualizationInfoView.Controller.Tools.Where(t => t.Name == ControllerBase.SelectionToolName).First();
    194       tool.IsSuspended = true;
    195227      this.graphVisualizationInfoView.Controller.ActivateTool(ControllerBase.PanToolName);
    196228    }
Note: See TracChangeset for help on using the changeset viewer.