Changeset 11555


Ignore:
Timestamp:
11/17/14 16:05:14 (5 years ago)
Author:
ascheibe
Message:

#2158 added error handling for view nesting problem

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

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core.Views/3.3/HeuristicLab.Core.Views-3.3.csproj

    r8600 r11555  
    147147      <DependentUpon>LogView.cs</DependentUpon>
    148148    </Compile>
     149    <Compile Include="NestingLevelErrorControl.cs">
     150      <SubType>UserControl</SubType>
     151    </Compile>
     152    <Compile Include="NestingLevelErrorControl.Designer.cs">
     153      <DependentUpon>NestingLevelErrorControl.cs</DependentUpon>
     154    </Compile>
    149155    <Compile Include="Plugin.cs" />
    150156    <Compile Include="VariableValueView.cs">
     
    378384  -->
    379385  <PropertyGroup>
    380    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     386    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    381387set ProjectDir=$(ProjectDir)
    382388set SolutionDir=$(SolutionDir)
     
    385391call PreBuildEvent.cmd
    386392</PreBuildEvent>
    387 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     393    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    388394export ProjectDir=$(ProjectDir)
    389395export SolutionDir=$(SolutionDir)
  • trunk/sources/HeuristicLab.Core.Views/3.3/ItemView.cs

    r11171 r11555  
    2020#endregion
    2121
     22using System;
     23using System.Windows.Forms;
    2224using HeuristicLab.MainForm.WindowsForms;
    2325
     
    2729  /// </summary>
    2830  public partial class ItemView : AsynchronousContentView {
     31    public const int MaximumNestingLevel = 37;
     32
    2933    public new IItem Content {
    3034      get { return (IItem)base.Content; }
     
    3842      InitializeComponent();
    3943    }
     44
     45    protected override void OnInitialized(EventArgs e) {
     46      base.OnInitialized(e);
     47
     48      if (CountParentControls() > MaximumNestingLevel) {
     49        NestingLevelErrorControl errorControl = new NestingLevelErrorControl();
     50        errorControl.Dock = DockStyle.Fill;
     51        //capture content, needed because it is set at a later time
     52        errorControl.Content = () => Content;
     53
     54        Controls.Clear();
     55        Controls.Add(errorControl);
     56      }
     57    }
     58
     59    private int CountParentControls() {
     60      int cnt = 0;
     61      Control parent = Parent;
     62      while (parent != null) {
     63        parent = parent.Parent;
     64        cnt++;
     65      }
     66      return cnt;
     67    }
    4068  }
    4169}
Note: See TracChangeset for help on using the changeset viewer.