Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/15/13 16:11:27 (11 years ago)
Author:
jkarder
Message:

#2116: added prototype of a breadcrumb navigation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs

    r9613 r10042  
    266266    private void itemsListView_DoubleClick(object sender, EventArgs e) {
    267267      if (itemsListView.SelectedItems.Count == 1) {
    268         IRun item = itemsListView.SelectedItems[0].Tag as IRun;
     268        var item = itemsListView.SelectedItems[0].Tag as IRun;
    269269        if (item != null) {
    270           IContentView view = MainFormManager.MainForm.ShowContent(item);
    271           if (view != null) {
    272             view.ReadOnly = ReadOnly;
    273             view.Locked = Locked;
     270          ViewHost outmostViewHost = null;
     271          for (var control = Parent; control != null; control = control.Parent) {
     272            var vh = control as ViewHost;
     273            if (vh != null) outmostViewHost = vh;
     274          }
     275          if (outmostViewHost != null) {
     276            var oldCrumbs = outmostViewHost.Breadcrumbs;
     277            var newCrumbs = BuildBreadcrumbTrail();
     278            outmostViewHost.Content = null;
     279            var viewType = MainFormManager.GetDefaultViewType(item.GetType());
     280            outmostViewHost.ViewType = viewType;
     281            outmostViewHost.Content = item;
     282            outmostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
     283            outmostViewHost.ActiveView.ReadOnly = ReadOnly;
     284            outmostViewHost.ActiveView.Locked = Locked;
    274285          }
    275286        }
     
    385396      try {
    386397        RunCollection.Modify();
    387       }
    388       finally {
     398      } finally {
    389399        ReadOnly = false;
    390400      }
     
    500510      }
    501511    }
     512    private IEnumerable<IContent> BuildBreadcrumbTrail() {
     513      var l = new LinkedList<IContent>();
     514      for (var control = (Control)this; control != null; control = control.Parent) {
     515        var vh = control as ViewHost;
     516        if (vh != null && vh.Content != null)
     517          l.AddFirst(vh.Content);
     518      }
     519      return l;
     520    }
    502521    #endregion
    503522  }
Note: See TracChangeset for help on using the changeset viewer.