diff --git a/PictureReposit/Form1.Designer.cs b/PictureReposit/Form1.Designer.cs
new file mode 100644
index 0000000..93f6671
--- /dev/null
+++ b/PictureReposit/Form1.Designer.cs
@@ -0,0 +1,194 @@
+
+namespace PictureReposit
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
+ this.pictureBox1 = new System.Windows.Forms.PictureBox();
+ this.lstPicFiles = new System.Windows.Forms.ListBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.lblPath = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.lblFileName = new System.Windows.Forms.Label();
+ this.lblCreated = new System.Windows.Forms.Label();
+ this.btnFileDialog = new System.Windows.Forms.Button();
+ this.btnReOrganize = new System.Windows.Forms.Button();
+ this.label3 = new System.Windows.Forms.Label();
+ this.txtRootDir = new System.Windows.Forms.TextBox();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
+ this.SuspendLayout();
+ //
+ // openFileDialog1
+ //
+ this.openFileDialog1.FileName = "openFileDialog1";
+ //
+ // pictureBox1
+ //
+ this.pictureBox1.Location = new System.Drawing.Point(183, 72);
+ this.pictureBox1.Name = "pictureBox1";
+ this.pictureBox1.Size = new System.Drawing.Size(654, 548);
+ this.pictureBox1.TabIndex = 0;
+ this.pictureBox1.TabStop = false;
+ //
+ // lstPicFiles
+ //
+ this.lstPicFiles.FormattingEnabled = true;
+ this.lstPicFiles.ItemHeight = 15;
+ this.lstPicFiles.Location = new System.Drawing.Point(13, 72);
+ this.lstPicFiles.Name = "lstPicFiles";
+ this.lstPicFiles.Size = new System.Drawing.Size(164, 424);
+ this.lstPicFiles.TabIndex = 1;
+ this.lstPicFiles.SelectedIndexChanged += new System.EventHandler(this.lstPicFiles_SelectedIndexChanged);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(146, 9);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(31, 15);
+ this.label1.TabIndex = 2;
+ this.label1.Text = "Path";
+ //
+ // lblPath
+ //
+ this.lblPath.AutoSize = true;
+ this.lblPath.Location = new System.Drawing.Point(183, 9);
+ this.lblPath.Name = "lblPath";
+ this.lblPath.Size = new System.Drawing.Size(574, 15);
+ this.lblPath.TabIndex = 3;
+ this.lblPath.Text = " " +
+ " " +
+ " x";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(127, 24);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(50, 15);
+ this.label2.TabIndex = 4;
+ this.label2.Text = "Filnamn";
+ //
+ // lblFileName
+ //
+ this.lblFileName.AutoSize = true;
+ this.lblFileName.Location = new System.Drawing.Point(183, 24);
+ this.lblFileName.Name = "lblFileName";
+ this.lblFileName.Size = new System.Drawing.Size(373, 15);
+ this.lblFileName.TabIndex = 5;
+ this.lblFileName.Text = " " +
+ " x";
+ //
+ // lblCreated
+ //
+ this.lblCreated.AutoSize = true;
+ this.lblCreated.Location = new System.Drawing.Point(563, 23);
+ this.lblCreated.Name = "lblCreated";
+ this.lblCreated.Size = new System.Drawing.Size(51, 15);
+ this.lblCreated.TabIndex = 6;
+ this.lblCreated.Text = "Skapad: ";
+ //
+ // btnFileDialog
+ //
+ this.btnFileDialog.Location = new System.Drawing.Point(13, 43);
+ this.btnFileDialog.Name = "btnFileDialog";
+ this.btnFileDialog.Size = new System.Drawing.Size(75, 23);
+ this.btnFileDialog.TabIndex = 7;
+ this.btnFileDialog.Text = "Välj Fil";
+ this.btnFileDialog.UseVisualStyleBackColor = true;
+ this.btnFileDialog.Click += new System.EventHandler(this.btnFileDialog_Click);
+ //
+ // btnReOrganize
+ //
+ this.btnReOrganize.Location = new System.Drawing.Point(13, 503);
+ this.btnReOrganize.Name = "btnReOrganize";
+ this.btnReOrganize.Size = new System.Drawing.Size(164, 23);
+ this.btnReOrganize.TabIndex = 8;
+ this.btnReOrganize.Text = "Reorganisera Filer";
+ this.btnReOrganize.UseVisualStyleBackColor = true;
+ this.btnReOrganize.Click += new System.EventHandler(this.btnReOrganize_Click);
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(13, 533);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(83, 15);
+ this.label3.TabIndex = 9;
+ this.label3.Text = "Ny RotKatalog";
+ //
+ // txtRootDir
+ //
+ this.txtRootDir.Location = new System.Drawing.Point(13, 563);
+ this.txtRootDir.Name = "txtRootDir";
+ this.txtRootDir.Size = new System.Drawing.Size(164, 23);
+ this.txtRootDir.TabIndex = 10;
+ this.txtRootDir.Text = "D:\\Bildlabb\\LabRotCat";
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(869, 642);
+ this.Controls.Add(this.txtRootDir);
+ this.Controls.Add(this.label3);
+ this.Controls.Add(this.btnReOrganize);
+ this.Controls.Add(this.btnFileDialog);
+ this.Controls.Add(this.lblCreated);
+ this.Controls.Add(this.lblFileName);
+ this.Controls.Add(this.label2);
+ this.Controls.Add(this.lblPath);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.lstPicFiles);
+ this.Controls.Add(this.pictureBox1);
+ this.Name = "Form1";
+ this.Text = "Form1";
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.OpenFileDialog openFileDialog1;
+ private System.Windows.Forms.PictureBox pictureBox1;
+ private System.Windows.Forms.ListBox lstPicFiles;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Label lblPath;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.Label lblFileName;
+ private System.Windows.Forms.Label lblCreated;
+ private System.Windows.Forms.Button btnFileDialog;
+ private System.Windows.Forms.Button btnReOrganize;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.TextBox txtRootDir;
+ }
+}
+
diff --git a/PictureReposit/Form1.cs b/PictureReposit/Form1.cs
new file mode 100644
index 0000000..01b11a7
--- /dev/null
+++ b/PictureReposit/Form1.cs
@@ -0,0 +1,194 @@
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PictureReposit
+{
+ public partial class Form1 : Form
+ {
+
+ private bool Deleting = false;
+ public Form1()
+ {
+ InitializeComponent();
+
+ RegistryKey PictureHandling = Registry.LocalMachine.OpenSubKey(@"Software\Tfoman\PictureHandling");
+ if (PictureHandling == null)
+ {
+ txtRootDir.Text = @"D:\Bildlabb\LabRotCat";
+ }
+ else
+ {
+ txtRootDir.Text = (string)PictureHandling.GetValue(@"RootMap");
+ }
+
+ }
+
+ private void btnFileDialog_Click(object sender, EventArgs e)
+ {
+ openFileDialog1.Title = "Välj bild-fil!";
+ openFileDialog1.InitialDirectory = "C:\\";
+ openFileDialog1.Filter = "Picture files (*.jpg)|*.jpg|All files (*.*)|*.*";
+ openFileDialog1.FilterIndex = 1;
+ openFileDialog1.RestoreDirectory = true;
+ openFileDialog1.ShowDialog();
+ openFileDialog1.Multiselect = false;
+ string fName = openFileDialog1.FileName;
+ if (fName.Trim() != "")
+ {
+ int fNamePos = fName.LastIndexOf(@"\") + 1;
+ lblFileName.Text = fName.Substring(fNamePos);
+ lblPath.Text = fName.Substring(0, fNamePos);
+ listLocalFiles();
+
+ for (int i = 0; i < lstPicFiles.Items.Count; i++)
+ {
+ if (lstPicFiles.Items[i].ToString() == lblFileName.Text)
+ {
+ lstPicFiles.SelectedIndex = i;
+ break;
+ }
+ }
+
+ }
+ }
+
+ private void listLocalFiles()
+ {
+ DirectoryInfo di = new DirectoryInfo(lblPath.Text);
+ FileInfo[] files = di.GetFiles("*.jpg");
+ lstPicFiles.Items.Clear();
+ for (int i = 0; i < files.Length; i++)
+ {
+ lstPicFiles.Items.Add(files[i].Name);
+ }
+ files = di.GetFiles("*.jpeg");
+ for (int i = 0; i < files.Length; i++)
+ {
+ lstPicFiles.Items.Add(files[i].Name);
+ }
+ btnReOrganize.Enabled = true;
+ }
+
+ private void lstPicFiles_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ if (!Deleting)
+ {
+ string fName = ((ListBox)sender).SelectedItem.ToString();
+ lblFileName.Text = fName;
+ Image actPic = Image.FromFile(lblPath.Text + fName, true);
+ lblCreated.Text = "Skapad: " + TakenDate(actPic);
+ int w = actPic.Width;
+ int h = actPic.Height;
+ int pw = pictureBox1.Width;
+ int ph = pictureBox1.Height;
+ pictureBox1.SizeMode = PictureBoxSizeMode.Normal;
+ Bitmap to_bm = new Bitmap((Image)actPic.Clone(), w * ph / h, ph);
+ pictureBox1.Image = to_bm;
+ actPic = null;
+
+ }
+ }
+
+ private string TakenDate(Image actPic)
+ {
+ string sPropDatTaken = "";
+ for (int i = 0; i < actPic.PropertyIdList.Length; i++)
+ {
+ if (actPic.PropertyIdList[i] == 306)
+ {
+ for (int j = 0; j < actPic.PropertyItems[i].Len; j++)
+ {
+ sPropDatTaken += Convert.ToChar(actPic.PropertyItems[i].Value[j]);
+ }
+ }
+ }
+ //actPic.Dispose();
+ return sPropDatTaken;
+ }
+
+ private void btnReOrganize_Click(object sender, EventArgs e)
+ {
+ bool error_upd = false;
+ if (txtRootDir.Text.Trim().Substring(txtRootDir.Text.Trim().Length - 1) != @"\")
+ txtRootDir.Text = txtRootDir.Text.Trim() + @"\";
+ DirectoryInfo di = new DirectoryInfo(txtRootDir.Text);
+ if (!di.Exists) di.Create();
+ Deleting = true;
+ pictureBox1.Image = null;
+ pictureBox1.Refresh();
+ for (int i = lstPicFiles.Items.Count - 1; i > -1; i--)
+ {
+ string lFileName = lstPicFiles.Items[i].ToString().Trim();
+ string fName = lblPath.Text.Trim() + lFileName;
+ lblFileName.Text = fName;
+ Image actIm = Image.FromFile(fName, true);
+ int w = actIm.Width;
+ int h = actIm.Height;
+ int pw = pictureBox1.Width;
+ int ph = pictureBox1.Height;
+ pictureBox1.SizeMode = PictureBoxSizeMode.Normal;
+ Bitmap to_bm = new Bitmap((Image)actIm.Clone(), w * ph / h, ph);
+ pictureBox1.Image = to_bm;
+ string td = TakenDate(actIm);
+
+ actIm.Dispose();
+ if (td.Trim() != "")
+ {
+ lblCreated.Text = "Skapad: " + td;
+ td = td.Substring(0, 10);
+ DateTime dttd = DateTime.Parse(td.Replace(":", "-"));
+ string subDir1 = dttd.Year.ToString("0000") + "-" + dttd.Month.ToString("00") + @"\";
+ string subDir2 = dttd.Year.ToString("0000") + "_" + dttd.Month.ToString("00") + "_" + dttd.Day.ToString("00") + @"\";
+ DirectoryInfo dis = new DirectoryInfo(di.FullName + subDir1);
+ if (!dis.Exists) dis.Create();
+ DirectoryInfo diss = new DirectoryInfo(dis.FullName + subDir2);
+ if (!diss.Exists) diss.Create();
+
+ FileInfo fi = new FileInfo(fName);
+ //Tommy
+ fi.CopyTo(diss.FullName + lFileName);
+ error_upd = false;
+ do
+ {
+ error_upd = false;
+ try
+ {
+ lstPicFiles.BeginUpdate();
+ }
+ catch
+ {
+ error_upd = true;
+ }
+ }
+ while (error_upd);
+ lstPicFiles.Items.RemoveAt(i);
+ lstPicFiles.EndUpdate();
+ lstPicFiles.Refresh();
+ lblCreated.Refresh();
+ lblFileName.Refresh();
+ pictureBox1.Refresh();
+ this.Refresh();
+ }
+ }
+ Deleting = false;
+ lblCreated.Text = "";
+ lblFileName.Text = "";
+ lblPath.Text = "";
+ btnReOrganize.Enabled = false;
+ }
+
+ private void txtRootDir_TextChanged(object sender, EventArgs e)
+ {
+
+ }
+ }
+}
diff --git a/PictureReposit/Form1.resx b/PictureReposit/Form1.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/PictureReposit/Form1.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/PictureReposit/PictureReposit.csproj b/PictureReposit/PictureReposit.csproj
new file mode 100644
index 0000000..a2d4310
--- /dev/null
+++ b/PictureReposit/PictureReposit.csproj
@@ -0,0 +1,9 @@
+
+
+
+ WinExe
+ net5.0-windows
+ true
+
+
+
\ No newline at end of file
diff --git a/PictureReposit/Program.cs b/PictureReposit/Program.cs
new file mode 100644
index 0000000..6470533
--- /dev/null
+++ b/PictureReposit/Program.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace PictureReposit
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.SetHighDpiMode(HighDpiMode.SystemAware);
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Application.Run(new Form1());
+ }
+ }
+}
diff --git a/PictureRepositApp.sln b/PictureRepositApp.sln
new file mode 100644
index 0000000..0849f42
--- /dev/null
+++ b/PictureRepositApp.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.31005.135
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PictureReposit", "PictureReposit\PictureReposit.csproj", "{2AAC2FEB-B0A8-4EA2-9CB0-1E6DA91A7152}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2AAC2FEB-B0A8-4EA2-9CB0-1E6DA91A7152}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2AAC2FEB-B0A8-4EA2-9CB0-1E6DA91A7152}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2AAC2FEB-B0A8-4EA2-9CB0-1E6DA91A7152}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2AAC2FEB-B0A8-4EA2-9CB0-1E6DA91A7152}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {B31DD224-40DA-4B5F-955A-5A787D229689}
+ EndGlobalSection
+EndGlobal