Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13426


Ignore:
Timestamp:
12/01/15 21:00:52 (8 years ago)
Author:
bburlacu
Message:

#1772: Updated the GenealogyGraphChart using new chart modes from HeuristicLab.Visualization

File:
1 edited

Legend:

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

    r13399 r13426  
    3232  public partial class GenealogyGraphChart : ChartControl {
    3333    private IGenealogyGraph genealogyGraph;
    34 
    3534    private const double XIncrement = 30;
    3635    private const double YIncrement = 30;
    3736    private const double Diameter = 20;
    38 
    3937    private readonly Brush defaultBrush;
    4038    private readonly Pen defaultPen;
     
    4745    public bool LockGenealogy { get; set; }
    4846    public bool TraceFragments { get; set; }
    49     #endregion
    50 
    51     #region chart modes
    52     public Dictionary<string, ChartMode> ChartMode { get; private set; }
    5347    #endregion
    5448
     
    10599    }
    106100
    107     public GenealogyGraphChart() {
     101    public GenealogyGraphChart() : base(new Chart(0, 0, 800, 600)) {
    108102      InitializeComponent();
    109 
    110       ChartMode = new Dictionary<string, ChartMode> {
    111         { "Select", new SelectChartMode(this) },
    112         { "ZoomIn", new ZoomInChartMode(this) },
    113         { "ZoomOut", new ZoomOutChartMode(this) },
    114         { "Pan", new PanChartMode(this) }
    115       };
    116 
     103      AddChartModes(new PanChartMode(this), new ZoomInChartMode(this), new ZoomOutChartMode(this), new SelectChartMode(this));
    117104      defaultBrush = new SolidBrush(Color.Transparent);
    118105      defaultPen = new Pen(Color.DarkGray);
     
    137124            Data = node,
    138125            ToolTipText = "Rank: " + node.Rank + nl +
    139                           "Quality: " + String.Format("{0:0.0000}", node.Quality) + nl +
     126                          "Quality: " + string.Format("{0:N4}", node.Quality) + nl +
    140127                          "IsElite: " + node.IsElite + nl +
    141128                          "In/Out Degree: " + node.InDegree + " " + node.OutDegree
     
    187174    #region event handlers
    188175
    189     protected override void PictureBoxOnMouseMove(object sender, MouseEventArgs e) {
    190       if (!DrawInProgress) {
    191         switch (e.Button) {
    192           case MouseButtons.Left:
    193             Mode = ChartMode["Select"];
    194             Cursor = Cursors.Default;
    195             break;
    196           case MouseButtons.Middle:
    197             Mode = ChartMode["Pan"];
    198             Cursor = Cursors.Hand;
    199             break;
    200         }
    201       }
    202       base.PictureBoxOnMouseMove(sender, e);
    203     }
    204 
    205176    protected override void PictureBoxOnMouseUp(object sender, MouseEventArgs e) {
    206       Cursor = Cursors.Default;
    207 
    208       var primitive = Chart.GetAllPrimitives(e.Location).FirstOrDefault(p => p is VisualGenealogyGraphNode);
    209       if (primitive == null) {
    210         SelectedVisualNode = null;
    211         return;
    212       }
    213       if (SelectedVisualNode == primitive) return;
    214       SelectedVisualNode = primitive as VisualGenealogyGraphNode;
    215       if (SelectedVisualNode == null) return;
    216 
    217       UpdateSelectedVisualNode(); // redraw ancestries, mark node etc.
    218 
     177      if (Mode is SelectChartMode) {
     178        var primitive = Chart.GetAllPrimitives(e.Location).FirstOrDefault(p => p is VisualGenealogyGraphNode);
     179        if (primitive != null && primitive != SelectedVisualNode) {
     180          SelectedVisualNode = (VisualGenealogyGraphNode)primitive;
     181          UpdateSelectedVisualNode(); // redraw ancestries, mark node etc.
     182        }
     183      }
    219184      base.PictureBoxOnMouseUp(sender, e);
    220185    }
Note: See TracChangeset for help on using the changeset viewer.