Changeset 10093 for branches/Breadcrumbs
- Timestamp:
- 10/29/13 13:47:35 (11 years ago)
- Location:
- branches/Breadcrumbs
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs
r10089 r10093 224 224 var item = (T)itemsListView.SelectedItems[0].Tag; 225 225 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 226 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 227 if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) { 228 var oldCrumbs = outermostViewHost.Breadcrumbs; 229 var newCrumbs = BuildBreadcrumbTrail(); 230 mainForm.ShowContentInSpecificViewHost(item, outermostViewHost); 231 outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item })); 232 } else { 226 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true); 227 if (!outermostViewHost.HotlinkingEnabled) { 233 228 if (showDetailsCheckBox.Checked) { 234 229 detailsGroupBox.Enabled = true; … … 256 251 var item = (T)itemsListView.SelectedItems[0].Tag; 257 252 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 258 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 259 var oldCrumbs = outermostViewHost.Breadcrumbs; 260 var newCrumbs = BuildBreadcrumbTrail(); 261 mainForm.ShowContentInSpecificViewHost(item, outermostViewHost); 262 outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item })); 253 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this); 263 254 outermostViewHost.ActiveView.ReadOnly = ReadOnly; 264 255 outermostViewHost.ActiveView.Locked = Locked; … … 449 440 } 450 441 } 451 protected virtual IEnumerable<IContent> BuildBreadcrumbTrail() {452 var l = new LinkedList<IContent>();453 for (var control = (Control)this; control != null; control = control.Parent) {454 var vh = control as ViewHost;455 if (vh != null && vh.Content != null)456 l.AddFirst(vh.Content);457 }458 return l;459 }460 442 #endregion 461 443 } -
branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ItemListView.cs
r10089 r10093 245 245 var item = (T)itemsListView.SelectedItems[0].Tag; 246 246 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 247 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 248 if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) { 249 var oldCrumbs = outermostViewHost.Breadcrumbs; 250 var newCrumbs = BuildBreadcrumbTrail(); 251 mainForm.ShowContentInSpecificViewHost(item, outermostViewHost); 252 outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item })); 247 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true); 248 if (outermostViewHost.HotlinkingEnabled) { 253 249 outermostViewHost.ActiveView.ReadOnly = ReadOnly; 254 250 outermostViewHost.ActiveView.Locked = Locked; … … 278 274 var item = (T)itemsListView.SelectedItems[0].Tag; 279 275 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 280 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 281 var oldCrumbs = outermostViewHost.Breadcrumbs; 282 var newCrumbs = BuildBreadcrumbTrail(); 283 mainForm.ShowContentInSpecificViewHost(item, outermostViewHost); 284 outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item })); 276 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this); 285 277 outermostViewHost.ActiveView.ReadOnly = ReadOnly; 286 278 outermostViewHost.ActiveView.Locked = Locked; … … 516 508 } 517 509 } 518 protected virtual IEnumerable<IContent> BuildBreadcrumbTrail() {519 var l = new LinkedList<IContent>();520 for (var control = (Control)this; control != null; control = control.Parent) {521 var vh = control as ViewHost;522 if (vh != null && vh.Content != null)523 l.AddFirst(vh.Content);524 }525 return l;526 }527 510 #endregion 528 511 } -
branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ParameterCollectionView.cs
r10089 r10093 153 153 var item = (IParameter)itemsListView.SelectedItems[0].Tag; 154 154 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 155 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 156 if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) { 157 var oldCrumbs = outermostViewHost.Breadcrumbs; 158 var newCrumbs = BuildBreadcrumbTrail(); 159 mainForm.ShowContentInSpecificViewHost(item, outermostViewHost); 160 outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item })); 155 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true); 156 if (outermostViewHost.HotlinkingEnabled) { 161 157 outermostViewHost.ActiveView.ReadOnly = ReadOnly || (item.Hidden && !AllowEditingOfHiddenParameters); 162 158 outermostViewHost.ActiveView.Locked = Locked; … … 176 172 var item = (IParameter)itemsListView.SelectedItems[0].Tag; 177 173 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 178 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 179 var oldCrumbs = outermostViewHost.Breadcrumbs; 180 var newCrumbs = BuildBreadcrumbTrail(); 181 mainForm.ShowContentInSpecificViewHost(item, outermostViewHost); 182 outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item })); 174 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this); 183 175 outermostViewHost.ActiveView.ReadOnly = ReadOnly || (item.Hidden && !AllowEditingOfHiddenParameters); 184 176 outermostViewHost.ActiveView.Locked = Locked; -
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 -
branches/Breadcrumbs/HeuristicLab.Operators.Views.GraphVisualization.Views/3.3/OperatorGraphView.cs
r9456 r10093 140 140 if (shapeInfo != null) { 141 141 IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo); 142 IContentView view = MainFormManager.MainForm.ShowContent(op); 143 if (view != null) { 144 view.ReadOnly = this.ReadOnly; 145 view.Locked = this.Locked; 146 } 142 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 143 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(op, this); 144 outermostViewHost.ActiveView.ReadOnly = ReadOnly; 145 outermostViewHost.ActiveView.Locked = Locked; 147 146 HandledMouseEventArgs eventArgs = e as HandledMouseEventArgs; 148 147 if (eventArgs != null) … … 195 194 if (shapeInfo != null) { 196 195 IOperator op = this.VisualizationInfo.GetOperatorForShapeInfo(shapeInfo); 197 IContentView view = MainFormManager.MainForm.ShowContent(op); 198 if (view != null) { 199 view.ReadOnly = this.ReadOnly; 200 view.Locked = this.Locked; 201 } 196 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 197 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(op, this); 198 outermostViewHost.ActiveView.ReadOnly = ReadOnly; 199 outermostViewHost.ActiveView.Locked = Locked; 202 200 } 203 201 } -
branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs
r10089 r10093 244 244 var item = (IRun)itemsListView.SelectedItems[0].Tag; 245 245 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 246 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 247 if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) { 248 var oldCrumbs = outermostViewHost.Breadcrumbs; 249 var newCrumbs = BuildBreadcrumbTrail(); 250 mainForm.ShowContentInSpecificViewHost(item, outermostViewHost); 251 outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item })); 246 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true); 247 if (outermostViewHost.HotlinkingEnabled) { 252 248 outermostViewHost.ActiveView.ReadOnly = ReadOnly; 253 249 outermostViewHost.ActiveView.Locked = Locked; … … 279 275 var item = (IRun)itemsListView.SelectedItems[0].Tag; 280 276 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 281 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 282 var oldCrumbs = outermostViewHost.Breadcrumbs; 283 var newCrumbs = BuildBreadcrumbTrail(); 284 mainForm.ShowContentInSpecificViewHost(item, outermostViewHost); 285 outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item })); 277 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this); 286 278 outermostViewHost.ActiveView.ReadOnly = ReadOnly; 287 279 outermostViewHost.ActiveView.Locked = Locked; … … 511 503 } 512 504 } 513 private IEnumerable<IContent> BuildBreadcrumbTrail() {514 var l = new LinkedList<IContent>();515 for (var control = (Control)this; control != null; control = control.Parent) {516 var vh = control as ViewHost;517 if (vh != null && vh.Content != null)518 l.AddFirst(vh.Content);519 }520 return l;521 }522 505 #endregion 523 506 } -
branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunView.cs
r10089 r10093 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Linq;25 23 using System.Windows.Forms; 26 24 using HeuristicLab.Common; … … 133 131 var item = (IItem)listView.SelectedItems[0].Tag; 134 132 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 135 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 136 if (outermostViewHost != null && outermostViewHost.HotlinkingEnabled) { 137 var oldCrumbs = outermostViewHost.Breadcrumbs; 138 var newCrumbs = BuildBreadcrumbTrail(); 139 mainForm.ShowContentInSpecificViewHost(item, outermostViewHost); 140 outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item })); 133 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this, true); 134 if (outermostViewHost.HotlinkingEnabled) { 141 135 outermostViewHost.ActiveView.ReadOnly = ReadOnly; 142 136 outermostViewHost.ActiveView.Locked = Locked; … … 156 150 var item = (IItem)listView.SelectedItems[0].Tag; 157 151 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 158 var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this); 159 var oldCrumbs = outermostViewHost.Breadcrumbs; 160 var newCrumbs = BuildBreadcrumbTrail(); 161 mainForm.ShowContentInSpecificViewHost(item, outermostViewHost); 162 outermostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item })); 152 var outermostViewHost = mainForm.ShowContentInOutermostViewHost(item, this); 163 153 outermostViewHost.ActiveView.ReadOnly = ReadOnly; 164 154 outermostViewHost.ActiveView.Locked = Locked; … … 191 181 } 192 182 } 193 private IEnumerable<IContent> BuildBreadcrumbTrail() {194 var l = new LinkedList<IContent>();195 for (var control = (Control)this; control != null; control = control.Parent) {196 var vh = control as ViewHost;197 if (vh != null && vh.Content != null)198 l.AddFirst(vh.Content);199 }200 return l;201 }202 183 } 203 184 }
Note: See TracChangeset
for help on using the changeset viewer.