Exemple #1
0
        }//end function

        private void format_Items()
        {
            var lsField = _indexField.Values.ToList();

            if (lsField.IndexOf(_Word) == -1 || lsField.IndexOf(_Meaning) == -1)
            {
                MessageBox.Show(string.Format("Please choose config column [{0}] and [{1}]", _Word, _Meaning));
                return;
            }

            int countCell = _listItems.Select(x => x.Length).Max();
            int colMiss   = countCell - _indexField.Count;

            if (colMiss > 1)
            {
                if (MessageBox.Show("Has " + colMiss.ToString() + " column not config, Are you will submit?", "Are you sure ?",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation,
                                    MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
            }

            int index = 0;

            _listWord.Clear();
            _listExam.Clear();

            #region
            foreach (string[] it in _listItems)
            {
                string word           = DataExtract.format_Word(it[_indexWord]),
                              meaning = DataExtract.format_Meaning(it[_indexMeaning]);

                ELWORD o = new ELWORD()
                {
                    WORD = word, MEANING = meaning
                };
                ELEXAMPLE xam = null;

                foreach (var kv in _indexField)
                {
                    switch (kv.Value)
                    {
                    case "Pronounce":
                        o.PRONOUNCE = it[kv.Key];
                        break;

                    case "Type":
                        o.TYPE = (byte)DataExtract.fomart_Type(it[kv.Key]);
                        break;

                    case "Example":
                        if (xam == null)
                        {
                            xam = new ELEXAMPLE()
                            {
                                WORD = word
                            }
                        }
                        ;
                        xam.EXAMPLE = it[kv.Key];
                        break;

                    case "Example_Meaning":
                        if (xam == null)
                        {
                            xam = new ELEXAMPLE()
                            {
                                WORD = word
                            }
                        }
                        ;
                        xam.MEANING = it[kv.Key];
                        break;
                    }
                }
                _listWord.Add(o);
                if (xam != null)
                {
                    _listExam.Add(xam);
                }
                index++;
            }
            #endregion
        }
Exemple #2
0
        private void load_Data()
        {
            view.Clear();
            int countCell = _listItems.Select(x => x.Length).Max();

            view.Columns.Add(new ColumnHeader {
                Text = "", Width = 40
            });
            for (int i = 1; i < countCell; i++)
            {
                _indexField.Add(i, "");
                view.Columns.Add(new ColumnHeader {
                    Text = "Column " + i.ToString(), Width = 125
                });
                ComboBox com = new ComboBox()
                {
                    Tag           = i,
                    Left          = (i - 1) * 125 + 40,
                    Top           = 7,
                    Width         = 125,
                    DropDownStyle = ComboBoxStyle.DropDownList,
                };
                com.SelectedIndexChanged += (se, ev) =>
                {
                    ComboBox si     = (ComboBox)se;
                    int      column = (int)si.Tag;
                    string   field  = _fields[si.SelectedIndex == 0 ? 0 : si.SelectedIndex - 1];
                    _indexField[column] = field;
                    switch (field)
                    {
                    case _Word:
                        _indexWord = column;
                        break;

                    case _Meaning:
                        _indexMeaning = column;
                        break;
                    }
                };
                com.Items.Add("");
                com.Items.AddRange(_fields);
                boxHeader.Controls.Add(com);
                if (countCell == 3)
                {
                    if (i == 1)
                    {
                        com.SelectedIndex = 1;
                    }
                    else if (i == 2)
                    {
                        com.SelectedIndex = 4;
                    }
                }
                else if (i <= 3)
                {
                    com.SelectedIndex = i;
                }
            }

            int k = 1;

            foreach (string[] it in _listItems)
            {
                if (it.Length < 3)
                {
                    continue;
                }
                bool chk = false;
                if (it[2][0] == '/')
                {
                    chk = true;
                }
                it[1] = DataExtract.format_Word(it[1]);
                view.Items.Add(new ListViewItem(it)
                {
                    Checked = chk
                });
                if (k % 2 == 0)
                {
                    view.Items[k - 1].BackColor = SystemColors.ControlLight;
                }
                k++;
            } //end for line
        }     // end function