Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1401


Ignore:
Timestamp:
03/24/09 11:28:23 (15 years ago)
Author:
epitzer
Message:

Initialize GUI with current configuration form ConfigurationService. (#506)

Location:
branches/New Persistence Exploration/Persistence
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.cs

    r1400 r1401  
    88using HeuristicLab.Persistence.Interfaces;
    99using System.Text;
     10using HeuristicLab.Persistence.Default.Decomposers;
    1011
    1112namespace HeuristicLab.Persistence.GUI {
     
    2627      initializeDecomposerList();
    2728      initializeFormatterPages();
     29      ConfigurationService.Instance.DefineConfiguration(
     30        XmlFormat.Instance,
     31        new Configuration(
     32          new Dictionary<Type, IFormatter> {{typeof (bool), new FakeBoolean2XmlFormatter()}},
     33          new List<IDecomposer>{new ArrayDecomposer(), new DictionaryDecomposer()}));         
     34      initializeFromConfigurationService();
     35    }
     36
     37    private void initializeFromConfigurationService() {
     38      foreach ( IFormat format in ConfigurationService.Instance.Formatters.Keys ) {
     39        Configuration config = ConfigurationService.Instance.GetConfiguration(format);
     40        foreach (ListViewItem item in decomposerList.Items) {
     41          if (item != null) {
     42            string name = item.Tag.GetType().AssemblyQualifiedName;
     43            item.Checked =
     44              config.Decomposers.Count(
     45                d => d.GetType().AssemblyQualifiedName == name) > 0;
     46             
     47          }
     48        }
     49        foreach ( TabPage page in formatterTabs.TabPages ) {
     50          if (page.Tag == format) {
     51            DataGridView gridView = (DataGridView)page.Controls.Find("GridView", false)[0];
     52            foreach ( DataGridViewRow row in gridView.Rows ) {
     53              if (row.Cells["Type"] != null) {
     54                IFormatter formatter = config.GetFormatter(typeNameTable[(string) row.Cells["Type"].Value]);
     55                if (formatter == null) {
     56                  row.Cells["Active"].Value = false;
     57                } else {
     58                  foreach (var pair in formatterTable) {
     59                    if ( pair.Value.GetType().AssemblyQualifiedName == formatter.GetType().AssemblyQualifiedName ) {
     60                      row.Cells["Formatter"].Value = pair.Key;
     61                      row.Cells["Active"].Value = true;
     62                      break;
     63                    }                   
     64                  }                               
     65                }
     66              }
     67              break;
     68            }
     69          }
     70        }       
     71      }
    2872    }
    2973
     
    3478        formatterTabs.TabPages.Add(page);
    3579        DataGridView gridView = new DataGridView {
     80          Name = "GridView",
    3681          Dock = DockStyle.Fill,
    3782          EditMode = DataGridViewEditMode.EditOnEnter,
     
    3984          AllowUserToDeleteRows = false,
    4085          AllowUserToResizeRows = false,
    41           Name = "GridView",
     86          AllowUserToOrderColumns = true,
    4287        };
    43         gridView.CellValueChanged += gridView_CellValueChanged;
     88        gridView.CellValueChanged += gridView_CellValueChanged;       
    4489        gridView.Columns.Add(new DataGridViewTextBoxColumn {
    4590          Name = "Type", ReadOnly = true,
     
    4792        });
    4893        gridView.Columns.Add(new DataGridViewCheckBoxColumn {
     94          Name = "Active",
    4995          AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells});
    5096        gridView.Columns.Add(new DataGridViewComboBoxColumn {
     97          Name = "Formatter",
    5198          AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill});
    5299        page.Controls.Add(gridView);
     
    60107      foreach ( var formatterMapping in formatterMap ) {
    61108        var row = gridView.Rows[gridView.Rows.Add()];
    62         row.Cells[0].Value = formatterMapping.Key;
    63         row.Cells[0].ToolTipText = formatterMapping.Key;
    64         row.Cells[1].Value = true;
     109        row.Cells["Type"].Value = formatterMapping.Key;
     110        row.Cells["Active"].ToolTipText = formatterMapping.Key;
     111        row.Cells["Formatter"].Value = true;
    65112        var comboBoxCell = (DataGridViewComboBoxCell) row.Cells[2];         
    66113        foreach ( var formatter in formatterMapping.Value ) {
     
    207254          if (controls.Length == 1) {
    208255            foreach (DataGridViewRow row in ((DataGridView) controls[0]).Rows) {
    209               if ( row.Cells[0].Value != null &&
    210                    row.Cells[1].Value != null &&
    211                    row.Cells[2].Value != null &&
    212                    (bool)row.Cells[1].Value == true ) {
     256              if ( row.Cells["Type"].Value != null &&
     257                   row.Cells["Active"].Value != null &&
     258                   row.Cells["Formatter"].Value != null &&
     259                   (bool)row.Cells["Active"].Value == true ) {
    213260                formatters.Add(
    214                   typeNameTable[(string)row.Cells[0].Value],                 
    215                   formatterTable[(string)row.Cells[2].Value]);
     261                  typeNameTable[(string)row.Cells["Type"].Value],                 
     262                  formatterTable[(string)row.Cells["Formatter"].Value]);
    216263              }
    217264            }
  • branches/New Persistence Exploration/Persistence/Persistence/Core/Configuration.cs

    r1400 r1401  
    3131    }
    3232
     33    public IEnumerable<IDecomposer> Decomposers {
     34      get { return decomposers; }
     35    }
     36
    3337    public IFormatter GetFormatter(Type type) {     
    3438      IFormatter formatter;
Note: See TracChangeset for help on using the changeset viewer.