private void bttnAddFolderContent_Click(object sender, EventArgs e) { frmAttributes attributes = new frmAttributes(cols); if (attributes.ShowDialog() == DialogResult.OK) { FolderBrowserDialog fb = new FolderBrowserDialog(); //fb.SelectedPath = initDir; fb.ShowNewFolderButton = false; fb.SelectedPath = destinationFolder; if (fb.ShowDialog() == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; List <string> flist = new List <string>(); flist = Directory.GetFiles(fb.SelectedPath, "*.tif").ToList(); flist.AddRange(Directory.GetFiles(fb.SelectedPath, "*.jpg").ToList()); string[] fn = flist.ToArray(); tspb.Maximum = fn.Length; tspb.Visible = true; foreach (string files in fn) { tspb.PerformStep(); string[] exif = getExifData(files); FileInfo fi = new FileInfo(files); Int32 filesize = (Int32)fi.Length; string imagesize = ""; string camera = ""; int bitspersample = 0; int sampleperpixel = 0; string fname = Path.GetFileName(files); DateTime dt = File.GetLastWriteTime(files); string met = attributes.meteo; string auth = attributes.author; double longit = 0; double latit = 0; for (int i = 0; i < exif.Length; i++) { string[] sline = exif[i].Split(';'); if (sline[0].ToLower() == "gps longitude") { longit = convertDegree2Decimal(sline[1].Trim()); } if (sline[0].ToLower() == "gps latitude") { latit = convertDegree2Decimal(sline[1].Trim()); } if (sline[0].ToLower() == "image size") { imagesize = sline[1].Trim(); } if (sline[0].ToLower() == "make") { camera = sline[1].Trim(); } if (sline[0].ToLower() == "bits per sample") { bitspersample = Convert.ToInt16(sline[1].Trim()); } if (sline[0].ToLower() == "samples per pixel") { sampleperpixel = Convert.ToInt16(sline[1].Trim()); } if (sline[0].ToLower() == "color components") { sampleperpixel = Convert.ToInt16(sline[1].Trim()); } } string location = attributes.loc; string content = attributes.content; string purpose = attributes.purpose; Boolean pub = attributes.publi; string tipus = attributes.tipus; string comment = attributes.comment; string drontipus = attributes.drontype; string oper = attributes.opera; insertFile(fname, tipus, Path.GetDirectoryName(files), dt, location, met, content, longit, latit, auth, purpose, pub, comment, filesize, imagesize, camera, bitspersample, sampleperpixel, drontipus, oper); } bs.DataSource = refreshDatagrid(); tspb.Value = 0; tspb.Visible = false; this.Cursor = Cursors.Default; } } }
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { frmAttributes attributes = new frmAttributes(cols); if (attributes.ShowDialog() == DialogResult.OK) { OpenFileDialog of = new OpenFileDialog(); of.InitialDirectory = destinationFolder; of.Multiselect = true; of.Filter = "Image files (jpg, tif)|*.jpg;*.tif"; if (of.ShowDialog() == DialogResult.OK) { //initDir = Path.GetDirectoryName(of.FileName); this.Cursor = Cursors.WaitCursor; tspb.Maximum = of.FileNames.Length; tspb.Visible = true; foreach (string files in of.FileNames) { tspb.PerformStep(); FileInfo fi = new FileInfo(files); string[] exif = getExifData(files); Int32 filesize = (Int32)fi.Length; string imagesize = ""; string camera = ""; int bitspersample = 0; int sampleperpixel = 0; string fname = Path.GetFileName(files); DateTime dt = File.GetLastWriteTime(files); string met = attributes.meteo; string auth = attributes.author; double longit = 0; double latit = 0; for (int i = 0; i < exif.Length; i++) { string[] sline = exif[i].Split(';'); if (sline[0].ToLower() == "gps longitude") { longit = convertDegree2Decimal(sline[1].Trim()); } if (sline[0].ToLower() == "gps latitude") { latit = convertDegree2Decimal(sline[1].Trim()); } if (sline[0].ToLower() == "image size") { imagesize = sline[1].Trim(); } if (sline[0].ToLower() == "make") { camera = sline[1].Trim(); } if (sline[0].ToLower() == "bits per sample") { bitspersample = Convert.ToInt16(sline[1].Trim()); } if (sline[0].ToLower() == "samples per pixel") { sampleperpixel = Convert.ToInt16(sline[1].Trim()); } if (sline[0].ToLower() == "color components") { sampleperpixel = Convert.ToInt16(sline[1].Trim()); } } string location = attributes.loc; string content = attributes.content; string purpose = attributes.purpose; Boolean pub = attributes.publi; string tipus = attributes.tipus; string comment = attributes.comment; string drontipus = attributes.drontype; string oper = attributes.opera; insertFile(fname, tipus, Path.GetDirectoryName(files), dt, location, met, content, longit, latit, auth, purpose, pub, comment, filesize, imagesize, camera, bitspersample, sampleperpixel, drontipus, oper); } bs.DataSource = refreshDatagrid(); this.Cursor = Cursors.Default; tspb.Visible = false; tspb.Value = 0; } } }