Changeset 11557


Ignore:
Timestamp:
11/19/14 14:26:07 (7 years ago)
Author:
ascheibe
Message:

#2158 improved error handling for nested views

Location:
trunk/sources/HeuristicLab.Core.Views/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemView.cs

    r11555 r11557  
    4747
    4848      if (CountParentControls() > MaximumNestingLevel) {
    49         NestingLevelErrorControl errorControl = new NestingLevelErrorControl();
     49        //capture content, needed because it is set at a later time
     50        NestingLevelErrorControl errorControl = new NestingLevelErrorControl(() => Content, this.GetType());
    5051        errorControl.Dock = DockStyle.Fill;
    51         //capture content, needed because it is set at a later time
    52         errorControl.Content = () => Content;
    5352
    5453        Controls.Clear();
  • trunk/sources/HeuristicLab.Core.Views/3.3/NestingLevelErrorControl.cs

    r11555 r11557  
    2828  public partial class NestingLevelErrorControl : UserControl {
    2929    public Func<IContent> Content { get; set; }
     30    public Type ViewType { get; set; }
    3031
    3132    public NestingLevelErrorControl() {
     
    3334    }
    3435
     36    public NestingLevelErrorControl(Func<IContent> content, Type viewType)
     37      : this() {
     38      Content = content;
     39      ViewType = viewType;
     40    }
     41
    3542    private void showButton_Click(object sender, System.EventArgs e) {
    36       if (Content != null) {
    37         if (MainFormManager.MainForm.ShowContent(Content()) == null) {
    38           using (TypeSelectorDialog dialog = new TypeSelectorDialog()) {
    39             dialog.Caption = "Unable to find view for content. Please choose a appropriate view.";
    40             dialog.TypeSelector.Configure(typeof(IContentView), false, false);
    41 
    42             if (dialog.ShowDialog(this) == DialogResult.OK) {
    43               MainFormManager.MainForm.ShowContent(Content(), dialog.TypeSelector.SelectedType);
    44             }
    45           }
    46         }
     43      if (Content != null && ViewType != null) {
     44        MainFormManager.MainForm.ShowContent(Content(), ViewType);
    4745      }
    4846    }
Note: See TracChangeset for help on using the changeset viewer.