void olvFieldSetup_CellEditFinishing(object sender, CellEditEventArgs e) { if (e.Control is ComboBox == false) { string msg = "EDITOR_SHOULD_BE_COMBOBOX, instead I got e.Control.GetType()=[" + e.Control.GetType() + "]"; Assembler.PopupException(msg + " olvFieldSetup_CellEditFinishing()"); return; } ComboBox editor = (ComboBox)e.Control; FieldSetup fieldSetup = (FieldSetup)e.RowObject; ColumnCatcher iCatcherEdited = this.olvColGenFieldSetup[e.Column]; switch (fieldSetup.RowIndexInObjectListView) { case 0: //CsvFieldType enumValueSelected1 = (CsvFieldType) Enum.Parse(typeof(CsvFieldType), editor.SelectedItem.ToString()); CsvFieldType selectedType = (CsvFieldType)editor.SelectedIndex; iCatcherEdited.Parser.CsvType = selectedType; break; case 1: //CsvFieldType enumValueSelected1 = (CsvFieldType) Enum.Parse(typeof(CsvFieldType), editor.SelectedItem.ToString()); string selectedFormat = editor.SelectedItem as string; if (selectedFormat == null) { selectedFormat = editor.Text; //user typed new value => add it to source list this.dataSnapshot.AddFormatForTypeUnique(selectedFormat, iCatcherEdited.Parser.CsvType); } if (selectedFormat == CsvTypeParser.FORMAT_VISUALIZE_EMPTY_STRING) { selectedFormat = ""; } iCatcherEdited.Parser.CsvTypeFormat = selectedFormat; break; default: throw new Exception("this.olvFieldSetup should contain exactly TWO identical rows; OLV should've passed rowIndex into AspectGetter and CellEdit"); break; } editor.SelectedIndexChanged -= cb_SelectedIndexChanged; this.dataSnapshotSerializer.Serialize(); this.olvFieldSetup.RefreshObject(iCatcherEdited); // Any updating will have been down in the SelectedIndexChanged event handler // Here we simply make the list redraw the involved ListViewItem //((ObjectListView)sender).RefreshItem(e.ListViewItem); // We have updated the model object, so we cancel the auto update //e.Cancel = true; //this.step3syncCsvRawAndFieldSetupToParsedByFormat(); this.step3safe(); }
void step2syncCsvRawToFieldSetup() { this.olvFieldSetup.Reset(); this.olvColGenFieldSetup.Clear(); foreach (var olvRaw in this.olvColGenParsedRaw.Keys) { ColumnCatcher iCatcher = this.olvColGenParsedRaw[olvRaw]; var olvColumnSetup = new OLVColumn(); olvColumnSetup.Name = "FieldSetupColumn_" + (iCatcher.ColumnSerno + 1); olvColumnSetup.Text = "FieldSetup " + (iCatcher.ColumnSerno + 1); olvColumnSetup.Width = olvRaw.Width; olvColumnSetup.AspectGetter = iCatcher.AspectGetterFieldSetup; this.olvFieldSetup.Columns.Add(olvColumnSetup); this.olvColGenFieldSetup.Add(olvColumnSetup, iCatcher); } this.olvFieldSetup.SetObjects(this.dataSnapshot.OLVModel); }
void olvFieldSetup_CellEditStarting(object sender, CellEditEventArgs e) { OLVColumn column = e.Column; ColumnCatcher iCatcher = this.olvColGenFieldSetup[column]; FieldSetup fieldSetup = (FieldSetup)e.RowObject; ComboBox cb; switch (fieldSetup.RowIndexInObjectListView) { case 0: cb = iCatcher.CreateEditorTypesAvailable(); cb.DropDownStyle = ComboBoxStyle.DropDownList; //cb.Width = 85; break; case 1: cb = iCatcher.CreateEditorFormatsAvailable(); cb.DropDownStyle = ComboBoxStyle.DropDown; //cb.Width = 95; break; default: throw new Exception("this.olvFieldSetup should contain exactly TWO identical rows; OLV should've passed rowIndex into AspectGetter and CellEdit"); break; } if (cb != null) { if (cb.Width - 20 > 90) { cb.Width -= 20; } cb.Font = ((ObjectListView)sender).Font; cb.SelectedIndexChanged += new EventHandler(cb_SelectedIndexChanged); //cb.Bounds = e.CellBounds; cb.Location = new Point(e.CellBounds.Location.X, e.CellBounds.Location.Y + 2); //v1 cb.DroppedDown = true; //v2 https://connect.microsoft.com/VisualStudio/feedback/details/316175/dropdown-for-combo-box-is-separated-from-its-textbox SendKeys.Send("{F4}"); //PF4 == drop down the box e.Control = cb; } }
void step1parseFileInfo(ImportSourcePathInfo e) { this.dataSnapshot.FileSelected = e.FSI.Name; this.csvUnnamed = readCsvToMatrix(e.FSI.FullName); string status = " Rows[" + this.csvUnnamed.Count + "]"; if (this.csvUnnamed.Count == 0) { string msg = "File [" + e.FSI.Name + "] isn't a CSV file;\r\nDouble Click here to open and adjust your settings"; throw new Exception(msg); } int maxColumns = 0; foreach (var row in this.csvUnnamed) { if (row.Count > maxColumns) maxColumns = row.Count; } if (maxColumns == 0) { string msg = "File [" + e.FSI.Name + "] is CSV with ZERO columns (???);\r\nDouble Click here to open and adjust your settings"; throw new Exception(msg); } status += " Columns[" + maxColumns + "] found in File[" + e.FSI.Name + "]"; string statusOld = this.grpPreviewParsedRaw.Text; int posToAppend = statusOld.IndexOf('|'); //if (posToAppend < 0) posToAppend = 0; string prefix = statusOld.Substring(0, posToAppend+1); // no exception thrown even if posToAppend=-1 (not found) this.grpPreviewParsedRaw.Text = prefix + status; //this.csvPreviewParsedRaw.Columns.Clear(); //this.csvPreviewParsedRaw.AllColumns.Clear(); //this.csvPreviewParsedRaw.Clear(); this.olvCsvParsedRaw.Reset(); this.olvColGenParsedRaw.Clear(); //RELIES_ON_CLASS_PROPERTIES_WHICH_LIST<LIST<STRING>>_DOESNT_HAVE Generator.GenerateColumns(this.csvPreviewParsedRaw, csvUnnamed); //int width = this.csvPreviewParsedRaw.Width / maxColumns; for (int i = 0; i < maxColumns; i++) { var olvColumn = new OLVColumn(); olvColumn.Name = "AnonymousColumn_" + (i+1); olvColumn.Text = "Anonymous " + (i + 1); //olvColumn.Width = width; //if (i == maxColumns-1) olvColumn.FillsFreeSpace = true; ColumnCatcher iCatcher; if (this.dataSnapshot.FieldSetupCurrent.Count >= i+1) { iCatcher = this.dataSnapshot.FieldSetupCurrent[i]; } else { iCatcher = new ColumnCatcher(i, this.dataSnapshot); this.dataSnapshot.FieldSetupCurrent.Add(iCatcher); } olvColumn.AspectGetter = iCatcher.AspectGetterParsedRaw; this.olvCsvParsedRaw.Columns.Add(olvColumn); //this.csvPreviewParsedRaw.AllColumns.Add(olvColumn); this.olvColGenParsedRaw.Add(olvColumn, iCatcher); } //MAKES_THE_TABLE_EMPTY_EVEN_WITHOUT_HEADERS_this.csvPreviewParsedRaw.RebuildColumns(); this.olvCsvParsedRaw.SetObjects(this.csvUnnamed); this.olvCsvParsedRaw.AutoResizeColumns(); }
void step1parseFileInfo(ImportSourcePathInfo e) { this.dataSnapshot.FileSelected = e.FSI.Name; this.csvUnnamed = readCsvToMatrix(e.FSI.FullName); string status = " Rows[" + this.csvUnnamed.Count + "]"; if (this.csvUnnamed.Count == 0) { string msg = "File [" + e.FSI.Name + "] isn't a CSV file;\r\nDouble Click here to open and adjust your settings"; throw new Exception(msg); } int maxColumns = 0; foreach (var row in this.csvUnnamed) { if (row.Count > maxColumns) { maxColumns = row.Count; } } if (maxColumns == 0) { string msg = "File [" + e.FSI.Name + "] is CSV with ZERO columns (???);\r\nDouble Click here to open and adjust your settings"; throw new Exception(msg); } status += " Columns[" + maxColumns + "] found in File[" + e.FSI.Name + "]"; string statusOld = this.grpPreviewParsedRaw.Text; int posToAppend = statusOld.IndexOf('|'); //if (posToAppend < 0) posToAppend = 0; string prefix = statusOld.Substring(0, posToAppend + 1); // no exception thrown even if posToAppend=-1 (not found) this.grpPreviewParsedRaw.Text = prefix + status; //this.csvPreviewParsedRaw.Columns.Clear(); //this.csvPreviewParsedRaw.AllColumns.Clear(); //this.csvPreviewParsedRaw.Clear(); this.olvCsvParsedRaw.Reset(); this.olvColGenParsedRaw.Clear(); //RELIES_ON_CLASS_PROPERTIES_WHICH_LIST<LIST<STRING>>_DOESNT_HAVE Generator.GenerateColumns(this.csvPreviewParsedRaw, csvUnnamed); //int width = this.csvPreviewParsedRaw.Width / maxColumns; for (int i = 0; i < maxColumns; i++) { var olvColumn = new OLVColumn(); olvColumn.Name = "AnonymousColumn_" + (i + 1); olvColumn.Text = "Anonymous " + (i + 1); //olvColumn.Width = width; //if (i == maxColumns-1) olvColumn.FillsFreeSpace = true; ColumnCatcher iCatcher; if (this.dataSnapshot.FieldSetupCurrent.Count >= i + 1) { iCatcher = this.dataSnapshot.FieldSetupCurrent[i]; } else { iCatcher = new ColumnCatcher(i, this.dataSnapshot); this.dataSnapshot.FieldSetupCurrent.Add(iCatcher); } olvColumn.AspectGetter = iCatcher.AspectGetterParsedRaw; this.olvCsvParsedRaw.Columns.Add(olvColumn); //this.csvPreviewParsedRaw.AllColumns.Add(olvColumn); this.olvColGenParsedRaw.Add(olvColumn, iCatcher); } //MAKES_THE_TABLE_EMPTY_EVEN_WITHOUT_HEADERS_this.csvPreviewParsedRaw.RebuildColumns(); this.olvCsvParsedRaw.SetObjects(this.csvUnnamed); this.olvCsvParsedRaw.AutoResizeColumns(); }