Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/01/15 23:17:56 (10 years ago)
Author:
bburlacu
Message:

#1772: Added some useful functionality to the GenealogyGraphView.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs

    r11817 r11852  
    4040    private readonly Pen defaultPen;
    4141
     42    private Dictionary<IGenealogyGraphNode, VisualGenealogyGraphNode> nodeMap;
     43    private Dictionary<Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>, VisualGenealogyGraphArc> arcMap;
     44
    4245    public IGenealogyGraph GenealogyGraph {
    4346      get { return genealogyGraph; }
     
    6366    }
    6467
    65     private Dictionary<IGenealogyGraphNode, VisualGenealogyGraphNode> nodeMap;
    66     private Dictionary<Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>, VisualGenealogyGraphArc> arcMap;
     68    public bool UpdateEnabled {
     69      get { return Chart.UpdateEnabled; }
     70      set { Chart.UpdateEnabled = value; }
     71    }
     72
     73    public void EnforceUpdate() {
     74      Chart.EnforceUpdate();
     75    }
    6776
    6877    #region chart modes
     
    225234
    226235      // update
    227       Chart.UpdateEnabled = true;
    228       Chart.EnforceUpdate();
     236      UpdateEnabled = true;
     237      EnforceUpdate();
    229238
    230239      if (SelectedVisualNode != null)
    231         /* emit clicked event */
    232         OnGenealogyGraphNodeClicked(SelectedVisualNode, e);
     240        OnGenealogyGraphNodeClicked(SelectedVisualNode, e); // emit clicked event
    233241
    234242      base.pictureBox_MouseUp(sender, e);
     
    306314    }
    307315
     316    public void ClearArcs() {
     317      foreach (var primitive in Chart.Group.Primitives.OfType<VisualGenealogyGraphArc>()) {
     318        primitive.Pen = Pens.Transparent;
     319      }
     320    }
     321
     322    public void ClearNodes() {
     323      foreach (var primitive in Chart.Group.Primitives.OfType<VisualGenealogyGraphNode>()) {
     324        primitive.Brush = new SolidBrush(Color.Transparent);
     325        primitive.Pen = new Pen(Color.LightGray);
     326      }
     327    }
     328
    308329    public virtual void ClearPrimitives() {
    309330      foreach (var primitive in Chart.Group.Primitives) {
     
    313334          primitive.Brush = new SolidBrush(Color.Transparent);
    314335          primitive.Pen = new Pen(Color.DarkGray);
    315         }
    316       }
    317     }
    318 
    319     public void HighlightNodes(IEnumerable<IGenealogyGraphNode> nodes) {
    320       Chart.UpdateEnabled = false;
    321       ClearPrimitives();
     336          //          primitive.Pen = Pens.Transparent; // remove the node contour
     337        }
     338      }
     339    }
     340
     341    public void HighlightNodes(IEnumerable<IGenealogyGraphNode> nodes, bool clearPrimitives = true) {
     342      if (clearPrimitives)
     343        ClearPrimitives();
     344
    322345      foreach (var node in nodes) {
    323346        var graphNode = GetMappedNode(node);
    324347        graphNode.Brush = new SolidBrush(node.GetColor());
    325348      }
    326       Chart.UpdateEnabled = true;
    327       Chart.EnforceUpdate();
     349    }
     350
     351    public void HighlightNodes(IEnumerable<IGenealogyGraphNode> nodes, Color color, bool clearPrimitives = true) {
     352      if (clearPrimitives)
     353        ClearPrimitives();
     354
     355      foreach (var node in nodes.Select(GetMappedNode)) {
     356        node.Brush = new SolidBrush(color);
     357      }
    328358    }
    329359
    330360    public void HighlightAll() {
    331       Chart.UpdateEnabled = false;
    332361      foreach (var visualNode in nodeMap.Values) {
    333362        visualNode.Brush = new SolidBrush(visualNode.Data.GetColor());
     
    340369        arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor());
    341370      }
    342       Chart.UpdateEnabled = true;
    343       Chart.EnforceUpdate();
    344371    }
    345372
Note: See TracChangeset for help on using the changeset viewer.