Changeset 10093 for branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms
- Timestamp:
- 10/29/13 13:47:35 (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
r10042 r10093 66 66 Tag = bc 67 67 }; 68 label.Click += label_Click;68 ((LinkLabel)label).LinkClicked += label_LinkClicked; 69 69 } 70 70 labels.Add(label); … … 93 93 if (!labels.Any()) return; 94 94 var curLoc = new Point(3, 0); 95 var ellipsis = new L abel {95 var ellipsis = new LinkLabel { 96 96 Location = curLoc, 97 97 AutoSize = true, … … 113 113 if (i == labels.Count - 1) return; 114 114 i += 1 + i % 2; 115 ellipsis.Tag = breadcrumbs.ElementAt(i / 2); 116 ellipsis.LinkClicked += label_LinkClicked; 115 117 while (i < labels.Count) { 116 118 var l = labels[i++]; … … 121 123 } 122 124 123 private void label_ Click(object sender,EventArgs e) {125 private void label_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { 124 126 var label = (LinkLabel)sender; 125 127 var content = (IContent)label.Tag; 126 int crumbCount = breadcrumbs.Count; 127 while (breadcrumbs.Any()) { 128 var item = breadcrumbs.Last.Value; 129 if (item == content) break; 128 while (breadcrumbs.Any() && breadcrumbs.Last.Value != content) 130 129 breadcrumbs.RemoveLast(); 131 } 132 var targetViewHost = ViewHost; 133 if (crumbCount - breadcrumbs.Count > 0) { 134 for (var parent = Parent; parent != null; parent = parent.Parent) { 135 var vh = parent as ViewHost; 136 if (vh != null) targetViewHost = vh; 137 } 138 } 139 bool showBreadcrumbs = targetViewHost.ShowBreadcrumbs; 140 targetViewHost.Content = null; 130 var mainForm = MainFormManager.GetMainForm<MainForm>(); 131 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(ViewHost); 132 bool showBreadcrumbs = outermostViewHost.ShowBreadcrumbs; 133 outermostViewHost.Content = null; 141 134 var viewType = MainFormManager.GetDefaultViewType(content.GetType()); 142 targetViewHost.ViewType = viewType;143 targetViewHost.Content = content;144 targetViewHost.UpdateBreadcrumbTrail(targetViewHost.Breadcrumbs, breadcrumbs);145 targetViewHost.ShowBreadcrumbs = showBreadcrumbs;135 outermostViewHost.ViewType = viewType; 136 outermostViewHost.Content = content; 137 outermostViewHost.UpdateBreadcrumbTrail(outermostViewHost.Breadcrumbs, breadcrumbs); 138 outermostViewHost.ShowBreadcrumbs = showBreadcrumbs; 146 139 } 147 140 -
branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.cs
r10089 r10093 379 379 private void PerformOutermostViewHostDetection() { 380 380 var mainForm = MainFormManager.GetMainForm<MainForm>(); 381 if (mainForm == null) return; 381 382 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 382 383 isOutermostViewHost = outermostViewHost == this; -
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.