示例#1
0
 //событие клика по хедеру строки которое выводит картинку в превью
 //click event on the header of the line that displays the picture in the preview
 private void dataGridView1_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
 {
     try
     {
         //получаем индекс выбранного ряда
         //get the index of the selected row
         int i = dataGridView1.CurrentRow.Index;
         //выводим новое фото в pictureBox
         //print a new photo in the pictureBox
         pictureBox1.Image = new Bitmap(lister.PATH_OF_PHOTO(i));
     }
     //в случае клика по хедеру пустой строки ловим исключение
     //In the case of a click on an empty line, we catch the exception
     catch (ArgumentOutOfRangeException)
     {
         //выводим данное сообщение
         //output this message
         MessageBox.Show("Пустая строка!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);//выводим данное сообщение
     }
 }
示例#2
0
 //метод поиска и вывода по году
 //method of search and output by year
 private void search_year()
 {
     try
     {
         //объявляем объект класса  FileInfo
         //declare an object of the FileInfo class
         FileInfo jack;
         //экземпляр структуры DateTime
         //an instance of the DateTime structure
         DateTime jessica;
         //считываем  ввод данных пользователя
         //read user input
         int comp = Convert.ToInt32(textBox1.Text);
         //считываем количество элементов коллекции "List" в объекте типа Photo_List
         //we read the number of elements of the "List" collection in the object of type Photo_List
         int count = NewLister.COUNT_int;
         //просматриваем все элементы коллекции "List" в объекте типа Photo_List
         //we scan all the elements of the "List" collection in an object of the type Photo_List
         for (int i = 0; i < count; i++)
         {
             //получаем данные о фото через объект класса  FileInfo
             //get photo data through an object of the FileInfo class
             jack = new FileInfo(NewLister.PATH_OF_PHOTO(i));
             //передаём экземпляру DateTime данные о создании файла(здесь фото)
             //we pass to the instance DateTime the data about the creation of the file (here the photo)
             jessica = jack.CreationTime;
             //сравниваем год создания и введенные данные
             //compare the year of creation and the data entered
             if (comp == jessica.Year)
             {
                 //если есть совпадения выводим эти файлы
                 //if there are matches, output these files
                 dataGridView1.Rows.Add(NewLister.NAME_OF_PHOTO(i), NewLister.DATE_OF_PHOTO(i).ToString());
             }
         }
     }
     //если ловим екзепшн
     //if we catch exception
     catch (FormatException)
     {
         //то выводим данное сообщение
         //then output this message
         MessageBox.Show("Неверные входные данные!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);//выводим данное сообщение
     }
 }