Esempio n. 1
0
 /// <summary>Creates a new <see cref="DiagramEdge"/> instance.</summary>
 public DiagramEdge(DiagramNode source, DiagramNode target, DiagramEdgeRole role, string label) {
    Assumption.NotNull(source);
    Assumption.NotNull(target);
    Role = role;
    Source = source;
    Target = target;
    Label = label.At(0).ToUpper() + label.After(0) + (Role.Has(DiagramEdgeRole.ZeroToMany) ? "*" : "");
    ComputedPath = new PointCollection();
    _initializeResources();
 }
Esempio n. 2
0
      /// <summary>Loads the diagram with the given collection of classes and namespaces.</summary>
      public void Load(IEnumerable<BplClass> classes) {
         Children.Clear();
         var counter = 0;

         // blocks layer
         _blocks = new Index<long, BplNamespace, DiagramBlock>(block => block.Id, block => block.Namespace);
         Blocks = new ReadOnlyIndex<long, BplNamespace, DiagramBlock>(_blocks);
         BlocksLayer = new Canvas();
         Children.Add(BlocksLayer);
         foreach (var ns in classes.Select(c => c.Namespace).Distinct()) {
            var block = new DiagramBlock(this, counter++, ns);
            BlocksLayer.Children.Add(block);
            _blocks.Add(block);
         }

         // skeleton layer
         SkeletonLayer = new Canvas();
         Children.Add(SkeletonLayer);

         // edges layer
         Edges = new HashSet<DiagramEdge>();
         EdgesLayer = new Canvas();
         Children.Add(EdgesLayer);

         // nodes layer
         _nodes = new Index<long, BplClass, DiagramNode>(node => node.Id, node => node.Class);
         Nodes = new ReadOnlyIndex<long, BplClass, DiagramNode>(_nodes);
         NodesLayer = new Canvas();
         Children.Add(NodesLayer);
         foreach (var bplClass in classes) {
            var node = new DiagramNode(this, counter++, bplClass);
            NodesLayer.Children.Add(node);
            _nodes.Add(node);
            _blocks[bplClass.Namespace].Add(node);
         }

         // content frame
         if (ContentBounds != null) {
            ContentBounds.SizeChanged -= _onContentSizeChanged;
         }
         ContentBounds = new Rectangle();
         ContentBounds.SizeChanged += _onContentSizeChanged;
         Children.Add(ContentBounds);

         IsEmpty = (Blocks.Count == 0 || Nodes.Count == 0);
         _isFirstLayout = true;
      }
Esempio n. 3
0
      private void _onCurrentClassChanged(object sender, EventArgs e) {
         if (_currentNode != null) {
            _currentNode.IsCurrentNode = false;
            _currentNode = null;
         }

         var currentClass = Explorer.Shell.CurrentClass;
         if (currentClass != null && Nodes != null) {
            _currentNode = Nodes.TryGet(currentClass);
            if (_currentNode != null) {
               _currentNode.IsCurrentNode = true;
            }
         }
      }
Esempio n. 4
0
 // adds a node to this block
 internal void Add(DiagramNode node) {
    _nodes.Add(node);
    node.Block = this;
 }