Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/09 12:58:14 (15 years ago)
Author:
epitzer
Message:

Format white space. (Ctrl-K, Ctrl-D) (#548)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence.GUI/3.3/PersistenceConfigurationForm.cs

    r1565 r1566  
    1717    private readonly Dictionary<string, IFormatter> formatterTable;
    1818    private readonly Dictionary<string, bool> simpleFormatterTable;
    19     private readonly Dictionary<IFormatter, string> reverseFormatterTable;   
     19    private readonly Dictionary<IFormatter, string> reverseFormatterTable;
    2020    private readonly Dictionary<string, Type> typeNameTable;
    2121    private readonly Dictionary<Type, string> reverseTypeNameTable;
    2222
    23     public PersistenceConfigurationForm() {     
     23    public PersistenceConfigurationForm() {
    2424      InitializeComponent();
    2525      formatterTable = new Dictionary<string, IFormatter>();
     
    5252    }
    5353
    54     private void UpdateDecomposerList(ListView decomposerList, Configuration config) {     
     54    private void UpdateDecomposerList(ListView decomposerList, Configuration config) {
    5555      decomposerList.Items.Clear();
    5656      var availableDecomposers = new Dictionary<string, IDecomposer>();
    57       foreach (IDecomposer d in ConfigurationService.Instance.Decomposers) {       
     57      foreach (IDecomposer d in ConfigurationService.Instance.Decomposers) {
    5858        availableDecomposers.Add(d.GetType().VersionInvariantName(), d);
    59       }     
    60       foreach (IDecomposer decomposer in config.Decomposers) {       
    61         var item = decomposerList.Items.Add(decomposer.GetType().Name);       
     59      }
     60      foreach (IDecomposer decomposer in config.Decomposers) {
     61        var item = decomposerList.Items.Add(decomposer.GetType().Name);
    6262        item.Checked = true;
    6363        item.Tag = decomposer;
    6464        availableDecomposers.Remove(decomposer.GetType().VersionInvariantName());
    65       }     
     65      }
    6666      foreach (KeyValuePair<string, IDecomposer> pair in availableDecomposers) {
    6767        var item = decomposerList.Items.Add(pair.Value.GetType().Name);
     
    6969        item.Tag = pair.Value;
    7070      }
    71     }   
     71    }
    7272
    7373    private void UpdateFromConfigurationService() {
    74       foreach ( IFormat format in ConfigurationService.Instance.Formats ) {
     74      foreach (IFormat format in ConfigurationService.Instance.Formats) {
    7575        Configuration config = ConfigurationService.Instance.GetConfiguration(format);
    7676        UpdateFormatterGrid(
    7777          (DataGridView)GetControlsOnPage(format.Name, "GridView"),
    78           config);       
     78          config);
    7979        UpdateDecomposerList(
    8080          (ListView)GetControlsOnPage(format.Name, "DecomposerList"),
    8181          config);
    8282      }
    83     }   
     83    }
    8484
    8585    private void initializeConfigPages() {
    86       configurationTabs.TabPages.Clear();     
    87       foreach ( IFormat format in ConfigurationService.Instance.Formats ) {
     86      configurationTabs.TabPages.Clear();
     87      foreach (IFormat format in ConfigurationService.Instance.Formats) {
    8888        List<IFormatter> formatters = ConfigurationService.Instance.Formatters[format.SerialDataType];
    8989        TabPage page = new TabPage(format.Name) {
     
    107107        horizontalSplit.Panel1.Controls.Add(decomposerList);
    108108        DataGridView gridView = createGridView();
    109         verticalSplit.Panel2.Controls.Add(gridView);       
     109        verticalSplit.Panel2.Controls.Add(gridView);
    110110        fillDataGrid(gridView, formatters);
    111111        ListBox checkBox = new ListBox {
     
    167167        new ColumnHeader {
    168168          Name = "DecomposerColumn", Text = "Decomposers",
    169         });     
     169        });
    170170      foreach (IDecomposer decomposer in ConfigurationService.Instance.Decomposers) {
    171171        var item = decomposerList.Items.Add(decomposer.GetType().Name);
     
    176176    }
    177177
    178     private void fillDataGrid(DataGridView gridView, IEnumerable<IFormatter> formatters) {           
     178    private void fillDataGrid(DataGridView gridView, IEnumerable<IFormatter> formatters) {
    179179      Dictionary<string, List<string>> formatterMap = createFormatterMap(formatters);
    180       foreach ( var formatterMapping in formatterMap ) {
     180      foreach (var formatterMapping in formatterMap) {
    181181        var row = gridView.Rows[gridView.Rows.Add()];
    182182        row.Cells["Type"].Value = formatterMapping.Key;
    183183        row.Cells["Type"].ToolTipText = formatterMapping.Key;
    184         row.Cells["Active"].Value = true;       
    185         var comboBoxCell = (DataGridViewComboBoxCell) row.Cells["Formatter"];         
    186         foreach ( var formatter in formatterMapping.Value ) {
     184        row.Cells["Active"].Value = true;
     185        var comboBoxCell = (DataGridViewComboBoxCell)row.Cells["Formatter"];
     186        foreach (var formatter in formatterMapping.Value) {
    187187          comboBoxCell.Items.Add(formatter);
    188         }         
    189         comboBoxCell.Value = comboBoxCell.Items[0];         
     188        }
     189        comboBoxCell.Value = comboBoxCell.Items[0];
    190190        comboBoxCell.ToolTipText = comboBoxCell.Items[0].ToString();
    191191        if (comboBoxCell.Items.Count == 1) {
    192192          comboBoxCell.ReadOnly = true;
    193193          comboBoxCell.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
    194         }     
     194        }
    195195      }
    196196    }
    197197
    198198    private Dictionary<string, List<string>> createFormatterMap(IEnumerable<IFormatter> formatters) {
    199       var formatterMap = new Dictionary<string, List<string>>();     
     199      var formatterMap = new Dictionary<string, List<string>>();
    200200      foreach (var formatter in formatters) {
    201201        string formatterName = reverseFormatterTable[formatter];
    202         string typeName = reverseTypeNameTable[formatter.SourceType];         
     202        string typeName = reverseTypeNameTable[formatter.SourceType];
    203203        if (!formatterMap.ContainsKey(typeName))
    204204          formatterMap.Add(typeName, new List<string>());
     
    221221          }
    222222          simpleFormatterTable[formatter.GetType().Name] = true;
    223           formatterTable.Add(formatterName, formatter);         
     223          formatterTable.Add(formatterName, formatter);
    224224          reverseFormatterTable.Add(formatter, formatterName);
    225225
     
    244244        }
    245245      }
    246     }   
     246    }
    247247
    248248    void gridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) {
    249249      UpdatePreview();
    250     }   
     250    }
    251251
    252252    private void decomposerList_ItemDrag(object sender, ItemDragEventArgs e) {
    253       ListView decomposerList = (ListView) sender;
     253      ListView decomposerList = (ListView)sender;
    254254      decomposerList.DoDragDrop(decomposerList.SelectedItems, DragDropEffects.Move);
    255255    }
    256256
    257     private void decomposerList_DragEnter(object sender, DragEventArgs e) {     
    258       if ( e.Data.GetDataPresent(typeof(ListView.SelectedListViewItemCollection).FullName)) {
     257    private void decomposerList_DragEnter(object sender, DragEventArgs e) {
     258      if (e.Data.GetDataPresent(typeof(ListView.SelectedListViewItemCollection).FullName)) {
    259259        e.Effect = DragDropEffects.Move;
    260       } 
     260      }
    261261    }
    262262
     
    266266        return;
    267267      }
    268       Point cp = decomposerList.PointToClient(new Point(e.X, e.Y));     
    269       ListViewItem targetItem = decomposerList.GetItemAt(cp.X, cp.Y);     
     268      Point cp = decomposerList.PointToClient(new Point(e.X, e.Y));
     269      ListViewItem targetItem = decomposerList.GetItemAt(cp.X, cp.Y);
    270270      if (targetItem == null)
    271         return;           
    272       int targetIndex = targetItem.Index;     
     271        return;
     272      int targetIndex = targetItem.Index;
    273273      var selectedItems = new List<ListViewItem>(decomposerList.SelectedItems.Cast<ListViewItem>());
    274274      int i = 0;
    275       foreach ( ListViewItem dragItem in selectedItems ) {               
     275      foreach (ListViewItem dragItem in selectedItems) {
    276276        if (targetIndex == dragItem.Index)
    277277          return;
    278278        if (dragItem.Index < targetIndex) {
    279           decomposerList.Items.Insert(targetIndex + 1, (ListViewItem) dragItem.Clone());
     279          decomposerList.Items.Insert(targetIndex + 1, (ListViewItem)dragItem.Clone());
    280280        } else {
    281           decomposerList.Items.Insert(targetIndex + i, (ListViewItem)dragItem.Clone());         
    282         }       
     281          decomposerList.Items.Insert(targetIndex + i, (ListViewItem)dragItem.Clone());
     282        }
    283283        decomposerList.Items.Remove(dragItem);
    284284        i++;
     
    288288
    289289    private void decomposerList_Resize(object sender, EventArgs e) {
    290       ListView decomposerList = (ListView)sender;     
    291       decomposerList.Columns["DecomposerColumn"].Width = decomposerList.Width - 4;     
    292     }
    293    
     290      ListView decomposerList = (ListView)sender;
     291      decomposerList.Columns["DecomposerColumn"].Width = decomposerList.Width - 4;
     292    }
     293
    294294    private void UpdatePreview() {
    295       ListBox checkBox = (ListBox)GetActiveControl("CheckBox");     
     295      ListBox checkBox = (ListBox)GetActiveControl("CheckBox");
    296296      IFormat activeFormat = (IFormat)configurationTabs.SelectedTab.Tag;
    297       if (activeFormat != null && checkBox != null ) {
     297      if (activeFormat != null && checkBox != null) {
    298298        checkBox.Items.Clear();
    299299        Configuration activeConfig = GetActiveConfiguration();
     
    302302        }
    303303        foreach (var decomposer in activeConfig.Decomposers)
    304           checkBox.Items.Add(decomposer.GetType().Name + " (D)");     
    305       }     
     304          checkBox.Items.Add(decomposer.GetType().Name + " (D)");
     305      }
    306306    }
    307307
     
    316316      } else {
    317317        return null;
    318       }     
    319     }
    320 
    321     private Control GetControlsOnPage(string pageName, string name) {     
     318      }
     319    }
     320
     321    private Control GetControlsOnPage(string pageName, string name) {
    322322      Control[] controls = configurationTabs.TabPages[pageName].Controls.Find(name, true);
    323323      if (controls.Length == 1) {
     
    325325      } else {
    326326        return null;
    327       }     
     327      }
    328328    }
    329329
     
    358358
    359359    private Configuration GetConfiguration(IFormat format) {
    360        return GenerateConfiguration(format,
    361         (DataGridView)GetControlsOnPage(format.Name, "GridView"),
    362         (ListView)GetControlsOnPage(format.Name, "DecomposerList"));
    363     }
    364    
     360      return GenerateConfiguration(format,
     361       (DataGridView)GetControlsOnPage(format.Name, "GridView"),
     362       (ListView)GetControlsOnPage(format.Name, "DecomposerList"));
     363    }
     364
    365365    private void updateButton_Click(object sender, EventArgs e) {
    366366      IFormat format = (IFormat)configurationTabs.SelectedTab.Tag;
     
    368368        ConfigurationService.Instance.DefineConfiguration(
    369369          GetActiveConfiguration());
    370     }   
    371    
     370    }
     371
    372372  }
    373373
     
    383383
    384384    public override Empty Format(Type o) {
    385      return null;
     385      return null;
    386386    }
    387387
     
    400400    public override bool Parse(Empty o) {
    401401      return false;
    402     }   
    403   } 
     402    }
     403  }
    404404
    405405  [EmptyStorableClass]
     
    424424    }
    425425
    426     private static void SimpleFullName(Type type, StringBuilder sb) {     
     426    private static void SimpleFullName(Type type, StringBuilder sb) {
    427427      if (type.IsGenericType) {
    428428        sb.Append(type.Name, 0, type.Name.LastIndexOf('`'));
Note: See TracChangeset for help on using the changeset viewer.