Changeset 3670


Ignore:
Timestamp:
05/06/10 13:20:01 (12 years ago)
Author:
mkommend
Message:

corrected opening of views from the ViewHost (ticket #972)

Location:
trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/MainForm.cs

    r3557 r3670  
    222222
    223223    public IContentView ShowContent(IContent content) {
     224      Type viewType = MainFormManager.GetDefaultViewType(content.GetType());
     225      if (viewType != null)
     226        return ShowContent(content, viewType);
     227      return null;
     228    }
     229
     230    internal IContentView ShowContent(IContent content, Type viewType) {
     231      if (viewType == null)
     232        throw new ArgumentNullException("Could not create view of type null");
     233
    224234      IContentView view;
    225       if (this.ShowContentInViewHost)
    226         view = new ViewHost();
    227       else
    228         view = MainFormManager.CreateDefaultView(content.GetType());
     235      if (this.ShowContentInViewHost) {
     236        ViewHost viewHost = new ViewHost();
     237        viewHost.ViewType = viewType;
     238        view = viewHost;
     239      } else
     240        view = MainFormManager.CreateView(viewType);
    229241
    230242      if (view != null) {
  • trunk/sources/HeuristicLab.MainForm.WindowsForms/3.3/ViewHost.cs

    r3664 r3670  
    248248
    249249    private void viewsLabel_DoubleClick(object sender, EventArgs e) {
    250       IContentView view = MainFormManager.MainForm.ShowContent(this.Content);
    251       view.ReadOnly = this.ReadOnly;
    252       view.Locked = this.Locked;
     250      IContentView view = MainFormManager.GetMainForm<MainForm>().ShowContent(this.Content,this.ViewType);
     251      if (view != null) {
     252        view.ReadOnly = this.ReadOnly;
     253        view.Locked = this.Locked;
     254      }
    253255    }
    254256    private void viewContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) {
Note: See TracChangeset for help on using the changeset viewer.