Changeset 1401
- Timestamp:
- 03/24/09 11:28:23 (16 years ago)
- 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 8 8 using HeuristicLab.Persistence.Interfaces; 9 9 using System.Text; 10 using HeuristicLab.Persistence.Default.Decomposers; 10 11 11 12 namespace HeuristicLab.Persistence.GUI { … … 26 27 initializeDecomposerList(); 27 28 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 } 28 72 } 29 73 … … 34 78 formatterTabs.TabPages.Add(page); 35 79 DataGridView gridView = new DataGridView { 80 Name = "GridView", 36 81 Dock = DockStyle.Fill, 37 82 EditMode = DataGridViewEditMode.EditOnEnter, … … 39 84 AllowUserToDeleteRows = false, 40 85 AllowUserToResizeRows = false, 41 Name = "GridView",86 AllowUserToOrderColumns = true, 42 87 }; 43 gridView.CellValueChanged += gridView_CellValueChanged; 88 gridView.CellValueChanged += gridView_CellValueChanged; 44 89 gridView.Columns.Add(new DataGridViewTextBoxColumn { 45 90 Name = "Type", ReadOnly = true, … … 47 92 }); 48 93 gridView.Columns.Add(new DataGridViewCheckBoxColumn { 94 Name = "Active", 49 95 AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells}); 50 96 gridView.Columns.Add(new DataGridViewComboBoxColumn { 97 Name = "Formatter", 51 98 AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill}); 52 99 page.Controls.Add(gridView); … … 60 107 foreach ( var formatterMapping in formatterMap ) { 61 108 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; 65 112 var comboBoxCell = (DataGridViewComboBoxCell) row.Cells[2]; 66 113 foreach ( var formatter in formatterMapping.Value ) { … … 207 254 if (controls.Length == 1) { 208 255 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 ) { 213 260 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]); 216 263 } 217 264 } -
branches/New Persistence Exploration/Persistence/Persistence/Core/Configuration.cs
r1400 r1401 31 31 } 32 32 33 public IEnumerable<IDecomposer> Decomposers { 34 get { return decomposers; } 35 } 36 33 37 public IFormatter GetFormatter(Type type) { 34 38 IFormatter formatter;
Note: See TracChangeset
for help on using the changeset viewer.