示例#1
0
        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();
        }
示例#2
0
        public object AspectGetterFieldSetup(object shouldBeListOfCatchers)
        {
            try {
                FieldSetup thisRowFieldSetup = shouldBeListOfCatchers as FieldSetup;
                if (thisRowFieldSetup == null)
                {
                    Assembler.PopupException("shouldBeListOfCatchers is not FieldSetup");
                    return("NOT_LIST<ColumnCatcher>");
                }

                switch (thisRowFieldSetup.RowIndexInObjectListView)
                {
                case 0:
                    if (thisRowFieldSetup.Count == 0)
                    {
                        Assembler.PopupException("shouldBeListOfCatchers.Count=0");
                        return("LIST<ColumnCatcher>.COUNT=0");
                    }
                    if (thisRowFieldSetup.Name != this.DataSnapshot.FieldSetupCurrent.Name)
                    {
                        return("NOT_FieldSetupCurrent.Name");
                    }
                    if (this.DataSnapshot.OLVModel.IndexOf(thisRowFieldSetup) != 0)
                    {
                        return("NOT_IN_OLVMODEL");
                    }
                    CsvTypeParser parser = thisRowFieldSetup[this.ColumnSerno].Parser;
                    return(parser.CsvType);

                //break;
                case 1:
                    if (thisRowFieldSetup.Name != "STUB_DISPLAY_FORMATS")
                    {
                        return("NOT_STUB_DISPLAY_FORMATS");
                    }
                    FieldSetup    prevRowFieldSetup = this.DataSnapshot.OLVModel[0];
                    CsvTypeParser prevRowParser     = prevRowFieldSetup[this.ColumnSerno].Parser;
                    return(prevRowParser.CsvTypeFormat);

                //break;
                default:
                    return("2ROWS_MAX");
                    //break;
                }
            } catch (Exception ex) {
                return("WRD" + ex.Message);
            }
        }
示例#3
0
        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;
            }
        }