Changeset 10089


Ignore:
Timestamp:
10/28/13 17:50:31 (6 years ago)
Author:
jkarder
Message:

#2116:

  • added hotlinking functionality
  • added methods for outermost view host detection and manipulation
Location:
branches/Breadcrumbs
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ItemCollectionView.cs

    r10042 r10089  
    219219    #region ListView Events
    220220    protected virtual void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
    221       removeButton.Enabled = (Content != null) && !Content.IsReadOnly && !ReadOnly && itemsListView.SelectedItems.Count > 0;
     221      removeButton.Enabled = Content != null && !Content.IsReadOnly && !ReadOnly && itemsListView.SelectedItems.Count > 0;
    222222      AdjustListViewColumnSizes();
    223       if (showDetailsCheckBox.Checked) {
    224         if (itemsListView.SelectedItems.Count == 1) {
    225           T item = (T)itemsListView.SelectedItems[0].Tag;
    226           detailsGroupBox.Enabled = true;
    227           viewHost.Content = item;
     223      if (itemsListView.SelectedItems.Count == 1) {
     224        var item = (T)itemsListView.SelectedItems[0].Tag;
     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 }));
    228232        } else {
    229           viewHost.Content = null;
    230           detailsGroupBox.Enabled = false;
     233          if (showDetailsCheckBox.Checked) {
     234            detailsGroupBox.Enabled = true;
     235            viewHost.Content = item;
     236          } else {
     237            viewHost.Content = null;
     238            detailsGroupBox.Enabled = false;
     239          }
    231240        }
    232241      }
     
    245254    protected virtual void itemsListView_DoubleClick(object sender, EventArgs e) {
    246255      if (itemsListView.SelectedItems.Count == 1) {
    247         var item = itemsListView.SelectedItems[0].Tag as T;
    248         if (item != null) {
    249           ViewHost outmostViewHost = null;
    250           for (var control = Parent; control != null; control = control.Parent) {
    251             var vh = control as ViewHost;
    252             if (vh != null) outmostViewHost = vh;
    253           }
    254           if (outmostViewHost != null) {
    255             var oldCrumbs = outmostViewHost.Breadcrumbs;
    256             var newCrumbs = BuildBreadcrumbTrail();
    257             outmostViewHost.Content = null;
    258             var viewType = MainFormManager.GetDefaultViewType(item.GetType());
    259             outmostViewHost.ViewType = viewType;
    260             outmostViewHost.Content = item;
    261             outmostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
    262             outmostViewHost.ActiveView.ReadOnly = ReadOnly;
    263             outmostViewHost.ActiveView.Locked = Locked;
    264           }
    265         }
     256        var item = (T)itemsListView.SelectedItems[0].Tag;
     257        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 }));
     263        outermostViewHost.ActiveView.ReadOnly = ReadOnly;
     264        outermostViewHost.ActiveView.Locked = Locked;
    266265      }
    267266    }
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ItemListView.cs

    r10042 r10089  
    242242                             (Content != null) && !Content.IsReadOnly && !ReadOnly;
    243243      AdjustListViewColumnSizes();
    244 
    245       if (showDetailsCheckBox.Checked) {
    246         if (itemsListView.SelectedItems.Count == 1) {
    247           T item = (T)itemsListView.SelectedItems[0].Tag;
    248           detailsGroupBox.Enabled = true;
    249           viewHost.Content = item;
     244      if (itemsListView.SelectedItems.Count == 1) {
     245        var item = (T)itemsListView.SelectedItems[0].Tag;
     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 }));
     253          outermostViewHost.ActiveView.ReadOnly = ReadOnly;
     254          outermostViewHost.ActiveView.Locked = Locked;
    250255        } else {
    251           viewHost.Content = null;
    252           detailsGroupBox.Enabled = false;
     256          if (showDetailsCheckBox.Checked) {
     257            detailsGroupBox.Enabled = true;
     258            viewHost.Content = item;
     259          } else {
     260            viewHost.Content = null;
     261            detailsGroupBox.Enabled = false;
     262          }
    253263        }
    254264      }
     
    266276    protected virtual void itemsListView_DoubleClick(object sender, EventArgs e) {
    267277      if (itemsListView.SelectedItems.Count == 1) {
    268         var item = itemsListView.SelectedItems[0].Tag as T;
    269         if (item != null) {
    270           ViewHost outmostViewHost = null;
    271           for (var control = Parent; control != null; control = control.Parent) {
    272             var vh = control as ViewHost;
    273             if (vh != null) outmostViewHost = vh;
    274           }
    275           if (outmostViewHost != null) {
    276             var oldCrumbs = outmostViewHost.Breadcrumbs;
    277             var newCrumbs = BuildBreadcrumbTrail();
    278             outmostViewHost.Content = null;
    279             var viewType = MainFormManager.GetDefaultViewType(item.GetType());
    280             outmostViewHost.ViewType = viewType;
    281             outmostViewHost.Content = item;
    282             outmostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
    283             outmostViewHost.ActiveView.ReadOnly = ReadOnly;
    284             outmostViewHost.ActiveView.Locked = Locked;
    285           }
    286         }
     278        var item = (T)itemsListView.SelectedItems[0].Tag;
     279        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 }));
     285        outermostViewHost.ActiveView.ReadOnly = ReadOnly;
     286        outermostViewHost.ActiveView.Locked = Locked;
    287287      }
    288288    }
  • branches/Breadcrumbs/HeuristicLab.Core.Views/3.3/ParameterCollectionView.cs

    r10087 r10089  
    147147      }
    148148    }
    149     protected override void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
    150       base.itemsListView_SelectedIndexChanged(sender, e);
    151       SetEnabledStateOfControls();
     149    protected virtual void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
     150      removeButton.Enabled = Content != null && !Content.IsReadOnly && !ReadOnly && itemsListView.SelectedItems.Count > 0;
     151      AdjustListViewColumnSizes();
     152      if (itemsListView.SelectedItems.Count == 1) {
     153        var item = (IParameter)itemsListView.SelectedItems[0].Tag;
     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 }));
     161          outermostViewHost.ActiveView.ReadOnly = ReadOnly || (item.Hidden && !AllowEditingOfHiddenParameters);
     162          outermostViewHost.ActiveView.Locked = Locked;
     163        } else {
     164          if (showDetailsCheckBox.Checked) {
     165            detailsGroupBox.Enabled = true;
     166            viewHost.Content = item;
     167          } else {
     168            viewHost.Content = null;
     169            detailsGroupBox.Enabled = false;
     170          }
     171        }
     172      }
    152173    }
    153174    protected override void itemsListView_DoubleClick(object sender, EventArgs e) {
    154175      if (itemsListView.SelectedItems.Count == 1) {
    155         var item = itemsListView.SelectedItems[0].Tag as IParameter;
    156         if (item != null) {
    157           ViewHost outmostViewHost = null;
    158           for (var control = Parent; control != null; control = control.Parent) {
    159             var vh = control as ViewHost;
    160             if (vh != null) outmostViewHost = vh;
    161           }
    162           if (outmostViewHost != null) {
    163             var oldCrumbs = outmostViewHost.Breadcrumbs;
    164             var newCrumbs = BuildBreadcrumbTrail();
    165             outmostViewHost.Content = null;
    166             var viewType = MainFormManager.GetDefaultViewType(item.GetType());
    167             outmostViewHost.ViewType = viewType;
    168             outmostViewHost.Content = item;
    169             outmostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
    170             outmostViewHost.ActiveView.ReadOnly = ReadOnly || (item.Hidden && !AllowEditingOfHiddenParameters);
    171             outmostViewHost.ActiveView.Locked = Locked;
    172           }
    173         }
     176        var item = (IParameter)itemsListView.SelectedItems[0].Tag;
     177        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 }));
     183        outermostViewHost.ActiveView.ReadOnly = ReadOnly || (item.Hidden && !AllowEditingOfHiddenParameters);
     184        outermostViewHost.ActiveView.Locked = Locked;
    174185      }
    175186    }
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/Controls/ViewHost.cs

    r10042 r10089  
    5858    }
    5959
     60    public bool HotlinkingEnabled { get; set; }
     61
    6062    private IContentView cachedView;
    6163    private IContentView activeView;
     
    130132    }
    131133
    132     private bool isOutmostViewHost;
     134    private bool isOutermostViewHost;
    133135    public IEnumerable<IContent> Breadcrumbs { get { return breadcrumbControl.Breadcrumbs; } }
    134136
     
    210212    }
    211213    private void ViewHost_VisibleChanged(object sender, EventArgs e) {
    212       PerformOuterViewHostDetection();
     214      PerformOutermostViewHostDetection();
    213215    }
    214216    private void viewContextMenuStrip_ShowBreadcrumbsChanged(object sender, EventArgs e) {
     
    375377    }
    376378
    377     private void PerformOuterViewHostDetection() {
    378       var outmostViewHost = this;
    379       for (var parent = Parent; parent != null; parent = parent.Parent) {
    380         var vh = parent as ViewHost;
    381         if (vh != null) outmostViewHost = vh;
    382       }
    383       isOutmostViewHost = outmostViewHost == this;
    384       viewContextMenuStrip.ShowBreadcrumbsToolStripMenuItem.Checked = isOutmostViewHost;
     379    private void PerformOutermostViewHostDetection() {
     380      var mainForm = MainFormManager.GetMainForm<MainForm>();
     381      var outermostViewHost = mainForm.GetOutermostViewOfType<ViewHost>(this);
     382      isOutermostViewHost = outermostViewHost == this;
     383      viewContextMenuStrip.ShowBreadcrumbsToolStripMenuItem.Checked = isOutermostViewHost;
    385384    }
    386385    #endregion
  • branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3/MainForms/MainForm.cs

    r9905 r10089  
    223223    }
    224224
     225    public T GetOutermostViewOfType<T>(Control childControl) where T : class, IView {
     226      T outermostView = null;
     227      for (var control = childControl; control != null; control = control.Parent) {
     228        var vh = control as T;
     229        if (vh != null) outermostView = vh;
     230      }
     231      return outermostView;
     232    }
     233
    225234    public IContentView ShowContent(IContent content) {
    226235      if (content == null) throw new ArgumentNullException("Content cannot be null.");
     
    230239    }
    231240
    232     public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class,IContent {
     241    public IContentView ShowContent<T>(T content, bool reuseExistingView, IEqualityComparer<T> comparer = null) where T : class, IContent {
    233242      if (content == null) throw new ArgumentNullException("Content cannot be null.");
    234243      if (!reuseExistingView) return ShowContent(content);
     
    262271        return view;
    263272      }
     273    }
     274
     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;
    264281    }
    265282
     
    550567      try {
    551568        ((IActionUserInterfaceItem)item.Tag).Execute();
    552       }
    553       catch (Exception ex) {
     569      } catch (Exception ex) {
    554570        ErrorHandling.ShowErrorDialog((Control)MainFormManager.MainForm, ex);
    555571      }
  • branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionView.cs

    r10042 r10089  
    237237    #region ListView Events
    238238    private void itemsListView_SelectedIndexChanged(object sender, EventArgs e) {
    239       removeButton.Enabled = itemsListView.SelectedItems.Count > 0 && (Content != null) && !Content.IsReadOnly && !ReadOnly;
     239      removeButton.Enabled = Content != null && !Content.IsReadOnly && !ReadOnly && itemsListView.SelectedItems.Count > 0;
    240240      // for performance reason (multiple selection fires this handler for every selected item)
    241241      if (itemsListView.SelectedIndices.Count <= 1)
    242242        AdjustListViewColumnSizes();
    243       if (showDetailsCheckBox.Checked) {
    244         if (itemsListView.SelectedItems.Count == 1) {
    245           IRun item = (IRun)itemsListView.SelectedItems[0].Tag;
    246           detailsGroupBox.Enabled = true;
    247           viewHost.Content = item;
     243      if (itemsListView.SelectedItems.Count == 1) {
     244        var item = (IRun)itemsListView.SelectedItems[0].Tag;
     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 }));
     252          outermostViewHost.ActiveView.ReadOnly = ReadOnly;
     253          outermostViewHost.ActiveView.Locked = Locked;
    248254        } else {
    249           viewHost.Content = null;
    250           detailsGroupBox.Enabled = false;
     255          if (showDetailsCheckBox.Checked) {
     256            detailsGroupBox.Enabled = true;
     257            viewHost.Content = item;
     258          } else {
     259            viewHost.Content = null;
     260            detailsGroupBox.Enabled = false;
     261          }
    251262        }
    252263      }
     
    266277    private void itemsListView_DoubleClick(object sender, EventArgs e) {
    267278      if (itemsListView.SelectedItems.Count == 1) {
    268         var item = itemsListView.SelectedItems[0].Tag as IRun;
    269         if (item != null) {
    270           ViewHost outmostViewHost = null;
    271           for (var control = Parent; control != null; control = control.Parent) {
    272             var vh = control as ViewHost;
    273             if (vh != null) outmostViewHost = vh;
    274           }
    275           if (outmostViewHost != null) {
    276             var oldCrumbs = outmostViewHost.Breadcrumbs;
    277             var newCrumbs = BuildBreadcrumbTrail();
    278             outmostViewHost.Content = null;
    279             var viewType = MainFormManager.GetDefaultViewType(item.GetType());
    280             outmostViewHost.ViewType = viewType;
    281             outmostViewHost.Content = item;
    282             outmostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
    283             outmostViewHost.ActiveView.ReadOnly = ReadOnly;
    284             outmostViewHost.ActiveView.Locked = Locked;
    285           }
    286         }
     279        var item = (IRun)itemsListView.SelectedItems[0].Tag;
     280        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 }));
     286        outermostViewHost.ActiveView.ReadOnly = ReadOnly;
     287        outermostViewHost.ActiveView.Locked = Locked;
    287288      }
    288289    }
  • branches/Breadcrumbs/HeuristicLab.Optimization.Views/3.3/RunView.cs

    r10042 r10089  
    130130
    131131    private void listView_SelectedIndexChanged(object sender, EventArgs e) {
    132       if (showDetailsCheckBox.Checked) {
    133         if (listView.SelectedItems.Count == 1) {
    134           detailsGroupBox.Enabled = true;
    135           viewHost.Content = listView.SelectedItems[0].Tag as IContent;
     132      if (listView.SelectedItems.Count == 1) {
     133        var item = (IItem)listView.SelectedItems[0].Tag;
     134        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 }));
     141          outermostViewHost.ActiveView.ReadOnly = ReadOnly;
     142          outermostViewHost.ActiveView.Locked = Locked;
    136143        } else {
    137           viewHost.Content = null;
    138           detailsGroupBox.Enabled = false;
     144          if (showDetailsCheckBox.Checked) {
     145            detailsGroupBox.Enabled = true;
     146            viewHost.Content = item;
     147          } else {
     148            viewHost.Content = null;
     149            detailsGroupBox.Enabled = false;
     150          }
    139151        }
    140152      }
     
    142154    private void listView_DoubleClick(object sender, EventArgs e) {
    143155      if (listView.SelectedItems.Count == 1) {
    144         var item = listView.SelectedItems[0].Tag as IItem;
    145         if (item != null) {
    146           ViewHost outmostViewHost = null;
    147           for (var control = Parent; control != null; control = control.Parent) {
    148             var vh = control as ViewHost;
    149             if (vh != null) outmostViewHost = vh;
    150           }
    151           if (outmostViewHost != null) {
    152             var oldCrumbs = outmostViewHost.Breadcrumbs;
    153             var newCrumbs = BuildBreadcrumbTrail();
    154             outmostViewHost.Content = null;
    155             var viewType = MainFormManager.GetDefaultViewType(item.GetType());
    156             outmostViewHost.ViewType = viewType;
    157             outmostViewHost.Content = item;
    158             outmostViewHost.UpdateBreadcrumbTrail(oldCrumbs, newCrumbs.Concat(new[] { item }));
    159             outmostViewHost.ActiveView.ReadOnly = ReadOnly;
    160             outmostViewHost.ActiveView.Locked = Locked;
    161           }
    162         }
     156        var item = (IItem)listView.SelectedItems[0].Tag;
     157        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 }));
     163        outermostViewHost.ActiveView.ReadOnly = ReadOnly;
     164        outermostViewHost.ActiveView.Locked = Locked;
    163165      }
    164166    }
Note: See TracChangeset for help on using the changeset viewer.