Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/15/10 01:34:27 (14 years ago)
Author:
mkommend
Message:

implemented first version of View.ReadOnly and adapted some views to the new mechanism (ticket #973)

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

Legend:

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

    r3341 r3350  
    6969      Caption = "Item Collection";
    7070      while (itemsListView.Items.Count > 0) RemoveListViewItem(itemsListView.Items[0]);
    71       itemsListView.Enabled = false;
    72       detailsGroupBox.Enabled = false;
    7371      viewHost.Content = null;
    74       addButton.Enabled = false;
    75       sortAscendingButton.Enabled = false;
    76       sortDescendingButton.Enabled = false;
    77       removeButton.Enabled = false;
    78 
    7972      if (Content != null) {
    8073        Caption += " (" + Content.GetType().Name + ")";
    81         itemsListView.Enabled = true;
    82         addButton.Enabled = !Content.IsReadOnly;
    8374        foreach (T item in Content)
    8475          AddListViewItem(CreateListViewItem(item));
     76        SortItemsListView(SortOrder.Ascending);
     77      }
     78      SetEnableStateOfControls();
     79    }
     80
     81    protected override void OnReadOnlyChanged() {
     82      base.OnReadOnlyChanged();
     83      SetEnableStateOfControls();
     84    }
     85    private void SetEnableStateOfControls() {
     86      if (Content == null) {
     87        itemsListView.Enabled = false;
     88        detailsGroupBox.Enabled = false;
    8589        sortAscendingButton.Enabled = itemsListView.Items.Count > 0;
    8690        sortDescendingButton.Enabled = itemsListView.Items.Count > 0;
    87         SortItemsListView(SortOrder.Ascending);
     91        viewHost.Enabled = false;
     92        addButton.Enabled = false;
     93        removeButton.Enabled = false;
     94      } else {
     95        itemsListView.Enabled = true;
     96        detailsGroupBox.Enabled = true;
     97        sortAscendingButton.Enabled = true;
     98        sortDescendingButton.Enabled = true;
     99        viewHost.Enabled = true;
     100        viewHost.ReadOnly = ReadOnly;
     101        addButton.Enabled = !ReadOnly;
     102        removeButton.Enabled = !ReadOnly;
    88103      }
    89104    }
  • trunk/sources/HeuristicLab.Core.Views/3.3/NamedItemView.cs

    r2917 r3350  
    6666        Caption = "NamedItem";
    6767        nameTextBox.Text = "-";
    68         nameTextBox.Enabled = false;
    6968        descriptionTextBox.Text = "";
    70         descriptionTextBox.Enabled = false;
    7169        toolTip.SetToolTip(descriptionTextBox, string.Empty);
    7270      } else {
    7371        Caption = Content.Name + " (" + Content.GetType().Name + ")";
    7472        nameTextBox.Text = Content.Name;
    75         nameTextBox.ReadOnly = !Content.CanChangeName;
     73        descriptionTextBox.Text = Content.Description;
     74        toolTip.SetToolTip(descriptionTextBox, Content.Description);
     75      }
     76      SetEnableStateOfControls();
     77    }
     78
     79    protected override void OnReadOnlyChanged() {
     80      base.OnReadOnlyChanged();
     81      SetEnableStateOfControls();
     82    }
     83    private void SetEnableStateOfControls() {
     84      if (Content == null) {
     85        nameTextBox.Enabled = false;
     86        descriptionTextBox.Enabled = false;
     87      } else {
    7688        nameTextBox.Enabled = true;
    77         descriptionTextBox.Text = Content.Description;
    78         descriptionTextBox.ReadOnly = !Content.CanChangeDescription;
     89        nameTextBox.ReadOnly = ReadOnly || !Content.CanChangeName; ;
    7990        descriptionTextBox.Enabled = true;
    80         toolTip.SetToolTip(descriptionTextBox, Content.Description);
     91        descriptionTextBox.ReadOnly = ReadOnly || !Content.CanChangeDescription;
    8192      }
    8293    }
Note: See TracChangeset for help on using the changeset viewer.