Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10093


Ignore:
Timestamp:
10/29/13 13:47:35 (11 years ago)
Author:
jkarder
Message:

#2116:

  • refactored breadcrumb navigation
  • added possibility to navigate to the first invisible breadcrumb via the ellipsis
Location:
branches/Breadcrumbs
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs

    r10089 r10093  
    224224        var item = (T)itemsListView.SelectedItems[0].Tag;
    225225        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    226         var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
    227         if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) {
    228           var oldCrumbs = outermostViewHost.Breadcrumbs;
    229           var newCrumbs = BuildBreadcrumbTrail();
    230           mainForm.ShowContentInSpecificViewHost(item, outermostViewHost);
    231           outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
    232         } else {
     226        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true);
     227        if (!outermostViewHost.HotlinkingEnabled) {
    233228          if (showDetailsCheckBox.Checked) {
    234229            detailsGroupBox.Enabled = true;
     
    256251        var item = (T)itemsListView.SelectedItems[0].Tag;
    257252        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    258         var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
    259         var oldCrumbs = outermostViewHost.Breadcrumbs;
    260         var newCrumbs = BuildBreadcrumbTrail();
    261         mainForm.ShowContentInSpecificViewHost(item, outermostViewHost);
    262         outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     253        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this);
    263254        outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    264255        outermostViewHost.ActiveView.Locked = Locked;
     
    449440      }
    450441    }
    451     protected virtual IEnumerable<IContent> BuildBreadcrumbTrail() {
    452       var l = new LinkedList<IContent>();
    453       for (var control = (Control)this; control != null; control = control.Parent) {
    454         var vh = control as ViewHost;
    455         if (vh != null && vh.Content != null)
    456           l.AddFirst(vh.Content);
    457       }
    458       return l;
    459     }
    460442    #endregion
    461443  }
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ItemListView.cs

    r10089 r10093  
    245245        var item = (T)itemsListView.SelectedItems[0].Tag;
    246246        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    247         var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
    248         if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) {
    249           var oldCrumbs = outermostViewHost.Breadcrumbs;
    250           var newCrumbs = BuildBreadcrumbTrail();
    251           mainForm.ShowContentInSpecificViewHost(item, outermostViewHost);
    252           outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     247        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true);
     248        if (outermostViewHost.HotlinkingEnabled) {
    253249          outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    254250          outermostViewHost.ActiveView.Locked = Locked;
     
    278274        var item = (T)itemsListView.SelectedItems[0].Tag;
    279275        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    280         var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
    281         var oldCrumbs = outermostViewHost.Breadcrumbs;
    282         var newCrumbs = BuildBreadcrumbTrail();
    283         mainForm.ShowContentInSpecificViewHost(item, outermostViewHost);
    284         outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     276        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this);
    285277        outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    286278        outermostViewHost.ActiveView.Locked = Locked;
     
    516508      }
    517509    }
    518     protected virtual IEnumerable<IContent> BuildBreadcrumbTrail() {
    519       var l = new LinkedList<IContent>();
    520       for (var control = (Control)this; control != null; control = control.Parent) {
    521         var vh = control as ViewHost;
    522         if (vh != null && vh.Content != null)
    523           l.AddFirst(vh.Content);
    524       }
    525       return l;
    526     }
    527510    #endregion
    528511  }
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ParameterCollectionView.cs

    r10089 r10093  
    153153        var item = (IParameter)itemsListView.SelectedItems[0].Tag;
    154154        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    155         var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
    156         if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) {
    157           var oldCrumbs = outermostViewHost.Breadcrumbs;
    158           var newCrumbs = BuildBreadcrumbTrail();
    159           mainForm.ShowContentInSpecificViewHost(item, outermostViewHost);
    160           outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     155        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true);
     156        if (outermostViewHost.HotlinkingEnabled) {
    161157          outermostViewHost.ActiveView.ReadOnly = ReadOnly || (item.Hidden && !AllowEditingOfHiddenParameters);
    162158          outermostViewHost.ActiveView.Locked = Locked;
     
    176172        var item = (IParameter)itemsListView.SelectedItems[0].Tag;
    177173        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    178         var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
    179         var oldCrumbs = outermostViewHost.Breadcrumbs;
    180         var newCrumbs = BuildBreadcrumbTrail();
    181         mainForm.ShowContentInSpecificViewHost(item, outermostViewHost);
    182         outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     174        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this);
    183175        outermostViewHost.ActiveView.ReadOnly = ReadOnly || (item.Hidden && !AllowEditingOfHiddenParameters);
    184176        outermostViewHost.ActiveView.Locked = Locked;
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/BreadcrumbControl.cs

    r10042 r10093  
    6666            Tag = bc
    6767          };
    68           label.Click += label_Click;
     68          ((LinkLabel)label).LinkClicked += label_LinkClicked;
    6969        }
    7070        labels.Add(label);
     
    9393      if (!labels.Any()) return;
    9494      var curLoc = new Point(3, 0);
    95       var ellipsis = new Label {
     95      var ellipsis = new LinkLabel {
    9696        Location = curLoc,
    9797        AutoSize = true,
     
    113113      if (i == labels.Count - 1) return;
    114114      i += 1 + i % 2;
     115      ellipsis.Tag = breadcrumbs.ElementAt(i / 2);
     116      ellipsis.LinkClicked += label_LinkClicked;
    115117      while (i < labels.Count) {
    116118        var l = labels[i++];
     
    121123    }
    122124
    123     private void label_Click(object sender, EventArgs e) {
     125    private void label_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
    124126      var label = (LinkLabel)sender;
    125127      var content = (IContent)label.Tag;
    126       int crumbCount = breadcrumbs.Count;
    127       while (breadcrumbs.Any()) {
    128         var item = breadcrumbs.Last.Value;
    129         if (item == content) break;
     128      while (breadcrumbs.Any() && breadcrumbs.Last.Value != content)
    130129        breadcrumbs.RemoveLast();
    131       }
    132       var targetViewHost = ViewHost;
    133       if (crumbCount - breadcrumbs.Count > 0) {
    134         for (var parent = Parent; parent != null; parent = parent.Parent) {
    135           var vh = parent as ViewHost;
    136           if (vh != null) targetViewHost = vh;
    137         }
    138       }
    139       bool showBreadcrumbs = targetViewHost.ShowBreadcrumbs;
    140       targetViewHost.Content = null;
     130      var mainForm = MainFormManager.GetMainForm<MainForm>();
     131      var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(ViewHost);
     132      bool showBreadcrumbs = outermostViewHost.ShowBreadcrumbs;
     133      outermostViewHost.Content = null;
    141134      var viewType = MainFormManager.GetDefaultViewType(content.GetType());
    142       targetViewHost.ViewType = viewType;
    143       targetViewHost.Content = content;
    144       targetViewHost.UpdateBreadcrumbTrail(targetViewHost.Breadcrumbs, breadcrumbs);
    145       targetViewHost.ShowBreadcrumbs = showBreadcrumbs;
     135      outermostViewHost.ViewType = viewType;
     136      outermostViewHost.Content = content;
     137      outermostViewHost.UpdateBreadcrumbTrail(outermostViewHost.Breadcrumbs, breadcrumbs);
     138      outermostViewHost.ShowBreadcrumbs = showBreadcrumbs;
    146139    }
    147140
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.cs

    r10089 r10093  
    379379    private void PerformOutermostViewHostDetection() {
    380380      var mainForm = MainFormManager.GetMainForm<MainForm>();
     381      if (mainForm == null) return;
    381382      var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
    382383      isOutermostViewHost = outermostViewHost == this;
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r10089 r10093  
    224224
    225225    public T GetOutermostViewOfType<T>(Control childControl) where T : class, IView {
     226      if (childControl == null) throw new ArgumentNullException("childControl", "ChildControl cannot be null.");
     227
    226228      T outermostView = null;
    227229      for (var control = childControl; control != null; control = control.Parent) {
     
    273275    }
    274276
    275     public void ShowContentInSpecificViewHost(IContent content, ViewHost viewHost) {
    276       if (viewHost == null) return;
    277       viewHost.Content = null;
    278       var viewType = MainFormManager.GetDefaultViewType(content.GetType());
    279       viewHost.ViewType = viewType;
    280       viewHost.Content = content;
     277    public ViewHost ShowContentInOutermostViewHost(IContent content, Control childControl, bool requireHotlinking = false) {
     278      if (content == null) throw new ArgumentNullException("content", "Content cannot be null.");
     279      if (childControl == null) throw new ArgumentNullException("childControl", "ChildControl cannot be null.");
     280
     281      var outermostViewHost = GetOutermostViewOfType<ViewHost>(childControl);
     282      if (outermostViewHost == null)
     283        throw new ArgumentException("No outermost ViewHost could be found for the specified child control.", "childControl");
     284
     285      if (!requireHotlinking || outermostViewHost.HotlinkingEnabled) {
     286        var oldCrumbs = outermostViewHost.Breadcrumbs;
     287        var newCrumbs = new LinkedList<IContent>();
     288        for (var control = childControl; control != null; control = control.Parent) {
     289          var vh = control as ViewHost;
     290          if (vh != null && vh.Content != null)
     291            newCrumbs.AddFirst(vh.Content);
     292        }
     293        bool showBreadcrumbs = outermostViewHost.ShowBreadcrumbs;
     294        outermostViewHost.Content = null;
     295        var viewType = MainFormManager.GetDefaultViewType(content.GetType());
     296        outermostViewHost.ViewType = viewType;
     297        outermostViewHost.Content = content;
     298        outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { content }));
     299        outermostViewHost.ShowBreadcrumbs = showBreadcrumbs;
     300      }
     301      return outermostViewHost;
    281302    }
    282303
  • branches/Breadcrumbs/HeuristicLab.Operators.Views.GraphVisualization.Views/3.3/OperatorGraphView.cs

    r9456 r10093  
    140140          if (shapeInfo != null) {
    141141            IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo);
    142             IContentView view = MainFormManager.MainForm.ShowContent(op);
    143             if (view != null) {
    144               view.ReadOnly = this.ReadOnly;
    145               view.Locked = this.Locked;
    146             }
     142            var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     143            var outermostViewHost = mainForm.ShowContentInOutermostViewHost(op, this);
     144            outermostViewHost.ActiveView.ReadOnly = ReadOnly;
     145            outermostViewHost.ActiveView.Locked = Locked;
    147146            HandledMouseEventArgs eventArgs = e as HandledMouseEventArgs;
    148147            if (eventArgs != null)
     
    195194      if (shapeInfo != null) {
    196195        IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo);
    197         IContentView view = MainFormManager.MainForm.ShowContent(op);
    198         if (view != null) {
    199           view.ReadOnly = this.ReadOnly;
    200           view.Locked = this.Locked;
    201         }
     196        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     197        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(op, this);
     198        outermostViewHost.ActiveView.ReadOnly = ReadOnly;
     199        outermostViewHost.ActiveView.Locked = Locked;
    202200      }
    203201    }
  • branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs

    r10089 r10093  
    244244        var item = (IRun)itemsListView.SelectedItems[0].Tag;
    245245        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    246         var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
    247         if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) {
    248           var oldCrumbs = outermostViewHost.Breadcrumbs;
    249           var newCrumbs = BuildBreadcrumbTrail();
    250           mainForm.ShowContentInSpecificViewHost(item, outermostViewHost);
    251           outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     246        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true);
     247        if (outermostViewHost.HotlinkingEnabled) {
    252248          outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    253249          outermostViewHost.ActiveView.Locked = Locked;
     
    279275        var item = (IRun)itemsListView.SelectedItems[0].Tag;
    280276        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    281         var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
    282         var oldCrumbs = outermostViewHost.Breadcrumbs;
    283         var newCrumbs = BuildBreadcrumbTrail();
    284         mainForm.ShowContentInSpecificViewHost(item, outermostViewHost);
    285         outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     277        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this);
    286278        outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    287279        outermostViewHost.ActiveView.Locked = Locked;
     
    511503      }
    512504    }
    513     private IEnumerable<IContent> BuildBreadcrumbTrail() {
    514       var l = new LinkedList<IContent>();
    515       for (var control = (Control)this; control != null; control = control.Parent) {
    516         var vh = control as ViewHost;
    517         if (vh != null && vh.Content != null)
    518           l.AddFirst(vh.Content);
    519       }
    520       return l;
    521     }
    522505    #endregion
    523506  }
  • branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunView.cs

    r10089 r10093  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    2523using System.Windows.Forms;
    2624using HeuristicLab.Common;
     
    133131        var item = (IItem)listView.SelectedItems[0].Tag;
    134132        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    135         var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
    136         if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) {
    137           var oldCrumbs = outermostViewHost.Breadcrumbs;
    138           var newCrumbs = BuildBreadcrumbTrail();
    139           mainForm.ShowContentInSpecificViewHost(item, outermostViewHost);
    140           outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     133        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true);
     134        if (outermostViewHost.HotlinkingEnabled) {
    141135          outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    142136          outermostViewHost.ActiveView.Locked = Locked;
     
    156150        var item = (IItem)listView.SelectedItems[0].Tag;
    157151        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    158         var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
    159         var oldCrumbs = outermostViewHost.Breadcrumbs;
    160         var newCrumbs = BuildBreadcrumbTrail();
    161         mainForm.ShowContentInSpecificViewHost(item, outermostViewHost);
    162         outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     152        var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this);
    163153        outermostViewHost.ActiveView.ReadOnly = ReadOnly;
    164154        outermostViewHost.ActiveView.Locked = Locked;
     
    191181      }
    192182    }
    193     private IEnumerable<IContent> BuildBreadcrumbTrail() {
    194       var l = new LinkedList<IContent>();
    195       for (var control = (Control)this; control != null; control = control.Parent) {
    196         var vh = control as ViewHost;
    197         if (vh != null && vh.Content != null)
    198           l.AddFirst(vh.Content);
    199       }
    200       return l;
    201     }
    202183  }
    203184}
Note: See TracChangeset for help on using the changeset viewer.