Free cookie consent management tool by TermsFeed Policy Generator

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

#2116:

  • added hotlinking functionality
  • added methods for outermost view host detection and manipulation
Location:
branches/Breadcrumbs/HeuristicLab.MainForm.WindowsForms/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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      }
Note: See TracChangeset for help on using the changeset viewer.