Changeset 11591 for branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
- Timestamp:
- 11/27/14 09:35:43 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
r10103 r11591 223 223 } 224 224 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 236 225 public IContentView ShowContent(IContent content) { 237 226 if (content == null) throw new ArgumentNullException("Content cannot be null."); … … 241 230 } 242 231 243 public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class, 232 public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class,IContent { 244 233 if (content == null) throw new ArgumentNullException("Content cannot be null."); 245 234 if (!reuseExistingView) return ShowContent(content); … … 273 262 return view; 274 263 } 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;301 264 } 302 265 … … 587 550 try { 588 551 ((IActionUserInterfaceItem)item.Tag).Execute(); 589 } catch (Exception ex) { 552 } 553 catch (Exception ex) { 590 554 ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, ex); 591 555 }
Note: See TracChangeset
for help on using the changeset viewer.