Kyaria icon

EXIF

Kyaria | PRO | 02/15/18 08:10:44 PM UTC | 0 ⭐ | 393 👁️ | Never ⏰ | []
C# |

4.85 KB

|

None

|

0 👍

/

0 👎

using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
 
namespace EXIF
{
    public partial class Form1 : Form
    {
        private string[] drv;
        private DirectoryInfo[] NoSpyARRAY;
        private FileInfo[] NoFILESpyARRAY;
 
        public Form1()
        {
            InitializeComponent();
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
 
            drv = Environment.GetLogicalDrives();
            TreeNode ShinyNode;
 
            for (int i = 0; i < drv.Length; i++)
            {
                ShinyNode = treeView1.Nodes.Add(drv[i]);
 
                ShowSubDick(ShinyNode);
            }
        }
 
        private void ShowSubDick(TreeNode shinyNode)
        {
            DirectoryInfo NoSpy = new DirectoryInfo(shinyNode.FullPath);
 
            try
            {
                NoSpyARRAY = NoSpy.GetDirectories();
                NoFILESpyARRAY = NoSpy.GetFiles();
            }
            catch { return;  }
 
            foreach (DirectoryInfo NewestDIRECTORYStuff in NoSpyARRAY)
            {
                shinyNode.Nodes.Add(NewestDIRECTORYStuff.Name);
            }
 
            foreach (FileInfo NewestFILEStuff in NoFILESpyARRAY)
            {
                if (NewestFILEStuff.Name.Contains(".png") || NewestFILEStuff.Name.Contains(".jpeg") || NewestFILEStuff.Name.Contains(".jpg") || NewestFILEStuff.Name.Contains(".img") || NewestFILEStuff.Name.Contains(".gif"))
                {
                    shinyNode.Nodes.Add(NewestFILEStuff.Name);
                }
            }
        }
 
        private void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
        {
            foreach(TreeNode NewShinyNode in e.Node.Nodes)
            {
                ShowSubDick(NewShinyNode);
            }
        }
 
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if(e.Node.Nodes.Count == 0)
            {
                ShowSubDick(e.Node);
            }
        }
 
        private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            DirectoryInfo ImageSpy = new DirectoryInfo(e.Node.FullPath);
 
            if (ImageSpy.ToString().Contains(".png") || ImageSpy.ToString().Contains(".jpeg") || ImageSpy.ToString().Contains(".jpg") || ImageSpy.ToString().Contains(".img") || ImageSpy.ToString().Contains(".gif"))
            {
                textBox1.Clear();
 
                pictureBox1.Image = Image.FromFile(ImageSpy.ToString());
                PropertyItem[] exifDATA = pictureBox1.Image.PropertyItems;
                ASCIIEncoding encoding = new ASCIIEncoding();
                string reader;
 
 
                foreach (PropertyItem exifARRAY in exifDATA)
                {
                    reader = encoding.GetString(exifARRAY.Value);
 
                    if (exifARRAY.Id.ToString().Contains("271")) // Hexa: 0x010F
                    {
                        textBox1.Text += "Gerätehersteller: " + reader;
                        textBox1.Text  += Environment.NewLine;
                    }
                    else if (exifARRAY.Id.ToString().Contains("272")) // Hexa: 0x0110
                    {
                        textBox1.Text += "Gerätemodell: " + reader;
                        textBox1.Text += Environment.NewLine;
                    }
                    else if (exifARRAY.Id.ToString().Contains("800")) // Hexa: 0x0320
                    {
                        textBox1.Text += "Bildtitel: " + reader;
                        textBox1.Text += Environment.NewLine;
                    }
                    else if (exifARRAY.Id.ToString().Contains("36867")) // Hexa: 0x9003
                    {
                        textBox1.Text += "Aufnahmezeitpunkt: " + reader;
                        textBox1.Text += Environment.NewLine;
                    }
                    else if (exifARRAY.Id.ToString().Contains("33437")) // Hexa: 0x829D
                    {
                        textBox1.Text += "Blende: " + exifARRAY.Value[0]; 
                        textBox1.Text += Environment.NewLine;
                    }
                    else if (exifARRAY.Id.ToString().Contains("34855")) // Hexa: 0x8827
                    {
                        textBox1.Text += "ISO-Empfindlichkeit: " + exifARRAY.Value[0]; 
                        textBox1.Text += Environment.NewLine;
                    }
                    else if (exifARRAY.Id.ToString().Contains("41989")) // Hexa: 0xA405
                    {
                        textBox1.Text += "Brennweite (Bezogen auf 35mm): " + exifARRAY.Value[0]; 
                        textBox1.Text += Environment.NewLine;
                    }
                }
            }
        }
    }
}

Comments