Changeset 10093 for branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
- Timestamp:
- 10/29/13 13:47:35 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
r10089 r10093 224 224 225 225 public T GetOutermostViewOfType<T>(Control childControl) where T : class, IView { 226 if (childControl == null) throw new ArgumentNullException("childControl", "ChildControl cannot be null."); 227 226 228 T outermostView = null; 227 229 for (var control = childControl; control != null; control = control.Parent) { … … 273 275 } 274 276 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; 281 302 } 282 303
Note: See TracChangeset
for help on using the changeset viewer.