Changeset 1398
- Timestamp:
- 03/23/09 15:44:53 (16 years ago)
- Location:
- branches/New Persistence Exploration/Persistence
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.Designer.cs
r1382 r1398 25 25 private void InitializeComponent() { 26 26 System.Windows.Forms.TabPage nullFormatterConfig; 27 System.Windows.Forms.ListViewItem listViewItem 1= new System.Windows.Forms.ListViewItem("Bli");28 System.Windows.Forms.ListViewItem listViewItem 2= new System.Windows.Forms.ListViewItem("Bla");29 System.Windows.Forms.ListViewItem listViewItem 3= new System.Windows.Forms.ListViewItem("Blo");27 System.Windows.Forms.ListViewItem listViewItem4 = new System.Windows.Forms.ListViewItem("Bli"); 28 System.Windows.Forms.ListViewItem listViewItem5 = new System.Windows.Forms.ListViewItem("Bla"); 29 System.Windows.Forms.ListViewItem listViewItem6 = new System.Windows.Forms.ListViewItem("Blo"); 30 30 this.dataGridView1 = new System.Windows.Forms.DataGridView(); 31 31 this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); … … 100 100 this.decomposerList.GridLines = true; 101 101 this.decomposerList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; 102 listViewItem 1.Checked = true;103 listViewItem 1.StateImageIndex = 1;104 listViewItem 1.Tag = "";105 listViewItem 2.Checked = true;106 listViewItem 2.StateImageIndex = 1;107 listViewItem 3.Checked = true;108 listViewItem 3.StateImageIndex = 1;102 listViewItem4.Checked = true; 103 listViewItem4.StateImageIndex = 1; 104 listViewItem4.Tag = ""; 105 listViewItem5.Checked = true; 106 listViewItem5.StateImageIndex = 1; 107 listViewItem6.Checked = true; 108 listViewItem6.StateImageIndex = 1; 109 109 this.decomposerList.Items.AddRange(new System.Windows.Forms.ListViewItem[] { 110 listViewItem 1,111 listViewItem 2,112 listViewItem 3});110 listViewItem4, 111 listViewItem5, 112 listViewItem6}); 113 113 this.decomposerList.Location = new System.Drawing.Point(0, 0); 114 114 this.decomposerList.Name = "decomposerList"; … … 167 167 // 168 168 this.checkbox.Dock = System.Windows.Forms.DockStyle.Fill; 169 this.checkbox.Enabled = false; 169 170 this.checkbox.FormattingEnabled = true; 170 171 this.checkbox.Location = new System.Drawing.Point(0, 0); -
branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.cs
r1382 r1398 10 10 namespace HeuristicLab.Persistence.GUI { 11 11 12 public partial class PersistenceConfigurationForm : Form { 12 public partial class PersistenceConfigurationForm : Form { 13 14 private readonly Dictionary<string, IFormatter> formatterTable; 15 private readonly Dictionary<string, Type> typeNameTable; 16 13 17 public PersistenceConfigurationForm() { 14 18 InitializeComponent(); 15 decomposerList.Items.Clear(); 19 formatterTable = new Dictionary<string, IFormatter>(); 20 typeNameTable = new Dictionary<string, Type>(); 21 decomposerList.Items.Clear(); 16 22 foreach ( IDecomposer decomposer in ConfigurationService.Instance.AllDecomposers ) { 17 23 var item = decomposerList.Items.Add(decomposer.GetType().Name); … … 19 25 item.Tag = decomposer; 20 26 } 21 27 22 28 foreach ( var formats in ConfigurationService.Instance.AllFormatters ) { 23 TabPage page = new TabPage(formats.Key.Name) ;29 TabPage page = new TabPage(formats.Key.Name) {Tag = formats.Key}; 24 30 formatterTabs.TabPages.Add(page); 25 31 DataGridView gridView = new DataGridView { … … 28 34 AllowUserToAddRows = false, 29 35 AllowUserToDeleteRows = false, 30 AllowUserToResizeRows = false, 36 AllowUserToResizeRows = false, 37 Name = "GridView", 31 38 }; 32 //gridView.CellValueChanged += gridView_CellValueChanged; 33 //gridView.DataError += gridView_DataError; 34 //gridView.CellFormatting += gridView_CellFormatting; 35 page.Controls.Add(gridView); 39 gridView.CellValueChanged += gridView_CellValueChanged; 40 page.Controls.Add(gridView); 36 41 gridView.Columns.Add(new DataGridViewTextBoxColumn { 37 42 Name = "Type", ReadOnly = true, … … 42 47 gridView.Columns.Add(new DataGridViewComboBoxColumn 43 48 { AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill }); 44 var formatterMap = new Dictionary< Type, List<IFormatter>>();49 var formatterMap = new Dictionary<string, List<string>>(); 45 50 foreach (var formatter in formats.Value) { 46 if (!formatterMap.ContainsKey(formatter.Type)) 47 formatterMap.Add(formatter.Type, new List<IFormatter>()); 48 formatterMap[formatter.Type].Add(formatter); 51 string formatterName = formatter.GetType().Name; 52 if (formatterTable.ContainsKey(formatterName)) { 53 IFormatter otherFormatter = formatterTable[formatterName]; 54 formatterTable.Remove(formatterName); 55 formatterTable.Add(otherFormatter.GetType().FullName, otherFormatter); 56 formatterName = formatter.GetType().FullName; 57 } 58 formatterTable.Add(formatterName, formatter); 59 string typeName = formatter.Type.Name; 60 if (typeNameTable.ContainsKey(typeName)) { 61 Type otherType = typeNameTable[typeName]; 62 if (otherType != formatter.Type) { 63 typeNameTable.Remove(typeName); 64 typeNameTable.Add(otherType.FullName, otherType); 65 typeName = formatter.Type.FullName; 66 typeNameTable.Add(typeName, formatter.Type); 67 } 68 } else { 69 typeNameTable.Add(typeName, formatter.Type); 70 } 71 } 72 foreach (var formatter in formats.Value) { 73 string formatterName = 74 formatterTable.ContainsKey(formatter.GetType().Name) ? 75 formatter.GetType().Name : 76 formatter.GetType().FullName; 77 string typeName = 78 typeNameTable.ContainsKey(formatter.Type.Name) ? 79 formatter.Type.Name : 80 formatter.Type.FullName; 81 if (!formatterMap.ContainsKey(typeName)) 82 formatterMap.Add(typeName, new List<string>()); 83 formatterMap[typeName].Add(formatterName); 49 84 } 50 85 foreach ( var formatterMapping in formatterMap ) { 51 86 var row = gridView.Rows[gridView.Rows.Add()]; 52 row.Cells[0].Value = formatterMapping.Key .SimpleFullName();53 row.Cells[0].ToolTipText = formatterMapping.Key .AssemblyQualifiedName;87 row.Cells[0].Value = formatterMapping.Key; 88 row.Cells[0].ToolTipText = formatterMapping.Key; 54 89 row.Cells[1].Value = true; 55 var comboBoxCell = (DataGridViewComboBoxCell) row.Cells[2]; 56 //comboBoxCell.ValueType = typeof(IFormatter); 57 foreach ( var formatter in formatterMapping.Value ) { 58 comboBoxCell.Items.Add(formatter.GetType().Name); 90 var comboBoxCell = (DataGridViewComboBoxCell) row.Cells[2]; 91 foreach ( var formatter in formatterMapping.Value ) { 92 comboBoxCell.Items.Add(formatter); 59 93 } 60 94 comboBoxCell.Value = comboBoxCell.Items[0]; … … 68 102 } 69 103 70 void gridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { 71 e.Value = e.Value.ToString(); 72 e.FormattingApplied = true; 104 void gridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { 105 UpdatePreview(); 73 106 } 74 107 … … 105 138 i++; 106 139 } 107 Update ();140 UpdatePreview(); 108 141 } 109 142 … … 121 154 } 122 155 123 private void Update () {124 checkbox.Items.Clear(); 156 private void UpdatePreview() { 157 checkbox.Items.Clear(); 125 158 foreach (var decomposer in GetDecomposers()) 126 checkbox.Items.Add(decomposer.GetType().Name); 159 checkbox.Items.Add(decomposer.GetType().Name + " (D)"); 160 IFormat activeFormat = (IFormat) formatterTabs.SelectedTab.Tag; 161 if (activeFormat != null) { 162 foreach (var formatter in GetCurrentConfiguration(activeFormat).Formatters) { 163 checkbox.Items.Add(formatter.GetType().Name + " (F)"); 164 } 165 } 127 166 } 128 167 129 168 private void decomposerList_ItemChecked(object sender, ItemCheckedEventArgs e) { 130 Update(); 169 UpdatePreview(); 170 } 171 172 public Configuration GetCurrentConfiguration(IFormat format) { 173 Dictionary<Type, IFormatter> formatters = new Dictionary<Type, IFormatter>(); 174 foreach ( TabPage page in formatterTabs.TabPages ) { 175 if ( page.Text == format.Name ) { 176 Control[] controls = page.Controls.Find("GridView", false); 177 if (controls.Length == 1) { 178 foreach (DataGridViewRow row in ((DataGridView) controls[0]).Rows) { 179 if ( row.Cells[1].Value != null && 180 row.Cells[0].Value != null && 181 row.Cells[2].Value != null && 182 (bool)row.Cells[1].Value == true ) { 183 formatters.Add( 184 typeNameTable[(string)row.Cells[0].Value], 185 formatterTable[(string)row.Cells[2].Value]); 186 } 187 } 188 } 189 } 190 } 191 return new Configuration(formatters, GetDecomposers()); 131 192 } 132 193 -
branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.resx
r1382 r1398 130 130 <value>True</value> 131 131 </metadata> 132 <metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 133 <value>True</value> 134 </metadata> 135 <metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 136 <value>True</value> 137 </metadata> 138 <metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 139 <value>True</value> 140 </metadata> 132 141 </root> -
branches/New Persistence Exploration/Persistence/Persistence/Core/PersistenceConfiguration.cs
r1373 r1398 1 1 using System; 2 using System.Collections; 2 3 using System.Collections.Generic; 3 4 using System.Reflection; … … 25 26 this.decomposers = new List<IDecomposer>(decomposers); 26 27 decomposerCache = new Dictionary<Type, IDecomposer>(); 27 } 28 } 29 30 public IEnumerable Formatters { 31 get { return formatters.Values; } 32 } 28 33 29 34 public IFormatter GetFormatter(Type type) {
Note: See TracChangeset
for help on using the changeset viewer.