Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/27/14 09:35:43 (9 years ago)
Author:
jkarder
Message:

#2116: reverted to r10041

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r10103 r11591  
    223223    }
    224224
    225     public T GetOutermostControlOfType<T>(Control childControl) where T : Control {
    226       if (childControl == null) throw new ArgumentNullException("childControl", "ChildControl cannot be null.");
    227 
    228       T outermostControl = null;
    229       for (var control = childControl; control != null; control = control.Parent) {
    230         var c = control as T;
    231         if (c != null) outermostControl = c;
    232       }
    233       return outermostControl;
    234     }
    235 
    236225    public IContentView ShowContent(IContent content) {
    237226      if (content == null) throw new ArgumentNullException("Content cannot be null.");
     
    241230    }
    242231
    243     public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class, IContent {
     232    public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class,IContent {
    244233      if (content == null) throw new ArgumentNullException("Content cannot be null.");
    245234      if (!reuseExistingView) return ShowContent(content);
     
    273262        return view;
    274263      }
    275     }
    276 
    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 = GetOutermostControlOfType<ViewHost>(childControl);
    282       if (outermostViewHost == null) return null;
    283 
    284       if (!requireHotlinking || outermostViewHost.HotlinkingEnabled) {
    285         var oldCrumbs = outermostViewHost.Breadcrumbs;
    286         var newCrumbs = new LinkedList<IContent>();
    287         for (var control = childControl; control != null; control = control.Parent) {
    288           var vh = control as ViewHost;
    289           if (vh != null && vh.Content != null)
    290             newCrumbs.AddFirst(vh.Content);
    291         }
    292         bool showBreadcrumbs = outermostViewHost.ShowBreadcrumbs;
    293         outermostViewHost.Content = null;
    294         var viewType = MainFormManager.GetDefaultViewType(content.GetType());
    295         outermostViewHost.ViewType = viewType;
    296         outermostViewHost.Content = content;
    297         outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { content }));
    298         outermostViewHost.ShowBreadcrumbs = showBreadcrumbs;
    299       }
    300       return outermostViewHost;
    301264    }
    302265
     
    587550      try {
    588551        ((IActionUserInterfaceItem)item.Tag).Execute();
    589       } catch (Exception ex) {
     552      }
     553      catch (Exception ex) {
    590554        ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, ex);
    591555      }
Note: See TracChangeset for help on using the changeset viewer.