Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2934 for trunk/sources


Ignore:
Timestamp:
03/05/10 12:37:59 (14 years ago)
Author:
mkommend
Message:

added parameters, corrected drag and drop position (ticket #867)

Location:
trunk/sources
Files:
2 added
13 edited

Legend:

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

    r2803 r2934  
    8282  </ItemGroup>
    8383  <ItemGroup>
     84    <Compile Include="ExpandableIconMaterial.cs" />
    8485    <Compile Include="NetronVisualization.cs">
    8586      <SubType>Component</SubType>
  • trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Utils/Selection.cs

    r2898 r2934  
    153153      g.SmoothingMode = SmoothingMode.HighQuality;
    154154      Bundle bundle = new Bundle(SelectedItems.Copy());
    155       return ImageExporter.FromBundle(bundle, g);
     155      return ImageExporter.FromBundle(bundle,g);
    156156    }
    157157
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/BidirectionalLookup.cs

    r2853 r2934  
    2424using System.Linq;
    2525using System.Text;
     26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    2627
    2728namespace HeuristicLab.Operators.Views.GraphVisualization {
    2829  public class BidirectionalLookup<TFirst, TSecond> {
     30    [Storable]
    2931    private Dictionary<TFirst, TSecond> firstToSecond;
     32    [Storable]
    3033    private Dictionary<TSecond, TFirst> secondToFirst;
    3134
     
    121124      this.secondToFirst.Clear();
    122125    }
    123 
    124 
    125126    #endregion
    126127  }
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/GraphVisualizationInfoView.cs

    r2917 r2934  
    4242  [Content(typeof(GraphVisualizationInfo), false)]
    4343  public partial class GraphVisualizationInfoView : ContentView {
    44     private BidirectionalLookup<IShapeInfo, IShape> shapeInfoShapeMapping;
    45     private BidirectionalLookup<IShapeInfo, INotifyObservableDictionaryItemsChanged<string, IShapeInfo>> shapeInfoConnectionsMapping;
     44    private BidirectionalLookup<IOperatorShapeInfo, IShape> shapeInfoShapeMapping;
     45    private BidirectionalLookup<IOperatorShapeInfo, INotifyObservableDictionaryItemsChanged<string, IOperatorShapeInfo>> shapeInfoConnectionsMapping;
    4646    private BidirectionalLookup<IConnection, KeyValuePair<IConnector, IConnector>> connectionConnectorsMapping;
    4747
     
    5050      InitializeComponent();
    5151      this.causedUpdateOfShapeInfo = false;
    52       this.shapeInfoShapeMapping = new BidirectionalLookup<IShapeInfo, IShape>();
    53       this.shapeInfoConnectionsMapping = new BidirectionalLookup<IShapeInfo, INotifyObservableDictionaryItemsChanged<string, IShapeInfo>>();
     52      this.shapeInfoShapeMapping = new BidirectionalLookup<IOperatorShapeInfo, IShape>();
     53      this.shapeInfoConnectionsMapping = new BidirectionalLookup<IOperatorShapeInfo, INotifyObservableDictionaryItemsChanged<string, IOperatorShapeInfo>>();
    5454      this.connectionConnectorsMapping = new BidirectionalLookup<IConnection, KeyValuePair<IConnector, IConnector>>();
    5555    }
     
    7575
    7676    private void UpdateContent() {
    77       foreach (IShapeInfo shapeInfo in this.shapeInfoShapeMapping.FirstValues)
     77      foreach (IOperatorShapeInfo shapeInfo in this.shapeInfoShapeMapping.FirstValues)
    7878        this.RemoveShapeInfo(shapeInfo);
    7979
     
    8282      this.connectionConnectorsMapping.Clear();
    8383
    84       foreach (IShapeInfo shapeInfo in this.Content.ShapeInfos)
     84      foreach (IOperatorShapeInfo shapeInfo in this.Content.OperatorShapeInfos)
    8585        if (!this.shapeInfoShapeMapping.ContainsFirst(shapeInfo))
    8686          this.AddShapeInfo(shapeInfo);
    8787
    88       foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> connection in this.Content.Connections)
     88      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> connection in this.Content.Connections)
    8989        this.AddConnection(connection.Key.Key, connection.Key.Value, connection.Value);
    9090
     
    9393
    9494    private void UpdateLayoutRoot() {
    95       IShapeInfo shapeInfo = this.Content.InitialShape;
     95      IOperatorShapeInfo shapeInfo = this.Content.InitialShape;
    9696      if (shapeInfo != null)
    9797        this.graphVisualization.Controller.Model.LayoutRoot = this.shapeInfoShapeMapping.GetByFirst(shapeInfo);
     
    107107      base.RegisterContentEvents();
    108108      this.Content.InitialShapeChanged += new EventHandler(VisualizationInfo_InitialShapeChanged);
    109       this.Content.ObserveableShapeInfos.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsAdded);
    110       this.Content.ObserveableShapeInfos.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsRemoved);
    111       this.Content.ObserveableShapeInfos.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_CollectionReset);
    112 
    113       this.Content.ObservableConnections.ItemsAdded += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsAdded);
    114       this.Content.ObservableConnections.ItemsRemoved += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsRemoved);
    115       this.Content.ObservableConnections.ItemsReplaced += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsReplaced);
    116       this.Content.ObservableConnections.CollectionReset += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_CollectionReset);
     109      this.Content.ObserveableShapeInfos.ItemsAdded += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_ItemsAdded);
     110      this.Content.ObserveableShapeInfos.ItemsRemoved += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_ItemsRemoved);
     111      this.Content.ObserveableShapeInfos.CollectionReset += new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_CollectionReset);
     112
     113      this.Content.ObservableConnections.ItemsAdded += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsAdded);
     114      this.Content.ObservableConnections.ItemsRemoved += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsRemoved);
     115      this.Content.ObservableConnections.ItemsReplaced += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsReplaced);
     116      this.Content.ObservableConnections.CollectionReset += new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_CollectionReset);
    117117    }
    118118
     
    120120      base.DeregisterContentEvents();
    121121      this.Content.InitialShapeChanged -= new EventHandler(VisualizationInfo_InitialShapeChanged);
    122       this.Content.ObserveableShapeInfos.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsAdded);
    123       this.Content.ObserveableShapeInfos.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_ItemsRemoved);
    124       this.Content.ObserveableShapeInfos.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IShapeInfo>(ShapeInfos_CollectionReset);
    125 
    126       this.Content.ObservableConnections.ItemsAdded -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsAdded);
    127       this.Content.ObservableConnections.ItemsRemoved -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsRemoved);
    128       this.Content.ObservableConnections.ItemsReplaced -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_ItemsReplaced);
    129       this.Content.ObservableConnections.CollectionReset -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>>(Connections_CollectionReset);
    130     }
    131 
    132     private void ShapeInfos_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IShapeInfo> e) {
    133       foreach (IShapeInfo shapeInfo in e.OldItems)
     122      this.Content.ObserveableShapeInfos.ItemsAdded -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_ItemsAdded);
     123      this.Content.ObserveableShapeInfos.ItemsRemoved -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_ItemsRemoved);
     124      this.Content.ObserveableShapeInfos.CollectionReset -= new HeuristicLab.Collections.CollectionItemsChangedEventHandler<IOperatorShapeInfo>(ShapeInfos_CollectionReset);
     125
     126      this.Content.ObservableConnections.ItemsAdded -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsAdded);
     127      this.Content.ObservableConnections.ItemsRemoved -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsRemoved);
     128      this.Content.ObservableConnections.ItemsReplaced -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_ItemsReplaced);
     129      this.Content.ObservableConnections.CollectionReset -= new CollectionItemsChangedEventHandler<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>>(Connections_CollectionReset);
     130    }
     131
     132    private void ShapeInfos_CollectionReset(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IOperatorShapeInfo> e) {
     133      foreach (IOperatorShapeInfo shapeInfo in e.OldItems)
    134134        this.RemoveShapeInfo(shapeInfo);
    135       foreach (IShapeInfo shapeInfo in e.Items)
     135      foreach (IOperatorShapeInfo shapeInfo in e.Items)
    136136        this.AddShapeInfo(shapeInfo);
    137137    }
    138138
    139     private void ShapeInfos_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IShapeInfo> e) {
    140       foreach (IShapeInfo shapeInfo in e.Items)
     139    private void ShapeInfos_ItemsAdded(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IOperatorShapeInfo> e) {
     140      foreach (IOperatorShapeInfo shapeInfo in e.Items)
    141141        this.AddShapeInfo(shapeInfo);
    142142    }
    143143
    144     private void ShapeInfos_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IShapeInfo> e) {
    145       foreach (IShapeInfo shapeInfo in e.Items)
     144    private void ShapeInfos_ItemsRemoved(object sender, HeuristicLab.Collections.CollectionItemsChangedEventArgs<IOperatorShapeInfo> e) {
     145      foreach (IOperatorShapeInfo shapeInfo in e.Items)
    146146        this.RemoveShapeInfo(shapeInfo);
    147147    }
    148148
    149     private void AddShapeInfo(IShapeInfo shapeInfo) {
     149    private void AddShapeInfo(IOperatorShapeInfo shapeInfo) {
    150150      this.RegisterShapeInfoEvents(shapeInfo);
    151151
     
    158158    }
    159159
    160     private void RemoveShapeInfo(IShapeInfo shapeInfo) {
     160    private void RemoveShapeInfo(IOperatorShapeInfo shapeInfo) {
    161161      this.DeregisterShapeInfoEvents(shapeInfo);
    162162      IShape shape = this.shapeInfoShapeMapping.GetByFirst(shapeInfo);
     
    179179
    180180    private void RegisterShapeInfoEvents(IShapeInfo shapeInfo) {
    181       shapeInfo.Changed += new ChangedEventHandler(shapeInfo_Changed);
     181      shapeInfo.Changed += new EventHandler(shapeInfo_Changed);
    182182    }
    183183
    184184    private void DeregisterShapeInfoEvents(IShapeInfo shapeInfo) {
    185       shapeInfo.Changed -= new ChangedEventHandler(shapeInfo_Changed);
    186     }
    187 
    188     private void Connections_CollectionReset(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>> e) {
     185      shapeInfo.Changed -= new EventHandler(shapeInfo_Changed);
     186    }
     187
     188    private void Connections_CollectionReset(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>> e) {
    189189      IConnection connection;
    190       foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items) {
     190      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items) {
    191191        connection = this.GetConnection(pair.Key.Key, pair.Key.Value);
    192192        this.RemoveConnection(connection);
    193193      }
    194       foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items)
     194      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items)
    195195        this.AddConnection(pair.Key.Key, pair.Key.Value, pair.Value);
    196196    }
    197197
    198     private void Connections_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>> e) {
     198    private void Connections_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>> e) {
    199199      IConnection connection;
    200       foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items) {
     200      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items) {
    201201        connection = this.GetConnection(pair.Key.Key, pair.Key.Value);
    202202        this.RemoveConnection(connection);
    203203      }
    204       foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items)
     204      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items)
    205205        this.AddConnection(pair.Key.Key, pair.Key.Value, pair.Value);
    206206    }
    207207
    208     private void Connections_ItemsAdded(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>> e) {
    209       foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items)
     208    private void Connections_ItemsAdded(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>> e) {
     209      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items)
    210210        this.AddConnection(pair.Key.Key, pair.Key.Value, pair.Value);
    211211    }
    212212
    213     private void Connections_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>> e) {
     213    private void Connections_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>> e) {
    214214      IConnection connection;
    215       foreach (KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo> pair in e.Items) {
     215      foreach (KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> pair in e.Items) {
    216216        connection = this.GetConnection(pair.Key.Key, pair.Key.Value);
    217217        this.RemoveConnection(connection);
     
    219219    }
    220220
    221     private void AddConnection(IShapeInfo shapeInfoFrom, string connectorName, IShapeInfo shapeInfoTo) {
     221    private void AddConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName, IOperatorShapeInfo shapeInfoTo) {
    222222      IShape shapeFrom = this.shapeInfoShapeMapping.GetByFirst(shapeInfoFrom);
    223223      IShape shapeTo = this.shapeInfoShapeMapping.GetByFirst(shapeInfoTo);
     
    234234    }
    235235
    236     private IConnection GetConnection(IShapeInfo shapeInfoFrom, string connectorName) {
     236    private IConnection GetConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName) {
    237237      IShape shape = this.shapeInfoShapeMapping.GetByFirst(shapeInfoFrom);
    238238      IConnector connector = shape.Connectors.Where(c => c.Name == connectorName).First();
     
    245245    }
    246246
    247     private void ChangeConnection(IShapeInfo shapeInfoFrom, string connectorName, IShapeInfo shapeInfoTo) {
     247    private void ChangeConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName, IOperatorShapeInfo shapeInfoTo) {
    248248      IConnection connection = this.GetConnection(shapeInfoFrom, connectorName);
    249249      IShape shapeTo = this.shapeInfoShapeMapping.GetByFirst(shapeInfoFrom);
     
    272272
    273273
    274     private void shapeInfo_Changed(object sender, ChangedEventArgs e) {
     274    private void shapeInfo_Changed(object sender, EventArgs e) {
    275275      if (this.causedUpdateOfShapeInfo)
    276276        return;
    277277
    278       IShapeInfo shapeInfo = (IShapeInfo)sender;
     278      this.causedUpdateOfShapeInfo = true;
     279      IOperatorShapeInfo shapeInfo = (IOperatorShapeInfo)sender;
    279280      IShape shape = this.shapeInfoShapeMapping.GetByFirst(shapeInfo);
    280281      shapeInfo.UpdateShape(shape);
    281282      shape.Invalidate();
     283      this.causedUpdateOfShapeInfo = false;
    282284    }
    283285
    284286
    285287    private void shape_OnEntityChange(object sender, EntityEventArgs e) {
     288      if (this.causedUpdateOfShapeInfo)
     289        return;
     290
    286291      this.causedUpdateOfShapeInfo = true;
    287292      IShape shape = e.Entity as IShape;
    288       IShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(shape);
    289 
     293      IOperatorShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(shape);
    290294      shapeInfo.Location = shape.Location;
    291       shapeInfo.Size = new Size(shape.Width, shape.Height);
    292 
     295
     296      OperatorShape operatorShape = shape as OperatorShape;
     297      if (operatorShape != null)
     298        shapeInfo.Collapsed = operatorShape.Collapsed;
     299     
    293300      this.graphVisualization.Invalidate();
    294301      this.causedUpdateOfShapeInfo = false;
     
    302309        this.RemoveConnection(connection); //is added again by the model events
    303310
    304         if (connectorFrom != null && connectorTo != null) {
     311        if (connectorFrom != null && connectorTo != null && connectorFrom.Name != "Predecessor") {
    305312          IShape shapeFrom = (IShape)connectorFrom.Parent;
    306313          IShape shapeTo = (IShape)connectorTo.Parent;
    307           IShapeInfo shapeInfoFrom = this.shapeInfoShapeMapping.GetBySecond(shapeFrom);
    308           IShapeInfo shapeInfoTo = this.shapeInfoShapeMapping.GetBySecond(shapeTo);
     314          IOperatorShapeInfo shapeInfoFrom = this.shapeInfoShapeMapping.GetBySecond(shapeFrom);
     315          IOperatorShapeInfo shapeInfoTo = this.shapeInfoShapeMapping.GetBySecond(shapeTo);
    309316          string connectorName = connectorFrom.Name;
    310317
     
    317324      IShape shape = e.Entity as IShape;
    318325      if (shape != null && this.shapeInfoShapeMapping.ContainsSecond(shape)) {
    319         IShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(shape);
     326        IOperatorShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(shape);
    320327        this.Content.RemoveShapeInfo(shapeInfo);
    321328      }
     
    324331      if (connection != null && this.connectionConnectorsMapping.ContainsFirst(connection)) {
    325332        IShape parentShape = (IShape)connection.From.AttachedTo.Parent;
    326         IShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(parentShape);
     333        IOperatorShapeInfo shapeInfo = this.shapeInfoShapeMapping.GetBySecond(parentShape);
    327334        string connectorName = connection.From.AttachedTo.Name;
    328335
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/HeuristicLab.Operators.Views.GraphVisualization-3.3.csproj

    r2900 r2934  
    104104      <DependentUpon>GraphVisualizationInfoView.cs</DependentUpon>
    105105    </Compile>
     106    <Compile Include="Model\IOperatorShapeInfo.cs" />
    106107    <Compile Include="Model\OperatorShapeInfo.cs" />
    107108    <Compile Include="Model\GraphVisualizationInfo.cs" />
     
    163164      <Name>HeuristicLab.Parameters-3.3</Name>
    164165    </ProjectReference>
     166    <ProjectReference Include="..\..\HeuristicLab.Persistence\3.3\HeuristicLab.Persistence-3.3.csproj">
     167      <Project>{102BC7D3-0EF9-439C-8F6D-96FF0FDB8E1B}</Project>
     168      <Name>HeuristicLab.Persistence-3.3</Name>
     169    </ProjectReference>
    165170    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\HeuristicLab.PluginInfrastructure.csproj">
    166171      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/Model/GraphVisualizationInfo.cs

    r2896 r2934  
    2828using System.Drawing;
    2929using HeuristicLab.Collections;
     30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3031
    3132namespace HeuristicLab.Operators.Views.GraphVisualization {
    3233  public sealed class GraphVisualizationInfo : DeepCloneable {
    33     private BidirectionalLookup<IOperator, IShapeInfo> shapeInfoMapping;
     34    private BidirectionalLookup<IOperator, IOperatorShapeInfo> operatorShapeInfoMapping;
     35    [Storable]
     36    private BidirectionalLookup<IOperator, IOperatorShapeInfo> OperatorShapeInfoMappingStore {
     37      get { return this.operatorShapeInfoMapping; }
     38      set {
     39        foreach (KeyValuePair<IOperator, IOperatorShapeInfo> pair in value.FirstEnumerable)
     40          this.AddShapeInfo(pair.Key, pair.Value);
     41      }
     42    }
     43
    3444    private BidirectionalLookup<IOperator, IObservableKeyedCollection<string, IParameter>> operatorParameterCollectionMapping;
    35     private Dictionary<IValueParameter<IOperator>, IOperator> parameterOperatorMapping;
     45    private Dictionary<IParameter, IOperator> parameterOperatorMapping;
    3646
    3747    private GraphVisualizationInfo() {
    38       this.shapeInfoMapping = new BidirectionalLookup<IOperator, IShapeInfo>();
     48      this.operatorShapeInfoMapping = new BidirectionalLookup<IOperator, IOperatorShapeInfo>();
    3949      this.operatorParameterCollectionMapping = new BidirectionalLookup<IOperator, IObservableKeyedCollection<string, IParameter>>();
    40       this.parameterOperatorMapping = new Dictionary<IValueParameter<IOperator>, IOperator>();
    41 
    42       this.shapeInfos = new ObservableSet<IShapeInfo>();
    43       this.connections = new ObservableDictionary<KeyValuePair<IShapeInfo, string>, IShapeInfo>();
     50      this.parameterOperatorMapping = new Dictionary<IParameter, IOperator>();
     51
     52      this.shapeInfos = new ObservableSet<IOperatorShapeInfo>();
     53      this.connections = new ObservableDictionary<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>();
    4454    }
    4555
     
    5363
    5464      foreach (IOperator op in operatorGraph.Operators)
    55         if (!this.shapeInfoMapping.ContainsFirst(op))
     65        if (!this.operatorShapeInfoMapping.ContainsFirst(op))
    5666          this.AddOperator(op);
    5767
     
    6575
    6676    private void UpdateInitialShape() {
    67       OperatorShapeInfo old = this.oldInitialShape as OperatorShapeInfo;
     77      IOperatorShapeInfo old = this.oldInitialShape as OperatorShapeInfo;
    6878      if (old != null)
    69         old.HeadColor = oldInitialShapeColor;
     79        old.Color = oldInitialShapeColor;
    7080
    7181      OperatorShapeInfo newInitialShapeInfo = this.InitialShape as OperatorShapeInfo;
    7282      if (newInitialShapeInfo != null) {
    73         oldInitialShapeColor = newInitialShapeInfo.HeadColor;
    74         newInitialShapeInfo.HeadColor = Color.LightGreen;
     83        oldInitialShapeColor = newInitialShapeInfo.Color;
     84        newInitialShapeInfo.Color = Color.LightGreen;
    7585      }
    7686
     
    8090    }
    8191
    82     private IShapeInfo oldInitialShape;
     92    [Storable]
     93    private IOperatorShapeInfo oldInitialShape;
     94    [Storable]
    8395    private Color oldInitialShapeColor;
    84     public IShapeInfo InitialShape {
     96    public IOperatorShapeInfo InitialShape {
    8597      get {
    8698        IOperator op = this.operatorGraph.InitialOperator;
    8799        if (op == null)
    88100          return null;
    89         return this.shapeInfoMapping.GetByFirst(op);
     101        return this.operatorShapeInfoMapping.GetByFirst(op);
    90102      }
    91103      set {
     
    93105          this.OperatorGraph.InitialOperator = null;
    94106        else
    95           this.OperatorGraph.InitialOperator = this.shapeInfoMapping.GetBySecond(value);
    96       }
    97     }
    98 
     107          this.OperatorGraph.InitialOperator = this.operatorShapeInfoMapping.GetBySecond(value);
     108      }
     109    }
     110
     111    [Storable]
    99112    private OperatorGraph operatorGraph;
    100113    public OperatorGraph OperatorGraph {
     
    102115    }
    103116
    104     private ObservableSet<IShapeInfo> shapeInfos;
    105     public INotifyObservableCollectionItemsChanged<IShapeInfo> ObserveableShapeInfos {
     117    private ObservableSet<IOperatorShapeInfo> shapeInfos;
     118    public INotifyObservableCollectionItemsChanged<IOperatorShapeInfo> ObserveableShapeInfos {
    106119      get { return this.shapeInfos; }
    107120    }
    108     public IEnumerable<IShapeInfo> ShapeInfos {
     121    public IEnumerable<IOperatorShapeInfo> OperatorShapeInfos {
    109122      get { return this.shapeInfos; }
    110123    }
    111     public IOperator GetOperatorForShapeInfo(IShapeInfo shapeInfo) {
    112       return this.shapeInfoMapping.GetBySecond(shapeInfo);
    113     }
    114 
    115     private ObservableDictionary<KeyValuePair<IShapeInfo, string>, IShapeInfo> connections;
    116     public INotifyObservableDictionaryItemsChanged<KeyValuePair<IShapeInfo, string>, IShapeInfo> ObservableConnections {
     124    public IOperator GetOperatorForShapeInfo(IOperatorShapeInfo shapeInfo) {
     125      return this.operatorShapeInfoMapping.GetBySecond(shapeInfo);
     126    }
     127
     128    [Storable]
     129    private ObservableDictionary<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> connections;
     130    public INotifyObservableDictionaryItemsChanged<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo> ObservableConnections {
    117131      get { return this.connections; }
    118132    }
    119     public IEnumerable<KeyValuePair<KeyValuePair<IShapeInfo, string>, IShapeInfo>> Connections {
     133    public IEnumerable<KeyValuePair<KeyValuePair<IOperatorShapeInfo, string>, IOperatorShapeInfo>> Connections {
    120134      get { return this.connections; }
    121135    }
    122136
    123137    #region methods to manipulate operatorgraph by the shape info
    124     internal void AddShapeInfo(IOperator op, IShapeInfo shapeInfo) {
     138    internal void AddShapeInfo(IOperator op, IOperatorShapeInfo shapeInfo) {
    125139      this.RegisterOperatorEvents(op);
    126140      this.operatorParameterCollectionMapping.Add(op, op.Parameters);
    127       this.shapeInfoMapping.Add(op, shapeInfo);
     141      this.operatorShapeInfoMapping.Add(op, shapeInfo);
    128142      this.shapeInfos.Add(shapeInfo);
    129143
     
    131145        this.AddParameter(op, param);
    132146
    133       this.operatorGraph.Operators.Add(op);
    134     }
    135 
    136     internal void RemoveShapeInfo(IShapeInfo shapeInfo) {
    137       IOperator op = this.shapeInfoMapping.GetBySecond(shapeInfo);
     147      if (!this.operatorGraph.Operators.Contains(op))
     148        this.operatorGraph.Operators.Add(op);
     149    }
     150
     151    internal void RemoveShapeInfo(IOperatorShapeInfo shapeInfo) {
     152      IOperator op = this.operatorShapeInfoMapping.GetBySecond(shapeInfo);
    138153      this.operatorGraph.Operators.Remove(op);
    139154    }
    140155
    141     internal void AddConnection(IShapeInfo shapeInfoFrom, string connectorName, IShapeInfo shapeInfoTo) {
    142       IOperator opFrom = this.shapeInfoMapping.GetBySecond(shapeInfoFrom);
    143       IOperator opTo = this.shapeInfoMapping.GetBySecond(shapeInfoTo);
     156    internal void AddConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName, IOperatorShapeInfo shapeInfoTo) {
     157      IOperator opFrom = this.operatorShapeInfoMapping.GetBySecond(shapeInfoFrom);
     158      IOperator opTo = this.operatorShapeInfoMapping.GetBySecond(shapeInfoTo);
    144159
    145160      IValueParameter<IOperator> param = (IValueParameter<IOperator>)opFrom.Parameters[connectorName];
     
    147162    }
    148163
    149     internal void ChangeConnection(IShapeInfo shapeInfoFrom, string connectorName, IShapeInfo shapeInfoTo) {
    150       IOperator opFrom = this.shapeInfoMapping.GetBySecond(shapeInfoFrom);
    151       IOperator opTo = this.shapeInfoMapping.GetBySecond(shapeInfoTo);
     164    internal void ChangeConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName, IOperatorShapeInfo shapeInfoTo) {
     165      IOperator opFrom = this.operatorShapeInfoMapping.GetBySecond(shapeInfoFrom);
     166      IOperator opTo = this.operatorShapeInfoMapping.GetBySecond(shapeInfoTo);
    152167
    153168      IValueParameter<IOperator> param = (IValueParameter<IOperator>)opFrom.Parameters[connectorName];
     
    155170    }
    156171
    157     internal void RemoveConnection(IShapeInfo shapeInfoFrom, string connectorName) {
    158       IOperator opFrom = this.shapeInfoMapping.GetBySecond(shapeInfoFrom);
     172    internal void RemoveConnection(IOperatorShapeInfo shapeInfoFrom, string connectorName) {
     173      IOperator opFrom = this.operatorShapeInfoMapping.GetBySecond(shapeInfoFrom);
    159174      IValueParameter<IOperator> param = (IValueParameter<IOperator>)opFrom.Parameters[connectorName];
    160175      param.Value = null;
     
    164179    #region operator events
    165180    private void AddOperator(IOperator op) {
    166       if (!this.shapeInfoMapping.ContainsFirst(op)) {
     181      if (!this.operatorShapeInfoMapping.ContainsFirst(op)) {
    167182        this.RegisterOperatorEvents(op);
    168         IShapeInfo shapeInfo = Factory.CreateShapeInfo(op);
     183        IOperatorShapeInfo shapeInfo = Factory.CreateOperatorShapeInfo(op);
    169184        this.operatorParameterCollectionMapping.Add(op, op.Parameters);
    170         this.shapeInfoMapping.Add(op, shapeInfo);
     185        this.operatorShapeInfoMapping.Add(op, shapeInfo);
    171186        foreach (IParameter param in op.Parameters)
    172187          this.AddParameter(op, param);
     
    181196        this.RemoveParameter(op, param);
    182197
    183       IShapeInfo shapeInfo = this.shapeInfoMapping.GetByFirst(op);
     198      IOperatorShapeInfo shapeInfo = this.operatorShapeInfoMapping.GetByFirst(op);
    184199      this.operatorParameterCollectionMapping.RemoveByFirst(op);
    185       this.shapeInfoMapping.RemoveByFirst(op);
     200      this.operatorShapeInfoMapping.RemoveByFirst(op);
    186201      this.shapeInfos.Remove(shapeInfo);
    187202    }
     
    189204    private void OperatorNameChanged(object sender, EventArgs e) {
    190205      IOperator op = (IOperator)sender;
    191       IShapeInfo shapeInfo = this.shapeInfoMapping.GetByFirst(op);
    192       OperatorShapeInfo operatorShapeInfo = shapeInfo as OperatorShapeInfo;
    193       if (operatorShapeInfo != null)
    194         operatorShapeInfo.Title = op.Name;
     206      IOperatorShapeInfo operatorShapeInfo = this.operatorShapeInfoMapping.GetByFirst(op);
     207      operatorShapeInfo.Title = op.Name;
    195208    }
    196209
     
    229242    #region parameter events
    230243    private void AddParameter(IOperator op, IParameter param) {
     244      this.parameterOperatorMapping.Add(param, op);
    231245      IValueParameter<IOperator> opParam = param as IValueParameter<IOperator>;
    232246      if (opParam != null) {
    233247        this.RegisterOperatorParameterEvents(opParam);
    234         this.parameterOperatorMapping.Add(opParam, op);
    235         IShapeInfo shapeInfo = this.shapeInfoMapping.GetByFirst(op);
     248        IOperatorShapeInfo shapeInfo = this.operatorShapeInfoMapping.GetByFirst(op);
    236249        shapeInfo.AddConnector(param.Name);
    237250
    238251        if (opParam.Value != null) {
    239           if (!this.shapeInfoMapping.ContainsFirst(opParam.Value))
     252          if (!this.operatorShapeInfoMapping.ContainsFirst(opParam.Value))
    240253            this.AddOperator(opParam.Value);
    241           this.connections.Add(new KeyValuePair<IShapeInfo, string>(shapeInfo, param.Name), this.shapeInfoMapping.GetByFirst(opParam.Value));
     254          this.connections.Add(new KeyValuePair<IOperatorShapeInfo, string>(shapeInfo, param.Name), this.operatorShapeInfoMapping.GetByFirst(opParam.Value));
    242255        }
    243       }
     256      } else
     257        this.RegisterParameterEvents(param);
    244258    }
    245259
     
    248262      if (opParam != null) {
    249263        this.DeregisterOperatorParameterEvents(opParam);
    250         this.parameterOperatorMapping.Remove(opParam);
    251         IShapeInfo shapeInfo = this.shapeInfoMapping.GetByFirst(op);
    252 
    253         this.connections.Remove(new KeyValuePair<IShapeInfo, string>(shapeInfo, param.Name));
     264        IOperatorShapeInfo shapeInfo = this.operatorShapeInfoMapping.GetByFirst(op);
     265        this.connections.Remove(new KeyValuePair<IOperatorShapeInfo, string>(shapeInfo, param.Name));
    254266        shapeInfo.RemoveConnector(param.Name);
    255       }
     267      } else
     268        this.DeregisterParameterEvents(param);
     269
     270      this.parameterOperatorMapping.Remove(param);
    256271    }
    257272
     
    260275      if (opParam != null) {
    261276        IOperator op = this.parameterOperatorMapping[opParam];
    262         IShapeInfo shapeInfo = this.shapeInfoMapping.GetByFirst(op);
    263         KeyValuePair<IShapeInfo, string> connectionFrom = new KeyValuePair<IShapeInfo, string>(shapeInfo, opParam.Name);
     277        IOperatorShapeInfo shapeInfo = this.operatorShapeInfoMapping.GetByFirst(op);
     278        KeyValuePair<IOperatorShapeInfo, string> connectionFrom = new KeyValuePair<IOperatorShapeInfo, string>(shapeInfo, opParam.Name);
    264279
    265280        if (opParam.Value == null)
    266281          this.connections.Remove(connectionFrom);
    267282        else {
    268           if (!this.shapeInfoMapping.ContainsFirst(opParam.Value))
     283          if (!this.operatorShapeInfoMapping.ContainsFirst(opParam.Value))
    269284            this.AddOperator(opParam.Value);
    270           this.connections[connectionFrom] = this.shapeInfoMapping.GetByFirst(opParam.Value);
     285          this.connections[connectionFrom] = this.operatorShapeInfoMapping.GetByFirst(opParam.Value);
    271286        }
    272287      }
     
    278293      foreach (IParameter param in e.Items)
    279294        AddParameter(op, param);
     295      this.UpdateParameterLabels(op);
    280296    }
    281297    private void Parameters_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IParameter> e) {
     
    284300      foreach (IParameter param in e.Items)
    285301        RemoveParameter(op, param);
     302      this.UpdateParameterLabels(op);
    286303    }
    287304    private void Parameters_ItemsReplaced(object sender, CollectionItemsChangedEventArgs<IParameter> e) {
     
    292309      foreach (IParameter param in e.Items)
    293310        AddParameter(op, param);
     311      this.UpdateParameterLabels(op);
    294312    }
    295313    private void Parameters_CollectionReset(object sender, CollectionItemsChangedEventArgs<IParameter> e) {
     
    300318      foreach (IParameter param in e.Items)
    301319        AddParameter(op, param);
     320      this.UpdateParameterLabels(op);
    302321    }
    303322
     
    307326    private void DeregisterOperatorParameterEvents(IValueParameter<IOperator> opParam) {
    308327      opParam.ValueChanged -= new EventHandler(opParam_ValueChanged);
     328    }
     329    private void RegisterParameterEvents(IParameter param) {
     330      param.ToStringChanged += new EventHandler(param_ToStringChanged);
     331      param.NameChanged += new EventHandler(param_NameChanged);
     332    }
     333    private void DeregisterParameterEvents(IParameter param) {
     334      param.ToStringChanged -= new EventHandler(param_ToStringChanged);
     335      param.NameChanged -= new EventHandler(param_NameChanged);
     336    }
     337
     338    private void param_NameChanged(object sender, EventArgs e) {
     339      IParameter param = (IParameter)sender;
     340      IOperator op = this.parameterOperatorMapping[param];
     341      this.UpdateParameterLabels(op);
     342    }
     343    private void param_ToStringChanged(object sender, EventArgs e) {
     344      IParameter param = (IParameter)sender;
     345      IOperator op = this.parameterOperatorMapping[param];
     346      this.UpdateParameterLabels(op);
     347    }
     348
     349    private void UpdateParameterLabels(IOperator op) {
     350      IEnumerable<IParameter> parameters = op.Parameters.Where(p => !(p is IValueParameter<IOperator>));
     351      IOperatorShapeInfo operatorShapeInfo = this.operatorShapeInfoMapping.GetByFirst(op);
     352      if (parameters.Count() > 0)
     353        operatorShapeInfo.UpdateLabels(parameters.Select(p => p.ToString()));
     354      else
     355        operatorShapeInfo.UpdateLabels(new List<string>());
    309356    }
    310357    #endregion
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/Model/IShapeInfo.cs

    r2868 r2934  
    3333    Type ShapeType { get; }
    3434    Point Location { get; set; }
    35     Size Size { get; set; }
    36 
    37     void AddConnector(string connectorName);
    38     void RemoveConnector(string connectorName);
    3935
    4036    IShape CreateShape();
    4137    void UpdateShape(IShape shape);
     38
     39    event EventHandler Changed;
    4240  }
    4341}
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/Model/OperatorShape.cs

    r2872 r2934  
    2626using Netron.Diagramming.Core;
    2727using System.Drawing;
     28using System.Drawing.Drawing2D;
     29using HeuristicLab.Netron;
    2830
    2931namespace HeuristicLab.Operators.Views.GraphVisualization {
    30   public class OperatorShape : ClassShape {
    31 
     32  public class OperatorShape : ComplexShapeBase {
     33    private static int LABEL_HEIGHT = 16;
     34    private static int LABEL_WIDTH = 180;
     35    private static int LABEL_SPACING = 3;
     36    private static int HEADER_HEIGHT = 30;
     37
     38    private ExpandableIconMaterial expandIconMaterial;
    3239    public OperatorShape()
    3340      : base() {
     41      this.Resizable = false;
    3442      this.additionalConnectors = new List<IConnector>();
    35     }
    36 
     43      this.labels = new List<string>();
     44    }
     45
     46    public override string EntityName {
     47      get { return "Operator Shape"; }
     48    }
     49
     50    public bool Collapsed {
     51      get { return this.expandIconMaterial.Collapsed; }
     52      set {
     53        if (this.expandIconMaterial.Collapsed != value)
     54          this.expandIconMaterial.Collapsed = value;
     55      }
     56    }
     57
     58    private Color color;
     59    public Color Color {
     60      get { return this.color; }
     61      set { this.color = value; }
     62    }
     63
     64    private string title;
     65    public string Title {
     66      get { return title; }
     67      set { title = value; }
     68    }
     69
     70    private IconMaterial iconMaterial;
     71    public Bitmap Icon {
     72      get { return this.iconMaterial.Icon; }
     73      set {
     74        this.iconMaterial.Icon = value;
     75        this.iconMaterial.Transform(new Rectangle(new Point(Rectangle.X + 5, Rectangle.Y + 5), this.iconMaterial.Icon.Size));
     76      }
     77    }
     78
     79    #region additional connectors
    3780    private List<IConnector> additionalConnectors;
    3881    public IEnumerable<string> AdditionalConnectorNames {
     
    58101    }
    59102
    60 
    61 
    62103    public void AddConnector(string connectorName) {
    63104      IConnector connector = this.CreateConnector(connectorName, this.BottomRightCorner);
     
    89130      }
    90131    }
    91 
     132    #endregion
     133
     134    #region label material
     135    private List<string> labels;
     136    public IEnumerable<string> Labels {
     137      get { return this.labels; }
     138    }
     139
     140    public void UpdateLabels(IEnumerable<string> labels) {
     141      this.labels = new List<string>(labels);
     142      this.expandIconMaterial.Visible = this.labels.Count != 0;
     143      this.UpdateLabels();
     144    }
     145    #endregion
     146
     147    private void expandIconMaterial_OnExpand(object sender, EventArgs e) {
     148      this.UpdateLabels();
     149    }
     150
     151    private void expandIconMaterial_OnCollapse(object sender, EventArgs e) {
     152      this.UpdateLabels();
     153    }
     154
     155    private Size CalculateSize() {
     156      int width = this.Rectangle.Width;
     157      int height = HEADER_HEIGHT;
     158      if (!Collapsed)
     159        height += this.labels.Count * (LABEL_HEIGHT + LABEL_SPACING);
     160      return new Size(width, height);
     161    }
     162
     163    private void UpdateLabels() {
     164      Size newSize = CalculateSize();
     165      if (this.Rectangle.Size != newSize) {
     166        foreach (IConnector connector in this.additionalConnectors)
     167          connector.MoveBy(new Point(0, newSize.Height - this.Rectangle.Height));
     168        this.mRectangle = new Rectangle(this.Rectangle.Location, newSize);
     169        this.Invalidate();
     170        this.RaiseOnChange(this, new EntityEventArgs(this));
     171      }
     172    }
    92173
    93174    protected override void Initialize() {
    94175      base.Initialize();
    95176
    96       #region Connectors
    97       this.Connectors.Clear();
    98 
    99       predecessor = this.CreateConnector("Predecessor", new Point(Rectangle.Left, Center.Y));
    100       Connectors.Add(predecessor);
    101 
    102       successor = this.CreateConnector("Successor", (new Point(Rectangle.Right, Center.Y)));
    103       Connectors.Add(successor);
    104       #endregion
     177      //the initial size
     178      this.Transform(0, 0, 200, HEADER_HEIGHT);
     179      this.color = Color.LightBlue;
     180
     181      this.iconMaterial = new IconMaterial();
     182      this.iconMaterial.Gliding = false;
     183      this.Children.Add(iconMaterial);
     184
     185      Bitmap expandBitmap = new Bitmap(HeuristicLab.Common.Resources.VS2008ImageLibrary.Redo);
     186      Bitmap collapseBitmap = new Bitmap(HeuristicLab.Common.Resources.VS2008ImageLibrary.Undo);
     187      this.expandIconMaterial = new ExpandableIconMaterial(expandBitmap, collapseBitmap);
     188      this.expandIconMaterial.Gliding = false;
     189      this.expandIconMaterial.Transform(new Rectangle(new Point(Rectangle.Right - 20, Rectangle.Y + 7), expandIconMaterial.Icon.Size));
     190      this.expandIconMaterial.Visible = false;
     191      this.expandIconMaterial.OnExpand += new EventHandler(expandIconMaterial_OnExpand);
     192      this.expandIconMaterial.OnCollapse += new EventHandler(expandIconMaterial_OnCollapse);
     193      this.Children.Add(expandIconMaterial);
     194
     195      this.predecessor = this.CreateConnector("Predecessor", new Point(Rectangle.Left, Center.Y));
     196      this.Connectors.Add(predecessor);
     197
     198      this.successor = this.CreateConnector("Successor", (new Point(Rectangle.Right, Center.Y)));
     199      this.Connectors.Add(successor);
     200    }
     201
     202    public override void Paint(Graphics g) {
     203      base.Paint(g);
     204
     205      g.SmoothingMode = SmoothingMode.HighQuality;
     206
     207      Pen pen;
     208      if (Hovered)
     209        pen = ArtPalette.HighlightPen;
     210      else
     211        pen = mPenStyle.DrawingPen();
     212
     213      GraphicsPath path = new GraphicsPath();
     214      path.AddArc(Rectangle.X, Rectangle.Y, 20, 20, -180, 90);
     215      path.AddLine(Rectangle.X + 10, Rectangle.Y, Rectangle.X + Rectangle.Width - 10, Rectangle.Y);
     216      path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y, 20, 20, -90, 90);
     217      path.AddLine(Rectangle.X + Rectangle.Width, Rectangle.Y + 10, Rectangle.X + Rectangle.Width, Rectangle.Y + Rectangle.Height - 10);
     218      path.AddArc(Rectangle.X + Rectangle.Width - 20, Rectangle.Y + Rectangle.Height - 20, 20, 20, 0, 90);
     219      path.AddLine(Rectangle.X + Rectangle.Width - 10, Rectangle.Y + Rectangle.Height, Rectangle.X + 10, Rectangle.Y + Rectangle.Height);
     220      path.AddArc(Rectangle.X, Rectangle.Y + Rectangle.Height - 20, 20, 20, 90, 90);
     221      path.AddLine(Rectangle.X, Rectangle.Y + Rectangle.Height - 10, Rectangle.X, Rectangle.Y + 10);
     222      //shadow
     223      if (ArtPalette.EnableShadows) {
     224        Region darkRegion = new Region(path);
     225        darkRegion.Translate(5, 5);
     226        g.FillRegion(ArtPalette.ShadowBrush, darkRegion);
     227      }
     228      //background
     229      g.FillPath(Brush, path);
     230
     231      using (LinearGradientBrush gradientBrush = new LinearGradientBrush(Rectangle.Location, new Point(Rectangle.X + Rectangle.Width, Rectangle.Y), this.Color, Color.White)) {
     232        Region gradientRegion = new Region(path);
     233        g.FillRegion(gradientBrush, gradientRegion);
     234      }
     235
     236      if (!this.Collapsed) {
     237        TextStyle textStyle = new TextStyle(Color.Black, new Font("Arial", 7), StringAlignment.Near, StringAlignment.Near);
     238        StringFormat stringFormat = textStyle.StringFormat;
     239        stringFormat.Trimming = StringTrimming.EllipsisWord;
     240        stringFormat.FormatFlags = StringFormatFlags.LineLimit;
     241        Rectangle rect;
     242
     243        for (int i = 0; i < this.labels.Count; i++) {
     244          rect = new Rectangle(Rectangle.X + 25, Rectangle.Y + HEADER_HEIGHT + i * (LABEL_HEIGHT + LABEL_SPACING), LABEL_WIDTH, LABEL_HEIGHT);
     245          g.DrawString(textStyle.GetFormattedText(this.labels[i]), textStyle.Font, textStyle.GetBrush(), rect, stringFormat);
     246        }
     247      }
     248
     249      //the border
     250      g.DrawPath(pen, path);
     251
     252      //the title
     253      g.DrawString(this.Title, ArtPalette.DefaultBoldFont, Brushes.Black, new Rectangle(Rectangle.X + 25, Rectangle.Y + 5, Rectangle.Width - 45, 27));
     254
     255      //the material
     256      foreach (IPaintable material in Children)
     257        material.Paint(g);
     258
     259      //the connectors
     260      if (this.ShowConnectors) {
     261        for (int k = 0; k < Connectors.Count; k++)
     262          Connectors[k].Paint(g);
     263      }
    105264    }
    106265  }
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/Model/OperatorShapeInfo.cs

    r2868 r2934  
    2828using Netron.Diagramming.Core;
    2929using System.Windows.Forms;
     30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3031
    3132namespace HeuristicLab.Operators.Views.GraphVisualization {
    32   internal class OperatorShapeInfo : ShapeInfo {
     33  internal class OperatorShapeInfo : ShapeInfo, IOperatorShapeInfo {
     34    [Storable]
     35    private List<string> connectorNames;
     36    [Storable]
     37    private List<string> labels;
    3338
    34     private List<string> connectorNames;
    3539    public OperatorShapeInfo()
    3640      : base(typeof(OperatorShape)) {
    3741      this.connectorNames = new List<string>();
     42      this.labels = new List<string>();
    3843    }
    3944
     
    4449    }
    4550
    46     public override void AddConnector(string connectorName) {
     51    public OperatorShapeInfo(IEnumerable<string> connectorNames, IEnumerable<string> labels)
     52      : this(connectorNames) {
     53      foreach (string label in labels)
     54        this.labels.Add(label);
     55    }
     56
     57    public void AddConnector(string connectorName) {
    4758      if (!this.connectorNames.Contains(connectorName) && connectorName != "Successor") {
    4859        this.connectorNames.Add(connectorName);
     
    5162    }
    5263
    53     public override void RemoveConnector(string connectorName) {
     64    public void RemoveConnector(string connectorName) {
    5465      if (this.connectorNames.Contains(connectorName)) {
    5566        this.connectorNames.Remove(connectorName);
     
    5869    }
    5970
     71    public void UpdateLabels(IEnumerable<string> labels) {
     72      this.labels = new List<string>(labels);
     73      this.OnChanged();
     74    }
     75
     76    [Storable]
     77    private bool collapsed;
     78    public bool Collapsed {
     79      get { return this.collapsed; }
     80      set {
     81        if (this.collapsed != value) {
     82          this.collapsed = value;
     83          this.OnChanged();
     84        }
     85      }
     86    }
     87
     88    [Storable]
    6089    private string title;
    6190    public string Title {
     
    6998    }
    7099
    71     private string text;
    72     public string Text {
    73       get { return this.text; }
     100    [Storable]
     101    private Color color;
     102    public Color Color {
     103      get { return this.color; }
    74104      set {
    75         if (this.text != value) {
    76           this.text = value;
     105        if (this.color != value) {
     106          this.color = value;
    77107          this.OnChanged();
    78108        }
     
    80110    }
    81111
    82     private Color headColor;
    83     public Color HeadColor {
    84       get { return this.headColor; }
     112    [Storable]
     113    private Bitmap icon;
     114    public Bitmap Icon {
     115      get { return this.icon; }
    85116      set {
    86         if (this.headColor != value) {
    87           this.headColor = value;
     117        if (this.icon != value) {
     118          this.icon = value;
    88119          this.OnChanged();
    89120        }
     
    94125      OperatorShape shape = (OperatorShape)base.CreateShape();
    95126      shape.Title = this.Title;
    96       shape.SubTitle = this.Text;
    97       shape.HeadColor = this.HeadColor;
     127      shape.Color = this.Color;
     128      shape.Icon = this.Icon;
     129      shape.Collapsed = this.Collapsed;
    98130      foreach (string connectorName in this.connectorNames)
    99131        shape.AddConnector(connectorName);
     132
     133      shape.UpdateLabels(this.labels);
    100134      return shape;
    101135    }
     
    104138      base.UpdateShape(shape);
    105139      OperatorShape operatorShape = shape as OperatorShape;
    106 
    107140      if (operatorShape != null) {
    108141        operatorShape.Title = this.Title;
    109         operatorShape.SubTitle = this.Text;
    110         operatorShape.HeadColor = this.HeadColor;
     142        operatorShape.Color = this.Color;
     143        operatorShape.Collapsed = this.Collapsed;
    111144
    112145        int i = 0;
     
    121154          j++;
    122155        }
    123         //remove old connectors
     156        //remove remaining old connectors
    124157        for (; j < oldConnectorNames.Count; j++)
    125158          operatorShape.RemoveConnector(oldConnectorNames[j]);
     
    128161        for (; i < this.connectorNames.Count; i++)
    129162          operatorShape.AddConnector(this.connectorNames[i]);
     163
     164        operatorShape.UpdateLabels(this.labels);
    130165      }
    131166    }
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/Model/ShapeInfo.cs

    r2893 r2934  
    2828using Netron.Diagramming.Core;
    2929using HeuristicLab.Collections;
     30using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3031
    3132namespace HeuristicLab.Operators.Views.GraphVisualization {
    32   internal abstract class ShapeInfo : Item, IShapeInfo {
     33  internal abstract class ShapeInfo : Item,IShapeInfo {
     34    private ShapeInfo() {
     35
     36    }
    3337    protected ShapeInfo(Type shapeType) {
    3438      if (!typeof(IShape).IsAssignableFrom(shapeType))
     
    3741    }
    3842
     43    public event EventHandler Changed;
     44
     45    [Storable]
    3946    private Type shapeType;
    4047    public Type ShapeType {
     
    4249    }
    4350
     51    [Storable]
    4452    private Point location;
    4553    public Point Location {
     
    5361    }
    5462
    55     private Size size;
    56     public Size Size {
    57       get { return this.size; }
    58       set {
    59         if (this.size != value) {
    60           this.size = value;
    61           this.OnChanged();
    62         }
    63       }
     63    protected void OnChanged() {
     64      if (this.Changed != null)
     65        this.Changed(this, EventArgs.Empty);
    6466    }
    65 
    66     public abstract void AddConnector(string connectorName);
    67     public abstract void RemoveConnector(string connectorName);
    6867
    6968    public virtual IShape CreateShape() {
     
    7170      shape.Tag = this;
    7271      shape.Location = this.Location;
    73       shape.Height = this.Size.Height;
    74       shape.Width = this.Size.Width;
    7572      return shape;
    7673    }
     
    7875    public virtual void UpdateShape(IShape shape) {
    7976      shape.Location = this.Location;
    80       shape.Height = this.Size.Height;
    81       shape.Width = this.Size.Width;
    8277    }
    8378  }
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/Model/ShapeInfoFactory.cs

    r2875 r2934  
    3838    }
    3939
    40     public static IShapeInfo CreateShapeInfo(IOperator op) {
    41       IEnumerable<string> paramterNames = op.Parameters.Where(p => p is IValueParameter<IOperator> && p.Name != "Successor").Select(p => p.Name);
    42       OperatorShapeInfo operatorShapeInfo = new OperatorShapeInfo(paramterNames);
     40    public static IOperatorShapeInfo CreateOperatorShapeInfo(IOperator op) {
     41      IEnumerable<string> operatorParameterNames = op.Parameters.Where(p => p is IValueParameter<IOperator> && p.Name != "Successor").Select(p => p.Name);
     42      IEnumerable<string> paramaterNameValues = op.Parameters.Where(p => !(p is IValueParameter<IOperator>)).Select(p => p.ToString());
     43
     44      OperatorShapeInfo operatorShapeInfo = new OperatorShapeInfo(operatorParameterNames,paramaterNameValues);
     45      operatorShapeInfo.Collapsed = true;
    4346      operatorShapeInfo.Title = op.Name;
    44       operatorShapeInfo.Text = op.GetType().ToString();
    45       operatorShapeInfo.HeadColor = Color.LightBlue;
     47      operatorShapeInfo.Color = Color.LightBlue;
     48      operatorShapeInfo.Icon = new Bitmap(op.ItemImage);
    4649
    4750      return operatorShapeInfo;
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphView.Designer.cs

    r2909 r2934  
    4040      this.zoomInButton = new System.Windows.Forms.Button();
    4141      this.zoomOutButton = new System.Windows.Forms.Button();
     42      this.screenshotButton = new System.Windows.Forms.Button();
    4243      this.buttonToolTip = new System.Windows.Forms.ToolTip();
    4344      this.shapeContextMenu.SuspendLayout();
     
    100101      // splitContainer.Panel1
    101102      //
     103      this.splitContainer.Panel1.Controls.Add(this.screenshotButton);
    102104      this.splitContainer.Panel1.Controls.Add(this.zoomOutButton);
    103105      this.splitContainer.Panel1.Controls.Add(this.zoomInButton);
     
    213215      this.zoomOutButton.Click += new System.EventHandler(zoomOutButton_Click);
    214216      this.buttonToolTip.SetToolTip(this.zoomOutButton, "Zoom Out");
     217      //
     218      // screenshotButton
     219      //
     220      this.screenshotButton.Image = HeuristicLab.Common.Resources.VS2008ImageLibrary.Copy;
     221      this.screenshotButton.Location = new System.Drawing.Point(243, 3);
     222      this.screenshotButton.Name = "screenshotButton";
     223      this.screenshotButton.Size = new System.Drawing.Size(24, 24);
     224      this.screenshotButton.TabIndex = 8;
     225      this.screenshotButton.UseVisualStyleBackColor = true;
     226      this.screenshotButton.Click += new System.EventHandler(screenshotButton_Click);
     227      this.buttonToolTip.SetToolTip(this.screenshotButton, "Screenshot");
    215228      //
    216229      // OperatorGraphView
     
    249262    private System.Windows.Forms.Button connectButton;
    250263    private System.Windows.Forms.Button panButton;
     264    private System.Windows.Forms.Button screenshotButton;
    251265    private System.Windows.Forms.ToolTip buttonToolTip;
    252266  }
  • trunk/sources/HeuristicLab.Operators.Views.GraphVisualization/3.3/OperatorGraphView.cs

    r2917 r2934  
    7878    }
    7979
    80 
    81     #region connector tooltips
    82 
    83     #endregion
    84 
    8580    private void Controller_SelectionChanged(object sender, EventArgs e) {
    8681      CollectionBase<IDiagramEntity> selectedObjects = this.graphVisualizationInfoView.Controller.Model.Selection.SelectedItems;
     
    8984        IShape shape = selectedObjects[0] as IShape;
    9085        if (shape != null) {
    91           IShapeInfo shapeInfo = shape.Tag as ShapeInfo;
     86          IOperatorShapeInfo shapeInfo = shape.Tag as IOperatorShapeInfo;
    9287          IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo);
    9388          this.detailsViewHost.Content = op;
     
    10499        }
    105100        if (shape != null) {
    106           IShapeInfo shapeInfo = shape.Tag as ShapeInfo;
     101          IOperatorShapeInfo shapeInfo = shape.Tag as IOperatorShapeInfo;
    107102          IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo);
    108103          if (connectorName != "Predecessor") {
     
    129124
    130125    private void shapeContextMenu_Opening(object sender, System.ComponentModel.CancelEventArgs e) {
    131       IShapeInfo shapeInfo = this.shapeContextMenu.Tag as ShapeInfo;
     126      IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo;
    132127      if (shapeInfo != null) {
    133128        IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo);
     
    138133
    139134    private void openViewToolStripMenuItem_Click(object sender, EventArgs e) {
    140       IShapeInfo shapeInfo = this.shapeContextMenu.Tag as ShapeInfo;
     135      IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo;
    141136      if (shapeInfo != null) {
    142137        IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo);
     
    146141
    147142    private void initialOperatorToolStripMenuItem_Click(object sender, EventArgs e) {
    148       IShapeInfo shapeInfo = this.shapeContextMenu.Tag as ShapeInfo;
     143      IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo;
    149144      if (this.VisualizationInfo.InitialShape == shapeInfo)
    150145        this.VisualizationInfo.InitialShape = null;
     
    154149
    155150    private void breakPointToolStripMenuItem_Click(object sender, EventArgs e) {
    156       IShapeInfo shapeInfo = this.shapeContextMenu.Tag as ShapeInfo;
     151      IOperatorShapeInfo shapeInfo = this.shapeContextMenu.Tag as IOperatorShapeInfo;
    157152      if (shapeInfo != null) {
    158153        IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo);
     
    174169      if (e.Effect != DragDropEffects.None) {
    175170        IOperator op = e.Data.GetData("Value") as IOperator;
    176         IShapeInfo shapeInfo = Factory.CreateShapeInfo(op);
     171        IOperatorShapeInfo shapeInfo = Factory.CreateOperatorShapeInfo(op);
    177172        Point mouse = new Point(MousePosition.X, MousePosition.Y);
    178         Point p = new Point(e.X, e.Y);
    179         Point screen = this.PointToScreen(new Point(0, 0));
    180         PointF worldPoint = this.graphVisualizationInfoView.Controller.View.WorldToView(new Point(mouse.X - screen.X, mouse.Y - screen.Y));
     173        Point screen = this.graphVisualizationInfoView.PointToScreen(new Point(0, 0));
     174        Point control = new Point(mouse.X - screen.X, mouse.Y - screen.Y);
     175        PointF worldPoint = this.graphVisualizationInfoView.Controller.View.ViewToWorld(control);
     176
     177        if (worldPoint.X < 0)
     178          worldPoint.X = 0;
     179        if (worldPoint.Y < 0)
     180          worldPoint.Y = 0;
    181181
    182182        shapeInfo.Location = Point.Round(worldPoint);
     
    184184      }
    185185    }
    186 
    187186    #endregion
    188187
     
    237236
    238237    private void zoomAreaButton_Click(object sender, EventArgs e) {
    239       this.graphVisualizationInfoView.Controller.ActivateTool(ControllerBase.ZoomAreaToolName);
     238      this.graphVisualizationInfoView.Controller.View.ZoomFit();
    240239    }
    241240
     
    247246      this.graphVisualizationInfoView.Controller.ActivateTool(ControllerBase.ZoomOutToolName);
    248247    }
     248
     249    private void screenshotButton_Click(object sender, EventArgs e) {
     250      Bitmap bitmap = ImageExporter.FromBundle(new Bundle(this.graphVisualizationInfoView.Controller.Model.Paintables),this.graphVisualizationInfoView.Controller.View.Graphics);
     251      SaveFileDialog saveFileDialog = new SaveFileDialog();
     252      saveFileDialog.Title = "Save Screenshot";
     253      saveFileDialog.DefaultExt = "bmp";
     254      saveFileDialog.Filter = "Bitmap|*.bmp|All Files|*.*";
     255      saveFileDialog.FilterIndex = 1;
     256
     257      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
     258        bitmap.Save(saveFileDialog.FileName);
     259      }
     260    }
     261
    249262  }
    250263}
Note: See TracChangeset for help on using the changeset viewer.