Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/13/12 19:08:05 (11 years ago)
Author:
jkarder
Message:

#1747:

  • added support to pan with the middle mouse button
  • removed pan button
File:
1 edited

Legend:

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

    r7259 r8000  
    2727using HeuristicLab.MainForm;
    2828using HeuristicLab.MainForm.WindowsForms;
     29using HeuristicLab.Netron.CustomTools;
    2930using Netron.Diagramming.Core;
    3031
     
    3334  [Content(typeof(OperatorGraph), true)]
    3435  public partial class OperatorGraphView : AsynchronousContentView {
     36    private ITool lastActiveTool;
     37
    3538    public OperatorGraphView() {
    3639      InitializeComponent();
     
    3942      this.graphVisualizationInfoView.Controller.Model.Selection.OnNewSelection += new EventHandler(Controller_SelectionChanged);
    4043      this.graphVisualizationInfoView.Controller.OnMouseDown += new EventHandler<MouseEventArgs>(Controller_OnMouseDown);
     44      this.graphVisualizationInfoView.Controller.ParentControl.MouseDown += new MouseEventHandler(ParentControl_MouseDown);
     45      this.graphVisualizationInfoView.Controller.ParentControl.MouseUp += new MouseEventHandler(ParentControl_MouseUp);
    4146      foreach (ITool tool in this.graphVisualizationInfoView.Controller.Tools) {
    4247        tool.OnToolActivate += new EventHandler<ToolEventArgs>(tool_OnToolActivate);
     
    6974      if (Content == null) {
    7075        selectButton.Enabled = false;
    71         panButton.Enabled = false;
    7276        relayoutButton.Enabled = false;
    7377        zoomToFitButton.Enabled = false;
     
    7983      } else {
    8084        selectButton.Enabled = true;
    81         panButton.Enabled = true;
    8285        relayoutButton.Enabled = true;
    8386        zoomToFitButton.Enabled = true;
     
    150153    }
    151154
     155    void ParentControl_MouseDown(object sender, MouseEventArgs e) {
     156      lastActiveTool = this.graphVisualizationInfoView.Controller.ActiveTool;
     157      if (e.Button == MouseButtons.Middle) {
     158        if (!(lastActiveTool is CustomPanTool)) this.graphVisualizationInfoView.Controller.ActivateTool(CustomPanTool.ToolName);
     159      }
     160    }
     161
     162    void ParentControl_MouseUp(object sender, MouseEventArgs e) {
     163      if (e.Button == MouseButtons.Middle) {
     164        if (lastActiveTool != null) this.graphVisualizationInfoView.Controller.ActivateTool(lastActiveTool.Name);
     165        else this.graphVisualizationInfoView.Controller.DeactivateAllTools();
     166      }
     167    }
     168
    152169    #region context menu
    153170    private void Controller_OnShowContextMenu(object sender, EntityMenuEventArgs e) {
     
    252269          button = this.selectButton;
    253270          break;
    254         case ControllerBase.PanToolName:
    255           button = this.panButton;
    256           break;
    257271        case ControllerBase.ConnectionToolName:
    258272          button = this.connectButton;
     
    268282      ITool tool = this.graphVisualizationInfoView.Controller.Tools.Where(t => t.Name == ControllerBase.SelectionToolName).First();
    269283      this.graphVisualizationInfoView.Controller.DeactivateAllTools();
    270     }
    271 
    272     private void panButton_Click(object sender, EventArgs e) {
    273       this.graphVisualizationInfoView.Controller.ActivateTool(ControllerBase.PanToolName);
    274284    }
    275285
Note: See TracChangeset for help on using the changeset viewer.