Пример #1
0
        private void dataGridView1_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e)
        {
            if (e.RowIndex >= 0 & fileList.Count > e.RowIndex)
            {
                fileListElement fileEl = fileList[e.RowIndex];
                string          valStr;
                switch (e.ColumnIndex)
                {
                case 0:
                    valStr = fileEl.fileName;
                    break;

                case 1:
                    valStr = fileEl.make;
                    break;

                case 2:
                    valStr = fileEl.makeDate;
                    break;

                case 3:
                    valStr = fileEl.check;
                    break;

                case 4:
                    valStr = fileEl.checkDate;
                    break;

                case 5:
                    valStr = fileEl.tpType;
                    break;
                }
                dataGridView1.CurrentCell.Value = fileEl;
            }
        }
Пример #2
0
        void Form1_DragDrop(object sender, DragEventArgs e)
        {
            Random rnd            = new Random();
            int    makeNameCount  = textBoxMake.Lines.Last() == "" ? textBoxMake.Lines.Length - 1: textBoxMake.Lines.Length;
            int    checkNameCount = textBoxCheck.Lines.Last() == "" ? textBoxCheck.Lines.Length - 1 : textBoxCheck.Lines.Length;
            string currentDate    = DateTime.Now.ToString("dd.MM.yy");

            string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
            foreach (string file in files)
            {
                if (file.Contains(".kml"))
                {
                    string fileName = file;
                    string filePath = "";
                    int    slashPos = file.LastIndexOf('\\');
                    if (slashPos != -1)
                    {
                        fileName = file.Substring(slashPos + 1, file.Length - slashPos - 1);
                        filePath = file.Substring(0, slashPos);
                    }
                    fileListElement fle = new fileListElement();
                    fle.fileName  = fileName;
                    fle.filePath  = filePath;
                    fle.make      = textBoxMake.Lines[rnd.Next(makeNameCount - 1)];
                    fle.makeDate  = currentDate;
                    fle.checkDate = currentDate;
                    fle.check     = textBoxCheck.Lines[rnd.Next(checkNameCount - 1)];
                    if (!fileList.Contains(fle))
                    {
                        fileList.Add(fle);
                        LogTextEvent(Color.Black, "Добавлен файл " + file);
                    }
                    else
                    {
                        LogTextEvent(Color.Red, "Файл с таким название уже добавлен: " + file);
                    }
                }
                else
                {
                    LogTextEvent(Color.Red, "Расширение файла должно быть KLM: " + file);
                }
            }
            fileListElementBindingSource.ResetBindings(true);
        }
Пример #3
0
        private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            var value = dataGridView1.CurrentCell.Value;

            if (e.RowIndex >= 0 & value != null)
            {
                fileListElement fileEl = fileList[e.RowIndex];
                string          valStr = value.ToString();
                switch (e.ColumnIndex)
                {
                case 0:
                    fileEl.fileName = valStr;
                    break;

                case 1:
                    fileEl.make = valStr;
                    break;

                case 2:
                    fileEl.makeDate = valStr;
                    break;

                case 3:
                    fileEl.check = valStr;
                    break;

                case 4:
                    fileEl.checkDate = valStr;
                    break;

                case 5:
                    fileEl.tpType = valStr;
                    break;

                case 6:
                    fileEl.city = valStr;
                    break;
                }
                fileList[e.RowIndex] = fileEl;
            }
        }