Changeset 10103 for branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms
- Timestamp:
- 11/04/13 10:15:31 (11 years ago)
- Location:
- branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/BreadcrumbControl.cs
r10093 r10103 129 129 breadcrumbs.RemoveLast(); 130 130 var mainForm = MainFormManager.GetMainForm<MainForm>(); 131 var outermostViewHost = mainForm.GetOutermost ViewOfType<ViewHost>(ViewHost);131 var outermostViewHost = mainForm.GetOutermostControlOfType<ViewHost>(ViewHost); 132 132 bool showBreadcrumbs = outermostViewHost.ShowBreadcrumbs; 133 133 outermostViewHost.Content = null; -
branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.cs
r10093 r10103 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel; 24 25 using System.Drawing; 25 26 using System.Linq; … … 41 42 viewsLabel.Visible = false; 42 43 viewsLabelVisible = true; 44 IsValidOutermostViewhost = true; 43 45 44 46 breadcrumbControl.ViewHost = this; … … 59 61 60 62 public bool HotlinkingEnabled { get; set; } 63 64 [DefaultValue(true)] 65 public bool IsValidOutermostViewhost { get; set; } 61 66 62 67 private IContentView cachedView; … … 132 137 } 133 138 134 private bool isOutermostViewHost;135 139 public IEnumerable<IContent> Breadcrumbs { get { return breadcrumbControl.Breadcrumbs; } } 136 140 … … 281 285 282 286 private void UpdateBreadcrumbControl() { 283 breadcrumbControl.Visible = ShowBreadcrumbs ;287 breadcrumbControl.Visible = ShowBreadcrumbs && Content != null; 284 288 if (ShowBreadcrumbs) 285 289 UpdateBreadcrumbTrail(breadcrumbControl.Breadcrumbs, BuildBreadcrumbTrail()); … … 378 382 379 383 private void PerformOutermostViewHostDetection() { 384 if (!IsValidOutermostViewhost) return; 380 385 var mainForm = MainFormManager.GetMainForm<MainForm>(); 381 if (mainForm == null) return; 382 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 383 isOutermostViewHost = outermostViewHost == this; 384 viewContextMenuStrip.ShowBreadcrumbsToolStripMenuItem.Checked = isOutermostViewHost; 386 if (mainForm == null) return; // needed for designer 387 var outermostViewHost = mainForm.GetOutermostControlOfType<ViewHost>(this); 388 viewContextMenuStrip.ShowBreadcrumbsToolStripMenuItem.Checked = outermostViewHost == this; 385 389 } 386 390 #endregion -
branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs
r10093 r10103 223 223 } 224 224 225 public T GetOutermost ViewOfType<T>(Control childControl) where T : class, IView{225 public T GetOutermostControlOfType<T>(Control childControl) where T : Control { 226 226 if (childControl == null) throw new ArgumentNullException("childControl", "ChildControl cannot be null."); 227 227 228 T outermost View= null;228 T outermostControl = null; 229 229 for (var control = childControl; control != null; control = control.Parent) { 230 var vh= control as T;231 if ( vh != null) outermostView = vh;232 } 233 return outermost View;230 var c = control as T; 231 if (c != null) outermostControl = c; 232 } 233 return outermostControl; 234 234 } 235 235 … … 279 279 if (childControl == null) throw new ArgumentNullException("childControl", "ChildControl cannot be null."); 280 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"); 281 var outermostViewHost = GetOutermostControlOfType<ViewHost>(childControl); 282 if (outermostViewHost == null) return null; 284 283 285 284 if (!requireHotlinking || outermostViewHost.HotlinkingEnabled) {
Note: See TracChangeset
for help on using the changeset viewer.