Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1382


Ignore:
Timestamp:
03/20/09 16:08:48 (16 years ago)
Author:
epitzer
Message:

Almost complete GUI for persistence configuration. (#506)

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

    r1373 r1382  
    2424    /// </summary>
    2525    private void InitializeComponent() {
     26      System.Windows.Forms.TabPage nullFormatterConfig;
    2627      System.Windows.Forms.ListViewItem listViewItem1 = new System.Windows.Forms.ListViewItem("Bli");
    2728      System.Windows.Forms.ListViewItem listViewItem2 = new System.Windows.Forms.ListViewItem("Bla");
    2829      System.Windows.Forms.ListViewItem listViewItem3 = new System.Windows.Forms.ListViewItem("Blo");
     30      this.dataGridView1 = new System.Windows.Forms.DataGridView();
     31      this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
     32      this.Column2 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
     33      this.Column3 = new System.Windows.Forms.DataGridViewComboBoxColumn();
    2934      this.decomposerList = new System.Windows.Forms.ListView();
    3035      this.DecomposersColumn = new System.Windows.Forms.ColumnHeader();
     36      this.splitContainer1 = new System.Windows.Forms.SplitContainer();
     37      this.splitContainer2 = new System.Windows.Forms.SplitContainer();
    3138      this.checkbox = new System.Windows.Forms.CheckedListBox();
     39      this.formatterTabs = new System.Windows.Forms.TabControl();
     40      nullFormatterConfig = new System.Windows.Forms.TabPage();
     41      nullFormatterConfig.SuspendLayout();
     42      ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
     43      this.splitContainer1.Panel1.SuspendLayout();
     44      this.splitContainer1.Panel2.SuspendLayout();
     45      this.splitContainer1.SuspendLayout();
     46      this.splitContainer2.Panel1.SuspendLayout();
     47      this.splitContainer2.Panel2.SuspendLayout();
     48      this.splitContainer2.SuspendLayout();
     49      this.formatterTabs.SuspendLayout();
    3250      this.SuspendLayout();
     51      //
     52      // nullFormatterConfig
     53      //
     54      nullFormatterConfig.Controls.Add(this.dataGridView1);
     55      nullFormatterConfig.Location = new System.Drawing.Point(4, 22);
     56      nullFormatterConfig.Name = "nullFormatterConfig";
     57      nullFormatterConfig.Size = new System.Drawing.Size(386, 554);
     58      nullFormatterConfig.TabIndex = 0;
     59      nullFormatterConfig.Text = "EmptyFormatterConfig";
     60      nullFormatterConfig.UseVisualStyleBackColor = true;
     61      //
     62      // dataGridView1
     63      //
     64      this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
     65      this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
     66            this.Column1,
     67            this.Column2,
     68            this.Column3});
     69      this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
     70      this.dataGridView1.Location = new System.Drawing.Point(0, 0);
     71      this.dataGridView1.Name = "dataGridView1";
     72      this.dataGridView1.Size = new System.Drawing.Size(386, 554);
     73      this.dataGridView1.TabIndex = 0;
     74      //
     75      // Column1
     76      //
     77      this.Column1.HeaderText = "Column1";
     78      this.Column1.Name = "Column1";
     79      //
     80      // Column2
     81      //
     82      this.Column2.HeaderText = "Column2";
     83      this.Column2.Name = "Column2";
     84      //
     85      // Column3
     86      //
     87      this.Column3.DisplayStyle = System.Windows.Forms.DataGridViewComboBoxDisplayStyle.ComboBox;
     88      this.Column3.HeaderText = "Column3";
     89      this.Column3.Name = "Column3";
    3390      //
    3491      // decomposerList
     
    3996      this.decomposerList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
    4097            this.DecomposersColumn});
     98      this.decomposerList.Dock = System.Windows.Forms.DockStyle.Fill;
    4199      this.decomposerList.FullRowSelect = true;
    42100      this.decomposerList.GridLines = true;
     
    53111            listViewItem2,
    54112            listViewItem3});
    55       this.decomposerList.Location = new System.Drawing.Point(25, 12);
     113      this.decomposerList.Location = new System.Drawing.Point(0, 0);
    56114      this.decomposerList.Name = "decomposerList";
    57115      this.decomposerList.ShowGroups = false;
    58       this.decomposerList.Size = new System.Drawing.Size(194, 278);
     116      this.decomposerList.Size = new System.Drawing.Size(199, 290);
    59117      this.decomposerList.TabIndex = 0;
    60118      this.decomposerList.UseCompatibleStateImageBehavior = false;
     
    71129      this.DecomposersColumn.Width = 190;
    72130      //
     131      // splitContainer1
     132      //
     133      this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
     134      this.splitContainer1.Location = new System.Drawing.Point(0, 0);
     135      this.splitContainer1.Name = "splitContainer1";
     136      //
     137      // splitContainer1.Panel1
     138      //
     139      this.splitContainer1.Panel1.Controls.Add(this.splitContainer2);
     140      //
     141      // splitContainer1.Panel2
     142      //
     143      this.splitContainer1.Panel2.Controls.Add(this.formatterTabs);
     144      this.splitContainer1.Size = new System.Drawing.Size(597, 580);
     145      this.splitContainer1.SplitterDistance = 199;
     146      this.splitContainer1.TabIndex = 2;
     147      //
     148      // splitContainer2
     149      //
     150      this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
     151      this.splitContainer2.Location = new System.Drawing.Point(0, 0);
     152      this.splitContainer2.Name = "splitContainer2";
     153      this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
     154      //
     155      // splitContainer2.Panel1
     156      //
     157      this.splitContainer2.Panel1.Controls.Add(this.decomposerList);
     158      //
     159      // splitContainer2.Panel2
     160      //
     161      this.splitContainer2.Panel2.Controls.Add(this.checkbox);
     162      this.splitContainer2.Size = new System.Drawing.Size(199, 580);
     163      this.splitContainer2.SplitterDistance = 290;
     164      this.splitContainer2.TabIndex = 1;
     165      //
    73166      // checkbox
    74167      //
     168      this.checkbox.Dock = System.Windows.Forms.DockStyle.Fill;
    75169      this.checkbox.FormattingEnabled = true;
    76       this.checkbox.Location = new System.Drawing.Point(314, 103);
     170      this.checkbox.Location = new System.Drawing.Point(0, 0);
    77171      this.checkbox.Name = "checkbox";
    78       this.checkbox.Size = new System.Drawing.Size(180, 154);
     172      this.checkbox.Size = new System.Drawing.Size(199, 274);
    79173      this.checkbox.TabIndex = 1;
    80174      this.checkbox.ThreeDCheckBoxes = true;
     175      //
     176      // formatterTabs
     177      //
     178      this.formatterTabs.Controls.Add(nullFormatterConfig);
     179      this.formatterTabs.Dock = System.Windows.Forms.DockStyle.Fill;
     180      this.formatterTabs.Location = new System.Drawing.Point(0, 0);
     181      this.formatterTabs.Name = "formatterTabs";
     182      this.formatterTabs.SelectedIndex = 0;
     183      this.formatterTabs.Size = new System.Drawing.Size(394, 580);
     184      this.formatterTabs.TabIndex = 0;
    81185      //
    82186      // PersistenceConfigurationForm
     
    85189      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    86190      this.ClientSize = new System.Drawing.Size(597, 580);
    87       this.Controls.Add(this.checkbox);
    88       this.Controls.Add(this.decomposerList);
     191      this.Controls.Add(this.splitContainer1);
    89192      this.Name = "PersistenceConfigurationForm";
    90193      this.Text = "PersistenceConfigurationForm";
     194      nullFormatterConfig.ResumeLayout(false);
     195      ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
     196      this.splitContainer1.Panel1.ResumeLayout(false);
     197      this.splitContainer1.Panel2.ResumeLayout(false);
     198      this.splitContainer1.ResumeLayout(false);
     199      this.splitContainer2.Panel1.ResumeLayout(false);
     200      this.splitContainer2.Panel2.ResumeLayout(false);
     201      this.splitContainer2.ResumeLayout(false);
     202      this.formatterTabs.ResumeLayout(false);
    91203      this.ResumeLayout(false);
    92204
     
    97209    private System.Windows.Forms.ListView decomposerList;
    98210    private System.Windows.Forms.ColumnHeader DecomposersColumn;
     211    private System.Windows.Forms.SplitContainer splitContainer1;
    99212    private System.Windows.Forms.CheckedListBox checkbox;
     213    private System.Windows.Forms.SplitContainer splitContainer2;
     214    private System.Windows.Forms.TabControl formatterTabs;
     215    private System.Windows.Forms.DataGridView dataGridView1;
     216    private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
     217    private System.Windows.Forms.DataGridViewCheckBoxColumn Column2;
     218    private System.Windows.Forms.DataGridViewComboBoxColumn Column3;
    100219  }
    101220}
  • branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.cs

    r1373 r1382  
    11using System;
    22using System.Collections.Generic;
    3 using System.ComponentModel;
    4 using System.Data;
    53using System.Drawing;
    64using System.Linq;
    7 using System.Text;
    85using System.Windows.Forms;
    96using HeuristicLab.Persistence.Default.Xml;
    107using HeuristicLab.Persistence.Interfaces;
     8using System.Text;
    119
    1210namespace HeuristicLab.Persistence.GUI {
     11
    1312  public partial class PersistenceConfigurationForm : Form {   
    1413    public PersistenceConfigurationForm() {
     
    1918        item.Checked = true;
    2019        item.Tag = decomposer;
    21       }     
     20      }
     21     
     22      foreach ( var formats in ConfigurationService.Instance.AllFormatters ) {
     23        TabPage page = new TabPage(formats.Key.Name);
     24        formatterTabs.TabPages.Add(page);
     25        DataGridView gridView = new DataGridView {
     26          Dock = DockStyle.Fill,
     27          EditMode = DataGridViewEditMode.EditOnEnter,
     28          AllowUserToAddRows = false,
     29          AllowUserToDeleteRows = false,
     30          AllowUserToResizeRows = false,                                       
     31        };
     32        //gridView.CellValueChanged += gridView_CellValueChanged;
     33        //gridView.DataError += gridView_DataError;
     34        //gridView.CellFormatting += gridView_CellFormatting;
     35        page.Controls.Add(gridView);
     36        gridView.Columns.Add(new DataGridViewTextBoxColumn {
     37          Name = "Type", ReadOnly = true,
     38          AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
     39        });
     40        gridView.Columns.Add(new DataGridViewCheckBoxColumn
     41          { AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells });
     42        gridView.Columns.Add(new DataGridViewComboBoxColumn
     43          { AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill });               
     44        var formatterMap = new Dictionary<Type, List<IFormatter>>();
     45        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);
     49        }
     50        foreach ( var formatterMapping in formatterMap ) {
     51          var row = gridView.Rows[gridView.Rows.Add()];
     52          row.Cells[0].Value = formatterMapping.Key.SimpleFullName();
     53          row.Cells[0].ToolTipText = formatterMapping.Key.AssemblyQualifiedName;
     54          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);
     59          }         
     60          comboBoxCell.Value = comboBoxCell.Items[0];         
     61          comboBoxCell.ToolTipText = comboBoxCell.Items[0].ToString();
     62          if (comboBoxCell.Items.Count == 1) {
     63            comboBoxCell.ReadOnly = true;
     64            comboBoxCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
     65          }     
     66        }     
     67      }
    2268    }
     69
     70    void gridView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) {
     71      e.Value = e.Value.ToString();
     72      e.FormattingApplied = true;
     73    }   
    2374
    2475    private void decomposerList_ItemDrag(object sender, ItemDragEventArgs e) {
     
    3687        return;
    3788      }
    38       //Returns the location of the mouse pointer in the ListView control.
    39       Point cp = decomposerList.PointToClient(new Point(e.X, e.Y));
    40       //Obtain the item that is located at the specified location of the mouse pointer.
    41       ListViewItem dragToItem = decomposerList.GetItemAt(cp.X, cp.Y);
    42       if (dragToItem == null) {
    43         return;
    44       }
    45       //Obtain the index of the item at the mouse pointer.
    46       int dragIndex = dragToItem.Index;
    47       ListViewItem[] sel = new ListViewItem[decomposerList.SelectedItems.Count];
    48       for (int i = 0; i <= decomposerList.SelectedItems.Count - 1; i++) {
    49         sel[i] = decomposerList.SelectedItems[i];
    50       }
    51       for (int i = 0; i < sel.GetLength(0); i++) {
    52         //Obtain the ListViewItem to be dragged to the target location.
    53         ListViewItem dragItem = sel[i];
    54         int itemIndex = dragIndex;
    55         if (itemIndex == dragItem.Index) {
     89      Point cp = decomposerList.PointToClient(new Point(e.X, e.Y));     
     90      ListViewItem targetItem = decomposerList.GetItemAt(cp.X, cp.Y);     
     91      if (targetItem == null)
     92        return;           
     93      int targetIndex = targetItem.Index;     
     94      var selectedItems = new List<ListViewItem>(decomposerList.SelectedItems.Cast<ListViewItem>());
     95      int i = 0;
     96      foreach ( ListViewItem dragItem in selectedItems ) {               
     97        if (targetIndex == dragItem.Index)
    5698          return;
    57         }
    58         if (dragItem.Index < itemIndex)
    59           itemIndex++;
    60         else
    61           itemIndex = dragIndex + i;
    62         //Insert the item at the mouse pointer.
    63         ListViewItem insertItem = (ListViewItem) dragItem.Clone();
    64         decomposerList.Items.Insert(itemIndex, insertItem);
    65         //Removes the item from the initial location while
    66         //the item is moved to the new location.
     99        if (dragItem.Index < targetIndex) {
     100          decomposerList.Items.Insert(targetIndex + 1, (ListViewItem) dragItem.Clone());
     101        } else {
     102          decomposerList.Items.Insert(targetIndex + i, (ListViewItem)dragItem.Clone());         
     103        }       
    67104        decomposerList.Items.Remove(dragItem);
     105        i++;
    68106      }
    69107      Update();
     
    92130      Update();
    93131    }
     132   
     133  }
     134
     135  public class FakeBoolean2XmlFormatter : IFormatter {   
     136
     137    public Type Type { get { return typeof (Boolean); } }
     138
     139    public IFormat Format { get { return XmlFormat.Instance; } }
     140
     141    public object DoFormat(object o) {
     142      return null;
     143    }
     144
     145    public object Parse(object o) {
     146      return null;
     147    }
     148   
     149  }
     150
     151  public class FormatterWrapper {
     152    public IFormatter Formatter;
     153    public FormatterWrapper(IFormatter f) {
     154      Formatter = f;
     155    }
     156    public override string ToString() {
     157      return Formatter.GetType().Name;
     158    }
     159  }
     160
     161  public static class TypeFormatter {
     162
     163    public static string SimpleFullName(this Type type) {
     164      StringBuilder sb = new StringBuilder();
     165      SimpleFullName(type, sb);
     166      return sb.ToString();
     167    }
     168
     169    private static void SimpleFullName(Type type, StringBuilder sb) {     
     170      if (type.IsGenericType) {
     171        sb.Append(type.Name, 0, type.Name.LastIndexOf('`'));     
     172        sb.Append("<");
     173        foreach (Type t in type.GetGenericArguments()) {
     174          SimpleFullName(t, sb);         
     175          sb.Append(", ");
     176        }
     177        sb.Remove(sb.Length - 2, 2);
     178        sb.Append(">");
     179      } else {
     180        sb.Append(type.Name);
     181      }
     182    }
    94183
    95184  }
     185
    96186}
  • branches/New Persistence Exploration/Persistence/HeuristicLab.Persistence.GUI/PersistenceConfigurationForm.resx

    r1373 r1382  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <metadata name="nullFormatterConfig.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     121    <value>False</value>
     122  </metadata>
     123  <metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     124    <value>True</value>
     125  </metadata>
     126  <metadata name="Column2.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     127    <value>True</value>
     128  </metadata>
     129  <metadata name="Column3.UserAddedColumn" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     130    <value>True</value>
     131  </metadata>
    120132</root>
Note: See TracChangeset for help on using the changeset viewer.