Changeset 3355


Ignore:
Timestamp:
04/15/10 16:07:38 (11 years ago)
Author:
mkommend
Message:

adapted OperatorGraphView to readyonly mechanism (ticket #973)

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/HeuristicLab.Netron-3.0.2672.12446/Controller.cs

    r2801 r3355  
    5656      }
    5757    }
     58
     59    public void RemoveTool(ITool tool) {
     60      if (tool == null)
     61        return;
     62      tool.Controller = null;
     63      registeredTools.Remove(tool);
     64
     65      IMouseListener mouseTool = tool as IMouseListener;
     66      if (mouseTool != null)
     67        mouseListeners.Remove(mouseTool);
     68      IKeyboardListener keyboardTool = tool as IKeyboardListener;
     69      if (keyboardTool != null)
     70        keyboardListeners.Remove(keyboardTool);
     71      IDragDropListener dragdropTool = tool as IDragDropListener;
     72      if (dragdropTool != null)
     73        dragdropListeners.Remove(dragdropTool);
     74
     75      tool.OnToolActivate -= new EventHandler<ToolEventArgs>(AddedTool_OnToolActivate);
     76      tool.OnToolDeactivate -= new EventHandler<ToolEventArgs>(AddedTool_OnToolDeactivate);
     77    }
    5878  }
    5979}
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Core/ControllerBase.cs

    r3184 r3355  
    155155    /// </summary>
    156156    private IView mView;
    157     private CollectionBase<IMouseListener> mouseListeners;
    158     private CollectionBase<IKeyboardListener> keyboardListeners;
    159     private CollectionBase<IDragDropListener> dragdropListeners;
    160     private IDiagramControl parentControl;
    161     private CollectionBase<ITool> registeredTools;
    162     private CollectionBase<IActivity> registeredActivity;
     157    protected CollectionBase<IMouseListener> mouseListeners;
     158    protected CollectionBase<IKeyboardListener> keyboardListeners;
     159    protected CollectionBase<IDragDropListener> dragdropListeners;
     160    protected IDiagramControl parentControl;
     161    protected CollectionBase<ITool> registeredTools;
     162    protected CollectionBase<IActivity> registeredActivity;
    163163
    164164    #endregion
     
    811811    /// <param name="e">ToolEventArgs</param>
    812812    // ------------------------------------------------------------------
    813     void AddedTool_OnToolDeactivate(object sender, ToolEventArgs e) {
     813    protected void AddedTool_OnToolDeactivate(object sender, ToolEventArgs e) {
    814814      ITool nextActiveToolInList = null;
    815815      if (this.activeTool == e.Properties) {
     
    833833    /// <param name="e">ToolEventArgs</param>
    834834    // ------------------------------------------------------------------
    835     void AddedTool_OnToolActivate(object sender, ToolEventArgs e) {
     835    protected void AddedTool_OnToolActivate(object sender, ToolEventArgs e) {
    836836      this.RaiseOnToolActivate(e);
    837837    }
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/GraphVisualizationInfoView.cs

    r3186 r3355  
    7474    }
    7575
     76    protected override void OnReadOnlyChanged() {
     77      base.OnReadOnlyChanged();
     78      this.SetEnableStateOfControls();
     79    }
     80
     81    private void SetEnableStateOfControls() {
     82      DeleteTool deleteTool = (DeleteTool) this.Controller.Tools.Where( t => t.Name == ControllerBase.DeleteToolName).FirstOrDefault();
     83      HeuristicLab.Netron.Controller controller = this.Controller as HeuristicLab.Netron.Controller;
     84      if (Content == null && deleteTool != null && controller != null)
     85        controller.RemoveTool(deleteTool);
     86      else {
     87        if (ReadOnly && deleteTool != null && controller != null)
     88          controller.RemoveTool(deleteTool);
     89        else if (!ReadOnly && deleteTool == null)
     90          this.Controller.AddTool(new DeleteTool(ControllerBase.DeleteToolName));
     91      }
     92    }
     93
    7694    private void UpdateContent() {
    7795      foreach (IOperatorShapeInfo shapeInfo in this.shapeInfoShapeMapping.FirstValues)
     
    82100      this.connectionConnectorsMapping.Clear();
    83101
    84       foreach (IOperatorShapeInfo shapeInfo in this.Content.OperatorShapeInfos)
    85         if (!this.shapeInfoShapeMapping.ContainsFirst(shapeInfo))
    86           this.AddShapeInfo(shapeInfo);
    87 
    88       foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> connection in this.Content.Connections)
    89         this.AddConnection(connection.Key.Key, connection.Key.Value, connection.Value);
    90 
    91       this.UpdateLayoutRoot();
     102      if (Content != null) {
     103        foreach (IOperatorShapeInfo shapeInfo in this.Content.OperatorShapeInfos)
     104          if (!this.shapeInfoShapeMapping.ContainsFirst(shapeInfo))
     105            this.AddShapeInfo(shapeInfo);
     106
     107        foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> connection in this.Content.Connections)
     108          this.AddConnection(connection.Key.Key, connection.Key.Value, connection.Value);
     109
     110        this.UpdateLayoutRoot();
     111      }
     112      this.SetEnableStateOfControls();
    92113    }
    93114
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphView.cs

    r3176 r3355  
    7272      if (createdVisualizationInfo)
    7373        this.graphVisualizationInfoView.RelayoutGraph();
    74     }
     74
     75      this.SetEnableStateOfControls();
     76    }
     77
     78    protected override void OnReadOnlyChanged() {
     79      base.OnReadOnlyChanged();
     80      this.SetEnableStateOfControls();
     81    }
     82
     83    private void SetEnableStateOfControls() {
     84      if (Content == null) {
     85        selectButton.Enabled = false;
     86        panButton.Enabled = false;
     87        relayoutButton.Enabled = false;
     88        zoomAreaButton.Enabled = false;
     89        zoomInButton.Enabled = false;
     90        zoomOutButton.Enabled = false;
     91        screenshotButton.Enabled = false;
     92        detailsViewHost.Enabled = false;
     93        graphVisualizationInfoView.ReadOnly = true;
     94        connectButton.Enabled = false;
     95       
     96      } else {
     97        selectButton.Enabled = true;
     98        panButton.Enabled = true;
     99        relayoutButton.Enabled = true;
     100        zoomAreaButton.Enabled = true;
     101        zoomInButton.Enabled = true;
     102        zoomOutButton.Enabled = true;
     103        screenshotButton.Enabled = true;
     104        detailsViewHost.Enabled = true;
     105        detailsViewHost.ReadOnly = ReadOnly;
     106        graphVisualizationInfoView.ReadOnly = ReadOnly;
     107        connectButton.Enabled = !ReadOnly;
     108      }
     109    }
    75110
    76111    private GraphVisualizationInfo VisualizationInfo {
     
    160195
    161196    private void initialOperatorToolStripMenuItem_Click(object sender, EventArgs e) {
    162       IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo;
    163       if (this.VisualizationInfo.InitialShape == shapeInfo)
    164         this.VisualizationInfo.InitialShape = null;
    165       else
    166         this.VisualizationInfo.InitialShape = shapeInfo;
     197      if (!ReadOnly) {
     198        IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo;
     199        if (this.VisualizationInfo.InitialShape == shapeInfo)
     200          this.VisualizationInfo.InitialShape = null;
     201        else
     202          this.VisualizationInfo.InitialShape = shapeInfo;
     203      }
    167204    }
    168205
    169206    private void breakPointToolStripMenuItem_Click(object sender, EventArgs e) {
    170       IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo;
    171       if (shapeInfo != null) {
    172         IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo);
    173         op.Breakpoint = !op.Breakpoint;
     207      if (!ReadOnly) {
     208        IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo;
     209        if (shapeInfo != null) {
     210          IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo);
     211          op.Breakpoint = !op.Breakpoint;
     212        }
    174213      }
    175214    }
     
    179218    private void OperatorGraphView_DragEnter(object sender, DragEventArgs e) {
    180219      e.Effect = DragDropEffects.None;
     220      if (ReadOnly)
     221        return;
    181222      Type type = e.Data.GetData("Type") as Type;
    182223      if ((type != null) && (typeof(IOperator).IsAssignableFrom(type))) {
Note: See TracChangeset for help on using the changeset viewer.