Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/04/20 15:23:29 (5 years ago)
Author:
mkommend
Message:

#2028: Synchronized readonly state in ViewHost and its actively shown view.

File:
1 edited

Legend:

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

    r17180 r17585  
    170170    }
    171171
     172
    172173    private void OnViewTypeChanged() {
    173       if (viewType != null) {
    174         if (!ViewCanShowContent(viewType, Content))
    175           throw new InvalidOperationException(string.Format("View \"{0}\" cannot display content \"{1}\".",
    176                                                             viewType, Content.GetType()));
    177         IContentView view = MainFormManager.CreateView(viewType);
    178         view.Locked = Locked;
    179         view.ReadOnly = ReadOnly;
    180         ActiveView = view; //necessary to allow the views to change the status of the viewhost
    181         view.Content = Content;
    182 
    183         UpdateActiveMenuItem();
    184       }
     174      if (viewType == null) return;
     175      if (!ViewCanShowContent(viewType, Content))
     176        throw new InvalidOperationException(string.Format("View \"{0}\" cannot display content \"{1}\".", viewType, Content.GetType()));
     177
     178      IContentView view = MainFormManager.CreateView(viewType);
     179      view.Locked = Locked;
     180      view.ReadOnly = ReadOnly;
     181      ActiveView = view; //necessary to allow the views to change the status of the viewhost
     182      view.Content = Content;
     183
     184      UpdateActiveMenuItem();
     185
    185186    }
    186187
     
    188189      activeView.CaptionChanged += new EventHandler(activeView_CaptionChanged);
    189190      activeView.LockedChanged += new EventHandler(activeView_LockedChanged);
     191      activeView.ReadOnlyChanged += new EventHandler(activeView_ReadOnlyChanged);
    190192      activeView.Changed += new EventHandler(activeView_Changed);
    191193    }
     
    193195      activeView.CaptionChanged -= new EventHandler(activeView_CaptionChanged);
    194196      activeView.LockedChanged -= new EventHandler(activeView_LockedChanged);
     197      activeView.ReadOnlyChanged -= new EventHandler(activeView_ReadOnlyChanged);
    195198      activeView.Changed -= new EventHandler(activeView_Changed);
    196199    }
     
    202205      configurationLabel.Enabled = !activeView.Locked;
    203206    }
     207    private void activeView_ReadOnlyChanged(object sender, EventArgs e) {
     208      ReadOnly = activeView.ReadOnly;
     209    }
     210
    204211    private void activeView_Changed(object sender, EventArgs e) {
    205212      OnChanged();
     
    228235
    229236    #region forwarding of view events
    230     internal protected override void OnShown(ViewShownEventArgs e) {
     237    protected internal override void OnShown(ViewShownEventArgs e) {
    231238      base.OnShown(e);
    232239      View view = ActiveView as View;
     
    234241        view.OnShown(e);
    235242    }
    236     internal protected override void OnHidden(EventArgs e) {
     243    protected internal override void OnHidden(EventArgs e) {
    237244      base.OnHidden(e);
    238245      View view = ActiveView as View;
     
    240247        view.OnHidden(e);
    241248    }
    242     internal protected override void OnClosing(FormClosingEventArgs e) {
     249    protected internal override void OnClosing(FormClosingEventArgs e) {
    243250      base.OnClosing(e);
    244251      View view = ActiveView as View;
     
    246253        view.OnClosing(e);
    247254    }
    248     internal protected override void OnClosed(FormClosedEventArgs e) {
     255    protected internal override void OnClosed(FormClosedEventArgs e) {
    249256      base.OnClosed(e);
    250257      View view = ActiveView as View;
Note: See TracChangeset for help on using the changeset viewer.