Kyaria

EXIF

Feb 15th, 2018
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.85 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using System.IO;
  6. using System.Drawing.Imaging;
  7.  
  8. namespace EXIF
  9. {
  10.     public partial class Form1 : Form
  11.     {
  12.         private string[] drv;
  13.         private DirectoryInfo[] NoSpyARRAY;
  14.         private FileInfo[] NoFILESpyARRAY;
  15.  
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.             pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
  20.  
  21.             drv = Environment.GetLogicalDrives();
  22.             TreeNode ShinyNode;
  23.  
  24.             for (int i = 0; i < drv.Length; i++)
  25.             {
  26.                 ShinyNode = treeView1.Nodes.Add(drv[i]);
  27.  
  28.                 ShowSubDick(ShinyNode);
  29.             }
  30.         }
  31.  
  32.         private void ShowSubDick(TreeNode shinyNode)
  33.         {
  34.             DirectoryInfo NoSpy = new DirectoryInfo(shinyNode.FullPath);
  35.  
  36.             try
  37.             {
  38.                 NoSpyARRAY = NoSpy.GetDirectories();
  39.                 NoFILESpyARRAY = NoSpy.GetFiles();
  40.             }
  41.             catch { return;  }
  42.  
  43.             foreach (DirectoryInfo NewestDIRECTORYStuff in NoSpyARRAY)
  44.             {
  45.                 shinyNode.Nodes.Add(NewestDIRECTORYStuff.Name);
  46.             }
  47.  
  48.             foreach (FileInfo NewestFILEStuff in NoFILESpyARRAY)
  49.             {
  50.                 if (NewestFILEStuff.Name.Contains(".png") || NewestFILEStuff.Name.Contains(".jpeg") || NewestFILEStuff.Name.Contains(".jpg") || NewestFILEStuff.Name.Contains(".img") || NewestFILEStuff.Name.Contains(".gif"))
  51.                 {
  52.                     shinyNode.Nodes.Add(NewestFILEStuff.Name);
  53.                 }
  54.             }
  55.         }
  56.  
  57.         private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
  58.         {
  59.             foreach(TreeNode NewShinyNode in e.Node.Nodes)
  60.             {
  61.                 ShowSubDick(NewShinyNode);
  62.             }
  63.         }
  64.  
  65.         private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
  66.         {
  67.             if(e.Node.Nodes.Count == 0)
  68.             {
  69.                 ShowSubDick(e.Node);
  70.             }
  71.         }
  72.  
  73.         private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
  74.         {
  75.             DirectoryInfo ImageSpy = new DirectoryInfo(e.Node.FullPath);
  76.  
  77.             if (ImageSpy.ToString().Contains(".png") || ImageSpy.ToString().Contains(".jpeg") || ImageSpy.ToString().Contains(".jpg") || ImageSpy.ToString().Contains(".img") || ImageSpy.ToString().Contains(".gif"))
  78.             {
  79.                 textBox1.Clear();
  80.  
  81.                 pictureBox1.Image = Image.FromFile(ImageSpy.ToString());
  82.                 PropertyItem[] exifDATA = pictureBox1.Image.PropertyItems;
  83.                 ASCIIEncoding encoding = new ASCIIEncoding();
  84.                 string reader;
  85.  
  86.  
  87.                 foreach (PropertyItem exifARRAY in exifDATA)
  88.                 {
  89.                     reader = encoding.GetString(exifARRAY.Value);
  90.  
  91.                     if (exifARRAY.Id.ToString().Contains("271")) // Hexa: 0x010F
  92.                     {
  93.                         textBox1.Text += "Gerätehersteller: " + reader;
  94.                         textBox1.Text  += Environment.NewLine;
  95.                     }
  96.                     else if (exifARRAY.Id.ToString().Contains("272")) // Hexa: 0x0110
  97.                     {
  98.                         textBox1.Text += "Gerätemodell: " + reader;
  99.                         textBox1.Text += Environment.NewLine;
  100.                     }
  101.                     else if (exifARRAY.Id.ToString().Contains("800")) // Hexa: 0x0320
  102.                     {
  103.                         textBox1.Text += "Bildtitel: " + reader;
  104.                         textBox1.Text += Environment.NewLine;
  105.                     }
  106.                     else if (exifARRAY.Id.ToString().Contains("36867")) // Hexa: 0x9003
  107.                     {
  108.                         textBox1.Text += "Aufnahmezeitpunkt: " + reader;
  109.                         textBox1.Text += Environment.NewLine;
  110.                     }
  111.                     else if (exifARRAY.Id.ToString().Contains("33437")) // Hexa: 0x829D
  112.                     {
  113.                         textBox1.Text += "Blende: " + exifARRAY.Value[0];
  114.                         textBox1.Text += Environment.NewLine;
  115.                     }
  116.                     else if (exifARRAY.Id.ToString().Contains("34855")) // Hexa: 0x8827
  117.                     {
  118.                         textBox1.Text += "ISO-Empfindlichkeit: " + exifARRAY.Value[0];
  119.                         textBox1.Text += Environment.NewLine;
  120.                     }
  121.                     else if (exifARRAY.Id.ToString().Contains("41989")) // Hexa: 0xA405
  122.                     {
  123.                         textBox1.Text += "Brennweite (Bezogen auf 35mm): " + exifARRAY.Value[0];
  124.                         textBox1.Text += Environment.NewLine;
  125.                     }
  126.                 }
  127.             }
  128.         }
  129.     }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment