Changeset 1399
- Timestamp:
- 03/23/09 17:13:25 (16 years ago)
- Location:
- branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.Designer.cs
r1398 r1399 25 25 private void InitializeComponent() { 26 26 System.Windows.Forms.TabPage nullFormatterConfig; 27 System.Windows.Forms.ListViewItem listViewItem 4= new System.Windows.Forms.ListViewItem("Bli");28 System.Windows.Forms.ListViewItem listViewItem 5= new System.Windows.Forms.ListViewItem("Bla");29 System.Windows.Forms.ListViewItem listViewItem 6= new System.Windows.Forms.ListViewItem("Blo");27 System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("Bli"); 28 System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("Bla"); 29 System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("Blo"); 30 30 this.dataGridView1 = new System.Windows.Forms.DataGridView(); 31 31 this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); … … 36 36 this.splitContainer1 = new System.Windows.Forms.SplitContainer(); 37 37 this.splitContainer2 = new System.Windows.Forms.SplitContainer(); 38 this.checkbox = new System.Windows.Forms.CheckedListBox();39 38 this.formatterTabs = new System.Windows.Forms.TabControl(); 39 this.checkBox = new System.Windows.Forms.ListBox(); 40 40 nullFormatterConfig = new System.Windows.Forms.TabPage(); 41 41 nullFormatterConfig.SuspendLayout(); … … 100 100 this.decomposerList.GridLines = true; 101 101 this.decomposerList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; 102 listViewItem 4.Checked = true;103 listViewItem 4.StateImageIndex = 1;104 listViewItem 4.Tag = "";105 listViewItem 5.Checked = true;106 listViewItem 5.StateImageIndex = 1;107 listViewItem 6.Checked = true;108 listViewItem 6.StateImageIndex = 1;102 listViewItem1.Checked = true; 103 listViewItem1.StateImageIndex = 1; 104 listViewItem1.Tag = ""; 105 listViewItem2.Checked = true; 106 listViewItem2.StateImageIndex = 1; 107 listViewItem3.Checked = true; 108 listViewItem3.StateImageIndex = 1; 109 109 this.decomposerList.Items.AddRange(new System.Windows.Forms.ListViewItem[] { 110 listViewItem 4,111 listViewItem 5,112 listViewItem 6});110 listViewItem1, 111 listViewItem2, 112 listViewItem3}); 113 113 this.decomposerList.Location = new System.Drawing.Point(0, 0); 114 114 this.decomposerList.Name = "decomposerList"; … … 159 159 // splitContainer2.Panel2 160 160 // 161 this.splitContainer2.Panel2.Controls.Add(this.check box);161 this.splitContainer2.Panel2.Controls.Add(this.checkBox); 162 162 this.splitContainer2.Size = new System.Drawing.Size(199, 580); 163 163 this.splitContainer2.SplitterDistance = 290; 164 164 this.splitContainer2.TabIndex = 1; 165 //166 // checkbox167 //168 this.checkbox.Dock = System.Windows.Forms.DockStyle.Fill;169 this.checkbox.Enabled = false;170 this.checkbox.FormattingEnabled = true;171 this.checkbox.Location = new System.Drawing.Point(0, 0);172 this.checkbox.Name = "checkbox";173 this.checkbox.Size = new System.Drawing.Size(199, 274);174 this.checkbox.TabIndex = 1;175 this.checkbox.ThreeDCheckBoxes = true;176 165 // 177 166 // formatterTabs … … 184 173 this.formatterTabs.Size = new System.Drawing.Size(394, 580); 185 174 this.formatterTabs.TabIndex = 0; 175 // 176 // checkBox 177 // 178 this.checkBox.Dock = System.Windows.Forms.DockStyle.Fill; 179 this.checkBox.FormattingEnabled = true; 180 this.checkBox.Location = new System.Drawing.Point(0, 0); 181 this.checkBox.Name = "checkBox"; 182 this.checkBox.Size = new System.Drawing.Size(199, 277); 183 this.checkBox.TabIndex = 0; 186 184 // 187 185 // PersistenceConfigurationForm … … 211 209 private System.Windows.Forms.ColumnHeader DecomposersColumn; 212 210 private System.Windows.Forms.SplitContainer splitContainer1; 213 private System.Windows.Forms.CheckedListBox checkbox;214 211 private System.Windows.Forms.SplitContainer splitContainer2; 215 212 private System.Windows.Forms.TabControl formatterTabs; … … 218 215 private System.Windows.Forms.DataGridViewCheckBoxColumn Column2; 219 216 private System.Windows.Forms.DataGridViewComboBoxColumn Column3; 217 private System.Windows.Forms.ListBox checkBox; 220 218 } 221 219 } -
branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.cs
r1398 r1399 13 13 14 14 private readonly Dictionary<string, IFormatter> formatterTable; 15 private readonly Dictionary<string, Type> typeNameTable; 15 private readonly Dictionary<IFormatter, string> reverseFormatterTable; 16 private readonly Dictionary<string, Type> typeNameTable; 17 private readonly Dictionary<Type, string> reverseTypeNameTable; 16 18 17 19 public PersistenceConfigurationForm() { 18 20 InitializeComponent(); 19 21 formatterTable = new Dictionary<string, IFormatter>(); 22 reverseFormatterTable = new Dictionary<IFormatter, string>(); 20 23 typeNameTable = new Dictionary<string, Type>(); 24 reverseTypeNameTable = new Dictionary<Type, string>(); 25 initializeDecomposerList(); 26 initializeFormatterPages(); 27 } 28 29 private void initializeFormatterPages() { 30 formatterTabs.TabPages.Clear(); 31 foreach ( var formats in ConfigurationService.Instance.AllFormatters ) { 32 TabPage page = new TabPage(formats.Key.Name) {Tag = formats.Key}; 33 formatterTabs.TabPages.Add(page); 34 DataGridView gridView = new DataGridView { 35 Dock = DockStyle.Fill, 36 EditMode = DataGridViewEditMode.EditOnEnter, 37 AllowUserToAddRows = false, 38 AllowUserToDeleteRows = false, 39 AllowUserToResizeRows = false, 40 Name = "GridView", 41 }; 42 gridView.CellValueChanged += gridView_CellValueChanged; 43 gridView.Columns.Add(new DataGridViewTextBoxColumn { 44 Name = "Type", ReadOnly = true, 45 AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill 46 }); 47 gridView.Columns.Add(new DataGridViewCheckBoxColumn { 48 AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells}); 49 gridView.Columns.Add(new DataGridViewComboBoxColumn { 50 AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill}); 51 page.Controls.Add(gridView); 52 fillDataGrid(gridView, formats.Value); 53 } 54 } 55 56 private void fillDataGrid(DataGridView gridView, IEnumerable<IFormatter> formatters) { 57 updateNameTables(formatters); 58 Dictionary<string, List<string>> formatterMap = createFormatterMap(formatters); 59 foreach ( var formatterMapping in formatterMap ) { 60 var row = gridView.Rows[gridView.Rows.Add()]; 61 row.Cells[0].Value = formatterMapping.Key; 62 row.Cells[0].ToolTipText = formatterMapping.Key; 63 row.Cells[1].Value = true; 64 var comboBoxCell = (DataGridViewComboBoxCell) row.Cells[2]; 65 foreach ( var formatter in formatterMapping.Value ) { 66 comboBoxCell.Items.Add(formatter); 67 } 68 comboBoxCell.Value = comboBoxCell.Items[0]; 69 comboBoxCell.ToolTipText = comboBoxCell.Items[0].ToString(); 70 if (comboBoxCell.Items.Count == 1) { 71 comboBoxCell.ReadOnly = true; 72 comboBoxCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; 73 } 74 } 75 } 76 77 private Dictionary<string, List<string>> createFormatterMap(IEnumerable<IFormatter> formatters) { 78 var formatterMap = new Dictionary<string, List<string>>(); 79 foreach (var formatter in formatters) { 80 string formatterName = reverseFormatterTable[formatter]; 81 string typeName = reverseTypeNameTable[formatter.Type]; 82 if (!formatterMap.ContainsKey(typeName)) 83 formatterMap.Add(typeName, new List<string>()); 84 formatterMap[typeName].Add(formatterName); 85 } 86 return formatterMap; 87 } 88 89 private void updateNameTables(IEnumerable<IFormatter> formatters) { 90 foreach (var formatter in formatters) { 91 string formatterName = formatter.GetType().Name; 92 if (formatterTable.ContainsKey(formatterName)) { 93 IFormatter otherFormatter = formatterTable[formatterName]; 94 formatterTable.Remove(formatterName); 95 reverseFormatterTable.Remove(otherFormatter); 96 formatterTable.Add(otherFormatter.GetType().FullName, otherFormatter); 97 reverseFormatterTable.Add(otherFormatter, otherFormatter.GetType().FullName); 98 formatterName = formatter.GetType().FullName; 99 } 100 formatterTable.Add(formatterName, formatter); 101 reverseFormatterTable.Add(formatter, formatterName); 102 103 string typeName = formatter.Type.IsGenericType ? 104 formatter.Type.SimpleFullName() : 105 formatter.Type.Name; 106 if (typeNameTable.ContainsKey(typeName)) { 107 Type otherType = typeNameTable[typeName]; 108 if (otherType != formatter.Type) { 109 typeNameTable.Remove(typeName); 110 reverseTypeNameTable.Remove(otherType); 111 typeNameTable.Add(otherType.FullName, otherType); 112 reverseTypeNameTable.Add(otherType, otherType.FullName); 113 typeName = formatter.Type.FullName; 114 typeNameTable.Add(typeName, formatter.Type); 115 reverseTypeNameTable.Add(formatter.Type, typeName); 116 } 117 } else { 118 typeNameTable.Add(typeName, formatter.Type); 119 reverseTypeNameTable.Add(formatter.Type, typeName); 120 } 121 } 122 } 123 124 private void initializeDecomposerList() { 21 125 decomposerList.Items.Clear(); 22 126 foreach ( IDecomposer decomposer in ConfigurationService.Instance.AllDecomposers ) { … … 24 128 item.Checked = true; 25 129 item.Tag = decomposer; 26 }27 28 foreach ( var formats in ConfigurationService.Instance.AllFormatters ) {29 TabPage page = new TabPage(formats.Key.Name) {Tag = formats.Key};30 formatterTabs.TabPages.Add(page);31 DataGridView gridView = new DataGridView {32 Dock = DockStyle.Fill,33 EditMode = DataGridViewEditMode.EditOnEnter,34 AllowUserToAddRows = false,35 AllowUserToDeleteRows = false,36 AllowUserToResizeRows = false,37 Name = "GridView",38 };39 gridView.CellValueChanged += gridView_CellValueChanged;40 page.Controls.Add(gridView);41 gridView.Columns.Add(new DataGridViewTextBoxColumn {42 Name = "Type", ReadOnly = true,43 AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill44 });45 gridView.Columns.Add(new DataGridViewCheckBoxColumn46 { AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells });47 gridView.Columns.Add(new DataGridViewComboBoxColumn48 { AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill });49 var formatterMap = new Dictionary<string, List<string>>();50 foreach (var formatter in formats.Value) {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);84 }85 foreach ( var formatterMapping in formatterMap ) {86 var row = gridView.Rows[gridView.Rows.Add()];87 row.Cells[0].Value = formatterMapping.Key;88 row.Cells[0].ToolTipText = formatterMapping.Key;89 row.Cells[1].Value = true;90 var comboBoxCell = (DataGridViewComboBoxCell) row.Cells[2];91 foreach ( var formatter in formatterMapping.Value ) {92 comboBoxCell.Items.Add(formatter);93 }94 comboBoxCell.Value = comboBoxCell.Items[0];95 comboBoxCell.ToolTipText = comboBoxCell.Items[0].ToString();96 if (comboBoxCell.Items.Count == 1) {97 comboBoxCell.ReadOnly = true;98 comboBoxCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;99 }100 }101 130 } 102 131 } … … 155 184 156 185 private void UpdatePreview() { 157 checkbox.Items.Clear(); 158 foreach (var decomposer in GetDecomposers()) 159 checkbox.Items.Add(decomposer.GetType().Name + " (D)"); 160 IFormat activeFormat = (IFormat) formatterTabs.SelectedTab.Tag; 186 checkBox.Items.Clear(); 187 IFormat activeFormat = (IFormat)formatterTabs.SelectedTab.Tag; 161 188 if (activeFormat != null) { 162 189 foreach (var formatter in GetCurrentConfiguration(activeFormat).Formatters) { 163 checkbox.Items.Add(formatter.GetType().Name + " (F)"); 164 } 165 } 190 checkBox.Items.Add(formatter.GetType().Name + " (F)"); 191 } 192 } 193 foreach (var decomposer in GetDecomposers()) 194 checkBox.Items.Add(decomposer.GetType().Name + " (D)"); 166 195 } 167 196 … … 177 206 if (controls.Length == 1) { 178 207 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 ) {208 if ( row.Cells[0].Value != null && 209 row.Cells[1].Value != null && 210 row.Cells[2].Value != null && 211 (bool)row.Cells[1].Value == true ) { 183 212 formatters.Add( 184 213 typeNameTable[(string)row.Cells[0].Value], … … 206 235 public object Parse(object o) { 207 236 return null; 208 } 209 210 } 211 212 public class FormatterWrapper {213 public IFormat ter Formatter;214 public FormatterWrapper(IFormatter f) {215 Formatter = f;216 } 217 public o verride string ToString() {218 return Formatter.GetType().Name;237 } 238 } 239 240 public class Int2XmlFormatter: IFormatter { 241 public Type Type { get { return typeof (int); } } 242 public IFormat Format { get { return XmlFormat.Instance; } } 243 public object DoFormat(object o) { 244 return null; 245 } 246 public object Parse(object o) { 247 return null; 219 248 } 220 249 } -
branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.resx
r1398 r1399 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>141 132 </root>
Note: See TracChangeset
for help on using the changeset viewer.