Nu fungerar hela inläsningen och reorganisationen !
This commit is contained in:
82
PictureHandling/Form1.Designer.cs
generated
82
PictureHandling/Form1.Designer.cs
generated
@ -46,9 +46,6 @@ namespace PictureHandling
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
|
||||||
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||||
this.btnFileDialog = new System.Windows.Forms.Button();
|
this.btnFileDialog = new System.Windows.Forms.Button();
|
||||||
this.lblPath = new System.Windows.Forms.Label();
|
this.lblPath = new System.Windows.Forms.Label();
|
||||||
@ -61,6 +58,10 @@ namespace PictureHandling
|
|||||||
this.btnReOrganize = new System.Windows.Forms.Button();
|
this.btnReOrganize = new System.Windows.Forms.Button();
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
this.txtRootDir = new System.Windows.Forms.TextBox();
|
this.txtRootDir = new System.Windows.Forms.TextBox();
|
||||||
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.lblGroundPath = new System.Windows.Forms.Label();
|
||||||
|
this.label6 = new System.Windows.Forms.Label();
|
||||||
|
this.lblFinalPath = new System.Windows.Forms.Label();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -75,31 +76,35 @@ namespace PictureHandling
|
|||||||
//
|
//
|
||||||
// lblPath
|
// lblPath
|
||||||
//
|
//
|
||||||
this.lblPath.Location = new System.Drawing.Point(160, 16);
|
this.lblPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.lblPath.Location = new System.Drawing.Point(167, 16);
|
||||||
this.lblPath.Name = "lblPath";
|
this.lblPath.Name = "lblPath";
|
||||||
this.lblPath.Size = new System.Drawing.Size(528, 23);
|
this.lblPath.Size = new System.Drawing.Size(521, 17);
|
||||||
this.lblPath.TabIndex = 1;
|
this.lblPath.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// label2
|
// label2
|
||||||
//
|
//
|
||||||
this.label2.Location = new System.Drawing.Point(104, 16);
|
this.label2.Location = new System.Drawing.Point(104, 16);
|
||||||
this.label2.Name = "label2";
|
this.label2.Name = "label2";
|
||||||
this.label2.Size = new System.Drawing.Size(56, 23);
|
this.label2.Size = new System.Drawing.Size(56, 17);
|
||||||
this.label2.TabIndex = 2;
|
this.label2.TabIndex = 2;
|
||||||
this.label2.Text = "Path";
|
this.label2.Text = "Path";
|
||||||
//
|
//
|
||||||
// lblFileName
|
// lblFileName
|
||||||
//
|
//
|
||||||
this.lblFileName.Location = new System.Drawing.Point(160, 48);
|
this.lblFileName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.lblFileName.Location = new System.Drawing.Point(167, 33);
|
||||||
this.lblFileName.Name = "lblFileName";
|
this.lblFileName.Name = "lblFileName";
|
||||||
this.lblFileName.Size = new System.Drawing.Size(248, 23);
|
this.lblFileName.Size = new System.Drawing.Size(210, 15);
|
||||||
this.lblFileName.TabIndex = 3;
|
this.lblFileName.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
this.label1.Location = new System.Drawing.Point(104, 48);
|
this.label1.Location = new System.Drawing.Point(104, 33);
|
||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(56, 23);
|
this.label1.Size = new System.Drawing.Size(56, 15);
|
||||||
this.label1.TabIndex = 4;
|
this.label1.TabIndex = 4;
|
||||||
this.label1.Text = "Filnamn";
|
this.label1.Text = "Filnamn";
|
||||||
//
|
//
|
||||||
@ -117,6 +122,7 @@ namespace PictureHandling
|
|||||||
//
|
//
|
||||||
// lstPicFiles
|
// lstPicFiles
|
||||||
//
|
//
|
||||||
|
this.lstPicFiles.FormattingEnabled = true;
|
||||||
this.lstPicFiles.Location = new System.Drawing.Point(16, 88);
|
this.lstPicFiles.Location = new System.Drawing.Point(16, 88);
|
||||||
this.lstPicFiles.Name = "lstPicFiles";
|
this.lstPicFiles.Name = "lstPicFiles";
|
||||||
this.lstPicFiles.Size = new System.Drawing.Size(128, 394);
|
this.lstPicFiles.Size = new System.Drawing.Size(128, 394);
|
||||||
@ -125,9 +131,10 @@ namespace PictureHandling
|
|||||||
//
|
//
|
||||||
// lblCreated
|
// lblCreated
|
||||||
//
|
//
|
||||||
this.lblCreated.Location = new System.Drawing.Point(424, 48);
|
this.lblCreated.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.lblCreated.Location = new System.Drawing.Point(355, 30);
|
||||||
this.lblCreated.Name = "lblCreated";
|
this.lblCreated.Name = "lblCreated";
|
||||||
this.lblCreated.Size = new System.Drawing.Size(264, 23);
|
this.lblCreated.Size = new System.Drawing.Size(333, 18);
|
||||||
this.lblCreated.TabIndex = 7;
|
this.lblCreated.TabIndex = 7;
|
||||||
this.lblCreated.Text = "Skapad: ";
|
this.lblCreated.Text = "Skapad: ";
|
||||||
//
|
//
|
||||||
@ -158,10 +165,49 @@ namespace PictureHandling
|
|||||||
this.txtRootDir.Text = "\\\\TFOASUS\\OurPictures";
|
this.txtRootDir.Text = "\\\\TFOASUS\\OurPictures";
|
||||||
this.txtRootDir.TextChanged += new System.EventHandler(this.txtRootDir_TextChanged);
|
this.txtRootDir.TextChanged += new System.EventHandler(this.txtRootDir_TextChanged);
|
||||||
//
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
this.label4.Location = new System.Drawing.Point(104, 48);
|
||||||
|
this.label4.Name = "label4";
|
||||||
|
this.label4.Size = new System.Drawing.Size(64, 15);
|
||||||
|
this.label4.TabIndex = 12;
|
||||||
|
this.label4.Text = "GrundPath";
|
||||||
|
//
|
||||||
|
// lblGroundPath
|
||||||
|
//
|
||||||
|
this.lblGroundPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||||
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.lblGroundPath.Location = new System.Drawing.Point(166, 48);
|
||||||
|
this.lblGroundPath.Name = "lblGroundPath";
|
||||||
|
this.lblGroundPath.Size = new System.Drawing.Size(174, 15);
|
||||||
|
this.lblGroundPath.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.label6.Location = new System.Drawing.Point(355, 48);
|
||||||
|
this.label6.Name = "label6";
|
||||||
|
this.label6.Size = new System.Drawing.Size(51, 15);
|
||||||
|
this.label6.TabIndex = 14;
|
||||||
|
this.label6.Text = "SlutPath";
|
||||||
|
//
|
||||||
|
// lblFinalPath
|
||||||
|
//
|
||||||
|
this.lblFinalPath.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.lblFinalPath.Location = new System.Drawing.Point(412, 48);
|
||||||
|
this.lblFinalPath.Name = "lblFinalPath";
|
||||||
|
this.lblFinalPath.Size = new System.Drawing.Size(276, 15);
|
||||||
|
this.lblFinalPath.TabIndex = 13;
|
||||||
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(704, 590);
|
this.ClientSize = new System.Drawing.Size(704, 590);
|
||||||
|
this.Controls.Add(this.label6);
|
||||||
|
this.Controls.Add(this.lblFinalPath);
|
||||||
|
this.Controls.Add(this.label4);
|
||||||
|
this.Controls.Add(this.lblGroundPath);
|
||||||
this.Controls.Add(this.txtRootDir);
|
this.Controls.Add(this.txtRootDir);
|
||||||
this.Controls.Add(this.label3);
|
this.Controls.Add(this.label3);
|
||||||
this.Controls.Add(this.btnReOrganize);
|
this.Controls.Add(this.btnReOrganize);
|
||||||
@ -173,14 +219,22 @@ namespace PictureHandling
|
|||||||
this.Controls.Add(this.label2);
|
this.Controls.Add(this.label2);
|
||||||
this.Controls.Add(this.lblPath);
|
this.Controls.Add(this.lblPath);
|
||||||
this.Controls.Add(this.btnFileDialog);
|
this.Controls.Add(this.btnFileDialog);
|
||||||
//this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
|
||||||
this.Name = "Form1";
|
this.Name = "Form1";
|
||||||
this.Text = "Form1";
|
this.Text = "Form1";
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private System.Windows.Forms.Label label4;
|
||||||
|
private System.Windows.Forms.Label lblGroundPath;
|
||||||
|
private System.Windows.Forms.Label label6;
|
||||||
|
private System.Windows.Forms.Label lblFinalPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Specialized;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.AccessControl;
|
using System.Security.AccessControl;
|
||||||
@ -77,94 +79,49 @@ namespace PictureHandling
|
|||||||
|
|
||||||
private void btnReOrganize_Click(object sender, EventArgs e)
|
private void btnReOrganize_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
pictureList.Clear();
|
ReorganizeImages();
|
||||||
bool error_upd = false;
|
}
|
||||||
//if (txtRootDir.Text.Trim().Substring(txtRootDir.Text.Trim().Length - 1) != @"\")
|
|
||||||
// txtRootDir.Text = txtRootDir.Text.Trim() + @"\";
|
|
||||||
|
|
||||||
txtRootDir.Text = txtRootDir.Text.Trim().EndsWith(@"\") ? txtRootDir.Text.Trim() : txtRootDir.Text.Trim() + @"\";
|
|
||||||
|
|
||||||
|
private void ReorganizeImages()
|
||||||
|
{
|
||||||
DirectoryInfo di = new DirectoryInfo(txtRootDir.Text);
|
DirectoryInfo di = new DirectoryInfo(txtRootDir.Text);
|
||||||
|
|
||||||
if (!di.Exists) di.Create();
|
if (!di.Exists) di.Create();
|
||||||
// om den nya rotkatalogen saknas skapa den
|
// om den nya rotkatalogen saknas skapa den
|
||||||
|
|
||||||
Deleting = true;
|
foreach (var localPic in pictureList)
|
||||||
// listboxen påverkas inte av denna
|
|
||||||
|
|
||||||
pictureBox1.Image = null;
|
|
||||||
pictureBox1.Refresh();
|
|
||||||
for (int i = lstPicFiles.Items.Count - 1; i > -1; i--)
|
|
||||||
{
|
{
|
||||||
var bufPicture = new LocalPicture();
|
if (localPic.CreatedDateChanged)
|
||||||
|
|
||||||
//string lFileName = lstPicFiles.Items[i].ToString().Trim();
|
|
||||||
bufPicture.PictureFileName= lstPicFiles.Items[i].ToString().Trim();
|
|
||||||
|
|
||||||
//string fName = lblPath.Text.Trim() + lFileName;
|
|
||||||
bufPicture.InitialPath = lblPath.Text.Trim();
|
|
||||||
|
|
||||||
lblFileName.Text = bufPicture.PictureFullPath;
|
|
||||||
|
|
||||||
//Image actIm = Image.FromFile(fName, true);
|
|
||||||
bufPicture.AktImage = Image.FromFile(bufPicture.PictureFullPath);
|
|
||||||
|
|
||||||
//int w = actIm.Width;
|
|
||||||
//int h = actIm.Height;
|
|
||||||
bufPicture.AktImWidth = bufPicture.AktImage.Width;
|
|
||||||
bufPicture.AktImHeight = bufPicture.AktImage.Height;
|
|
||||||
|
|
||||||
|
|
||||||
int pw = pictureBox1.Width;
|
|
||||||
int ph = pictureBox1.Height;
|
|
||||||
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;
|
|
||||||
Bitmap to_bm = new Bitmap((Image)bufPicture.AktImage.Clone(), bufPicture.AktImWidth * ph / bufPicture.AktImHeight, ph);
|
|
||||||
pictureBox1.Image = to_bm;
|
|
||||||
string td = TakenDate(bufPicture.AktImage);
|
|
||||||
|
|
||||||
//actIm.Dispose();
|
|
||||||
if (td.Trim() != "")
|
|
||||||
{
|
{
|
||||||
lblCreated.Text = "Skapad: " + td;
|
PropertyItem prp;
|
||||||
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
|
try
|
||||||
{
|
{
|
||||||
lstPicFiles.BeginUpdate();
|
prp = localPic.AktImage.GetPropertyItem(306);
|
||||||
}
|
}
|
||||||
catch
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
error_upd = true;
|
if (ex.Message == "Det går inte att hitta egenskapen.")
|
||||||
|
{
|
||||||
|
prp = localPic.AktImage.PropertyItems[0];
|
||||||
|
prp.Id = 306;
|
||||||
|
prp.Len = localPic.CreatedDate.Length;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (error_upd);
|
prp.Value = System.Text.ASCIIEncoding.ASCII.GetBytes(localPic.CreatedDate);
|
||||||
lstPicFiles.Items.RemoveAt(i);
|
localPic.AktImage.SetPropertyItem(prp);
|
||||||
lstPicFiles.EndUpdate();
|
|
||||||
lstPicFiles.Refresh();
|
|
||||||
lblCreated.Refresh();
|
|
||||||
lblFileName.Refresh();
|
|
||||||
pictureBox1.Refresh();
|
|
||||||
this.Refresh();
|
|
||||||
}
|
}
|
||||||
|
DirectoryInfo dis = new DirectoryInfo(localPic.AarManDir);
|
||||||
|
if (!dis.Exists) dis.Create();
|
||||||
|
DirectoryInfo diss = new DirectoryInfo(localPic.AarManDayDir);
|
||||||
|
if (!diss.Exists) diss.Create();
|
||||||
|
|
||||||
|
localPic.AktImage.Save(localPic.ImageNewFullpath);
|
||||||
}
|
}
|
||||||
Deleting = false;
|
|
||||||
lblCreated.Text = "";
|
|
||||||
lblFileName.Text = "";
|
|
||||||
lblPath.Text = "";
|
|
||||||
btnReOrganize.Enabled = false;
|
btnReOrganize.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,19 +129,20 @@ namespace PictureHandling
|
|||||||
{
|
{
|
||||||
if (!Deleting)
|
if (!Deleting)
|
||||||
{
|
{
|
||||||
string fName = ((ListBox)sender).SelectedItem.ToString();
|
string fName = ((ListBox)sender).SelectedValue.ToString();
|
||||||
|
var lp = ((ListBox)sender).SelectedItem;
|
||||||
lblFileName.Text = fName;
|
lblFileName.Text = fName;
|
||||||
Image actPic = Image.FromFile(lblPath.Text + fName, true);
|
|
||||||
lblCreated.Text = "Skapad: " + TakenDate(actPic);
|
lblCreated.Text = "Skapad: " + ((LocalPicture)lp).CreatedDate;
|
||||||
int w = actPic.Width;
|
lblGroundPath.Text = ((LocalPicture)lp).AarManDir;
|
||||||
int h = actPic.Height;
|
lblFinalPath.Text = ((LocalPicture)lp).AarManDayDir;
|
||||||
|
int w = ((LocalPicture)lp).AktImWidth;
|
||||||
|
int h = ((LocalPicture)lp).AktImHeight;
|
||||||
int pw = pictureBox1.Width;
|
int pw = pictureBox1.Width;
|
||||||
int ph = pictureBox1.Height;
|
int ph = pictureBox1.Height;
|
||||||
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;
|
pictureBox1.SizeMode = PictureBoxSizeMode.Normal;
|
||||||
Bitmap to_bm = new Bitmap((Image)actPic.Clone(), w * ph / h, ph);
|
Bitmap to_bm = new Bitmap((Image)((LocalPicture)lp).AktImage.Clone(), w * ph / h, ph);
|
||||||
pictureBox1.Image = to_bm;
|
pictureBox1.Image = to_bm;
|
||||||
actPic = null;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,17 +195,94 @@ namespace PictureHandling
|
|||||||
private void listLocalFiles()
|
private void listLocalFiles()
|
||||||
{
|
{
|
||||||
DirectoryInfo di = new DirectoryInfo(lblPath.Text);
|
DirectoryInfo di = new DirectoryInfo(lblPath.Text);
|
||||||
List<FileInfo> files = new List<FileInfo>();
|
var files = new List<FileInfo>();
|
||||||
files.AddRange( di.GetFiles("*.jpg"));
|
files.AddRange(di.GetFiles("*.jpg"));
|
||||||
files.AddRange(di.GetFiles("*.jpeg"));
|
files.AddRange(di.GetFiles("*.jpeg"));
|
||||||
//
|
//
|
||||||
lstPicFiles.Items.Clear();
|
Deleting = true;
|
||||||
foreach (var item in files)
|
lstPicFiles.DataSource = null;
|
||||||
{
|
pictureList = listBoxDataSource(files);
|
||||||
lstPicFiles.Items.Add(item.Name);
|
lstPicFiles.DataSource = pictureList;
|
||||||
}
|
lstPicFiles.DisplayMember = "PictureFileName";
|
||||||
|
lstPicFiles.ValueMember = "PictureFullPath";
|
||||||
|
Deleting = false;
|
||||||
|
|
||||||
btnReOrganize.Enabled = true;
|
btnReOrganize.Enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<LocalPicture> listBoxDataSource(List<FileInfo> fileInfos)
|
||||||
|
{
|
||||||
|
|
||||||
|
var outPut = new List<LocalPicture>();
|
||||||
|
|
||||||
|
txtRootDir.Text = txtRootDir.Text.Trim().EndsWith(@"\") ? txtRootDir.Text.Trim() : txtRootDir.Text.Trim() + @"\";
|
||||||
|
|
||||||
|
foreach (var fi in fileInfos)
|
||||||
|
{
|
||||||
|
var bufPicture = new LocalPicture();
|
||||||
|
|
||||||
|
bufPicture.RootPosition = txtRootDir.Text;
|
||||||
|
|
||||||
|
bufPicture.PictureFileName = fi.Name;
|
||||||
|
|
||||||
|
bufPicture.InitialPath = fi.DirectoryName;
|
||||||
|
|
||||||
|
bufPicture.AktImage = Image.FromFile(bufPicture.PictureFullPath);
|
||||||
|
|
||||||
|
bufPicture.AktImWidth = bufPicture.AktImage.Width;
|
||||||
|
bufPicture.AktImHeight = bufPicture.AktImage.Height;
|
||||||
|
|
||||||
|
bufPicture.CreatedDate = TakenDate(bufPicture.AktImage);
|
||||||
|
|
||||||
|
outPut.Add(bufPicture);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FillupDateGaps(outPut);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<LocalPicture> FillupDateGaps(List<LocalPicture> inPut)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"FillupDateGaps input has {inPut.Count} files.");
|
||||||
|
var picReg = new SortedList<string, LocalPicture>();
|
||||||
|
foreach (var pict in inPut)
|
||||||
|
{
|
||||||
|
picReg.Add(pict.PictureFileName, pict);
|
||||||
|
}
|
||||||
|
var tmpPicture = new LocalPicture();
|
||||||
|
tmpPicture.CreatedDate = "";
|
||||||
|
Stack<string> stack = new Stack<string>();
|
||||||
|
var outPut = new List<LocalPicture>();
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, LocalPicture> lPic in picReg)
|
||||||
|
{
|
||||||
|
if (lPic.Value.CreatedDate == "")
|
||||||
|
{
|
||||||
|
if (tmpPicture.CreatedDate != "")
|
||||||
|
{
|
||||||
|
lPic.Value.CreatedDate = tmpPicture.CreatedDate;
|
||||||
|
lPic.Value.CreatedDateChanged = true;
|
||||||
|
outPut.Add(lPic.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stack.Push(lPic.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmpPicture = lPic.Value;
|
||||||
|
while (stack.Count > 0)
|
||||||
|
{
|
||||||
|
var picRegKey = stack.Pop();
|
||||||
|
picReg[picRegKey].CreatedDate = tmpPicture.CreatedDate;
|
||||||
|
picReg[picRegKey].CreatedDateChanged = true;
|
||||||
|
outPut.Add(picReg[picRegKey]);
|
||||||
|
}
|
||||||
|
outPut.Add(lPic.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Debug.WriteLine($"FillupDateGaps output has {outPut.Count} files.");
|
||||||
|
return outPut;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
123
PictureHandling/Form1.resx
Normal file
123
PictureHandling/Form1.resx
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
@ -10,16 +10,57 @@ namespace PictureHandling
|
|||||||
{
|
{
|
||||||
public class LocalPicture
|
public class LocalPicture
|
||||||
{
|
{
|
||||||
|
|
||||||
public string PictureFileName { get; set; }
|
public string PictureFileName { get; set; }
|
||||||
public string InitialPath { get; set; }
|
public string InitialPath { get; set; }
|
||||||
public string PictureFullPath {
|
public string PictureFullPath
|
||||||
get {
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
return Path.Combine(InitialPath, PictureFileName);
|
return Path.Combine(InitialPath, PictureFileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public Image AktImage { get; set; }
|
public Image AktImage { get; set; }
|
||||||
public int AktImWidth { get; set; }
|
public int AktImWidth { get; set; }
|
||||||
public int AktImHeight { get; set; }
|
public int AktImHeight { get; set; }
|
||||||
|
public string CreatedDate { get; set; }
|
||||||
|
public bool CreatedDateChanged { get; set; } = false;
|
||||||
|
public string AarManDir
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(CreatedDate)) return RootPosition;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DateTime dttd = DateTime.Parse(CreatedDate.Substring(0, 10).Replace(":", "-"));
|
||||||
|
string subDir = dttd.Year.ToString("0000") + "-" + dttd.Month.ToString("00") + @"\";
|
||||||
|
return Path.Combine(RootPosition + subDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string AarManDayDir
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(CreatedDate)) return RootPosition;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DateTime dttd = DateTime.Parse(CreatedDate.Substring(0, 10).Replace(":", "-"));
|
||||||
|
string subDir = dttd.Year.ToString("0000") + "_" + dttd.Month.ToString("00") + "_" + dttd.Day.ToString("00") + @"\";
|
||||||
|
return Path.Combine(AarManDir + subDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ImageNewFullpath
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Path.Combine(AarManDayDir + PictureFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string RootPosition { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,6 +35,11 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Collections.Specialized, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Collections.Specialized.4.3.0\lib\net46\System.Collections.Specialized.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Xml.Linq" />
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
@ -56,6 +61,9 @@
|
|||||||
<Compile Include="LocalPicture.cs" />
|
<Compile Include="LocalPicture.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<EmbeddedResource Include="Form1.resx">
|
||||||
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
@ -65,6 +73,7 @@
|
|||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<None Include="packages.config" />
|
||||||
<None Include="Properties\Settings.settings">
|
<None Include="Properties\Settings.settings">
|
||||||
<Generator>SettingsSingleFileGenerator</Generator>
|
<Generator>SettingsSingleFileGenerator</Generator>
|
||||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||||
|
|||||||
4
PictureHandling/packages.config
Normal file
4
PictureHandling/packages.config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="System.Collections.Specialized" version="4.3.0" targetFramework="net472" />
|
||||||
|
</packages>
|
||||||
Reference in New Issue
Block a user