Пример #1
0
        private void btnChooseFileImage_Click(object sender, EventArgs e)
        {
            openFileDialog1.FileName         = "";
            openFileDialog1.InitialDirectory = txtPathImportImage.Text;
            DialogResult r = openFileDialog1.ShowDialog();

            if (r == System.Windows.Forms.DialogResult.OK)
            {
                txtFileImportImage.Text = Path.GetFileName(openFileDialog1.FileName);
                txtPathImportImage.Text = Path.GetDirectoryName(openFileDialog1.FileName);
            }
            if (openFileDialog1.FileName != "")
            {
                try
                {
                    picImage.Load(openFileDialog1.FileName);
                    List <string> captions = db.GetCaptionsOfThisImage(txtFileImportImage.Text);
                    if (captions.Count > 0)
                    {
                        txtCaption.Text = captions[captions.Count - 1];
                    }
                    else
                    {
                        txtCaption.Text = "";
                    }
                }
                catch
                {
                    MessageBox.Show("Immagine non caricata.\nFormato non supportato?");
                }
            }
        }