Programmet fungerar nu både via select av enskilda bilder (gt1) och alla jpg/jpeg

This commit is contained in:
2020-07-25 10:24:53 +02:00
parent 6b27788721
commit f06e73c5f1
2 changed files with 202 additions and 111 deletions

View File

@ -7,19 +7,19 @@ namespace PictureHandling
private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.Button btnFileDialog; private System.Windows.Forms.Button btnFileDialog;
private System.Windows.Forms.Label lblPath; private System.Windows.Forms.Label lblPath;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label HPath;
private System.Windows.Forms.Label lblFileName; private System.Windows.Forms.Label lblFileName;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label HFilnamn;
private System.Windows.Forms.PictureBox pictureBox1; private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.ListBox lstPicFiles; private System.Windows.Forms.ListBox lstPicFiles;
private System.Windows.Forms.Label lblCreated; private System.Windows.Forms.Label HSkapad;
private System.Windows.Forms.Button btnReOrganize; private System.Windows.Forms.Button btnReOrganize;
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
//private System.ComponentModel.Container components = null; //private System.ComponentModel.Container components = null;
private System.Windows.Forms.Label label3; private System.Windows.Forms.Label HNyRotKatalog;
private System.Windows.Forms.TextBox txtRootDir; private System.Windows.Forms.TextBox txtRootDir;
private bool Deleting = false; private bool Deleting = false;
@ -49,25 +49,28 @@ namespace PictureHandling
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();
this.label2 = new System.Windows.Forms.Label(); this.HPath = new System.Windows.Forms.Label();
this.lblFileName = new System.Windows.Forms.Label(); this.lblFileName = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label(); this.HFilnamn = new System.Windows.Forms.Label();
this.pictureBox1 = new System.Windows.Forms.PictureBox(); this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.lstPicFiles = new System.Windows.Forms.ListBox(); this.lstPicFiles = new System.Windows.Forms.ListBox();
this.lblCreated = new System.Windows.Forms.Label(); this.HSkapad = new System.Windows.Forms.Label();
this.btnReOrganize = new System.Windows.Forms.Button(); this.btnReOrganize = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label(); this.HNyRotKatalog = 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.HGrundpath = new System.Windows.Forms.Label();
this.lblGroundPath = new System.Windows.Forms.Label(); this.lblGroundPath = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label(); this.HSlutpath = new System.Windows.Forms.Label();
this.lblFinalPath = new System.Windows.Forms.Label(); this.lblFinalPath = new System.Windows.Forms.Label();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.lblCreated = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.tableLayoutPanel1.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnFileDialog // btnFileDialog
// //
this.btnFileDialog.Location = new System.Drawing.Point(16, 56); this.btnFileDialog.Location = new System.Drawing.Point(35, 92);
this.btnFileDialog.Name = "btnFileDialog"; this.btnFileDialog.Name = "btnFileDialog";
this.btnFileDialog.Size = new System.Drawing.Size(75, 23); this.btnFileDialog.Size = new System.Drawing.Size(75, 23);
this.btnFileDialog.TabIndex = 0; this.btnFileDialog.TabIndex = 0;
@ -76,46 +79,49 @@ namespace PictureHandling
// //
// lblPath // lblPath
// //
this.lblPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.lblPath.BackColor = System.Drawing.Color.Transparent;
| System.Windows.Forms.AnchorStyles.Right))); this.lblPath.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblPath.Location = new System.Drawing.Point(167, 16); this.lblPath.Location = new System.Drawing.Point(75, 16);
this.lblPath.Name = "lblPath"; this.lblPath.Name = "lblPath";
this.lblPath.Size = new System.Drawing.Size(521, 17); this.lblPath.Size = new System.Drawing.Size(279, 16);
this.lblPath.TabIndex = 1; this.lblPath.TabIndex = 1;
// //
// label2 // HPath
// //
this.label2.Location = new System.Drawing.Point(104, 16); this.HPath.Dock = System.Windows.Forms.DockStyle.Fill;
this.label2.Name = "label2"; this.HPath.Location = new System.Drawing.Point(3, 16);
this.label2.Size = new System.Drawing.Size(56, 17); this.HPath.Name = "HPath";
this.label2.TabIndex = 2; this.HPath.Size = new System.Drawing.Size(66, 16);
this.label2.Text = "Path"; this.HPath.TabIndex = 2;
this.HPath.Text = "Path";
// //
// lblFileName // lblFileName
// //
this.lblFileName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.lblFileName.BackColor = System.Drawing.Color.Transparent;
| System.Windows.Forms.AnchorStyles.Right))); this.tableLayoutPanel1.SetColumnSpan(this.lblFileName, 3);
this.lblFileName.Location = new System.Drawing.Point(167, 33); this.lblFileName.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblFileName.Location = new System.Drawing.Point(75, 0);
this.lblFileName.Name = "lblFileName"; this.lblFileName.Name = "lblFileName";
this.lblFileName.Size = new System.Drawing.Size(210, 15); this.lblFileName.Size = new System.Drawing.Size(590, 16);
this.lblFileName.TabIndex = 3; this.lblFileName.TabIndex = 3;
// //
// label1 // HFilnamn
// //
this.label1.Location = new System.Drawing.Point(104, 33); this.HFilnamn.Dock = System.Windows.Forms.DockStyle.Fill;
this.label1.Name = "label1"; this.HFilnamn.Location = new System.Drawing.Point(3, 0);
this.label1.Size = new System.Drawing.Size(56, 15); this.HFilnamn.Name = "HFilnamn";
this.label1.TabIndex = 4; this.HFilnamn.Size = new System.Drawing.Size(66, 16);
this.label1.Text = "Filnamn"; this.HFilnamn.TabIndex = 4;
this.HFilnamn.Text = "Filnamn";
// //
// pictureBox1 // pictureBox1
// //
this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.pictureBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.pictureBox1.Location = new System.Drawing.Point(176, 88); this.pictureBox1.Location = new System.Drawing.Point(179, 90);
this.pictureBox1.Name = "pictureBox1"; this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(512, 480); this.pictureBox1.Size = new System.Drawing.Size(524, 509);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
this.pictureBox1.TabIndex = 5; this.pictureBox1.TabIndex = 5;
this.pictureBox1.TabStop = false; this.pictureBox1.TabStop = false;
@ -123,105 +129,135 @@ namespace PictureHandling
// lstPicFiles // lstPicFiles
// //
this.lstPicFiles.FormattingEnabled = true; this.lstPicFiles.FormattingEnabled = true;
this.lstPicFiles.Location = new System.Drawing.Point(16, 88); this.lstPicFiles.Location = new System.Drawing.Point(35, 124);
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);
this.lstPicFiles.TabIndex = 6; this.lstPicFiles.TabIndex = 6;
this.lstPicFiles.SelectedIndexChanged += new System.EventHandler(this.lstPicFiles_SelectedIndexChanged); this.lstPicFiles.SelectedIndexChanged += new System.EventHandler(this.lstPicFiles_SelectedIndexChanged);
// //
// lblCreated // HSkapad
// //
this.lblCreated.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.HSkapad.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblCreated.Location = new System.Drawing.Point(355, 30); this.HSkapad.Location = new System.Drawing.Point(360, 16);
this.lblCreated.Name = "lblCreated"; this.HSkapad.Name = "HSkapad";
this.lblCreated.Size = new System.Drawing.Size(333, 18); this.HSkapad.Size = new System.Drawing.Size(50, 16);
this.lblCreated.TabIndex = 7; this.HSkapad.TabIndex = 7;
this.lblCreated.Text = "Skapad: "; this.HSkapad.Text = "Skapad: ";
// //
// btnReOrganize // btnReOrganize
// //
this.btnReOrganize.Enabled = false; this.btnReOrganize.Enabled = false;
this.btnReOrganize.Location = new System.Drawing.Point(16, 496); this.btnReOrganize.Location = new System.Drawing.Point(35, 532);
this.btnReOrganize.Name = "btnReOrganize"; this.btnReOrganize.Name = "btnReOrganize";
this.btnReOrganize.Size = new System.Drawing.Size(136, 23); this.btnReOrganize.Size = new System.Drawing.Size(136, 23);
this.btnReOrganize.TabIndex = 8; this.btnReOrganize.TabIndex = 8;
this.btnReOrganize.Text = "Reorganisera filer"; this.btnReOrganize.Text = "Reorganisera filer";
this.btnReOrganize.Click += new System.EventHandler(this.btnReOrganize_Click); this.btnReOrganize.Click += new System.EventHandler(this.btnReOrganize_Click);
// //
// label3 // HNyRotKatalog
// //
this.label3.Location = new System.Drawing.Point(16, 528); this.HNyRotKatalog.Location = new System.Drawing.Point(35, 564);
this.label3.Name = "label3"; this.HNyRotKatalog.Name = "HNyRotKatalog";
this.label3.Size = new System.Drawing.Size(128, 16); this.HNyRotKatalog.Size = new System.Drawing.Size(128, 16);
this.label3.TabIndex = 9; this.HNyRotKatalog.TabIndex = 9;
this.label3.Text = "Ny RotKatalog"; this.HNyRotKatalog.Text = "Ny RotKatalog";
// //
// txtRootDir // txtRootDir
// //
this.txtRootDir.Location = new System.Drawing.Point(16, 544); this.txtRootDir.Location = new System.Drawing.Point(35, 580);
this.txtRootDir.Name = "txtRootDir"; this.txtRootDir.Name = "txtRootDir";
this.txtRootDir.Size = new System.Drawing.Size(136, 20); this.txtRootDir.Size = new System.Drawing.Size(136, 20);
this.txtRootDir.TabIndex = 10; this.txtRootDir.TabIndex = 10;
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 // HGrundpath
// //
this.label4.Location = new System.Drawing.Point(104, 48); this.HGrundpath.Dock = System.Windows.Forms.DockStyle.Fill;
this.label4.Name = "label4"; this.HGrundpath.Location = new System.Drawing.Point(3, 32);
this.label4.Size = new System.Drawing.Size(64, 15); this.HGrundpath.Name = "HGrundpath";
this.label4.TabIndex = 12; this.HGrundpath.Size = new System.Drawing.Size(66, 18);
this.label4.Text = "GrundPath"; this.HGrundpath.TabIndex = 12;
this.HGrundpath.Text = "GrundPath";
// //
// lblGroundPath // lblGroundPath
// //
this.lblGroundPath.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) this.lblGroundPath.BackColor = System.Drawing.Color.Transparent;
| System.Windows.Forms.AnchorStyles.Right))); this.lblGroundPath.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblGroundPath.Location = new System.Drawing.Point(166, 48); this.lblGroundPath.Location = new System.Drawing.Point(75, 32);
this.lblGroundPath.Name = "lblGroundPath"; this.lblGroundPath.Name = "lblGroundPath";
this.lblGroundPath.Size = new System.Drawing.Size(174, 15); this.lblGroundPath.Size = new System.Drawing.Size(279, 18);
this.lblGroundPath.TabIndex = 11; this.lblGroundPath.TabIndex = 11;
// //
// label6 // HSlutpath
// //
this.label6.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.HSlutpath.Dock = System.Windows.Forms.DockStyle.Fill;
this.label6.Location = new System.Drawing.Point(355, 48); this.HSlutpath.Location = new System.Drawing.Point(360, 32);
this.label6.Name = "label6"; this.HSlutpath.Name = "HSlutpath";
this.label6.Size = new System.Drawing.Size(51, 15); this.HSlutpath.Size = new System.Drawing.Size(50, 18);
this.label6.TabIndex = 14; this.HSlutpath.TabIndex = 14;
this.label6.Text = "SlutPath"; this.HSlutpath.Text = "SlutPath";
// //
// lblFinalPath // lblFinalPath
// //
this.lblFinalPath.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.lblFinalPath.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblFinalPath.Location = new System.Drawing.Point(412, 48); this.lblFinalPath.Location = new System.Drawing.Point(416, 32);
this.lblFinalPath.Name = "lblFinalPath"; this.lblFinalPath.Name = "lblFinalPath";
this.lblFinalPath.Size = new System.Drawing.Size(276, 15); this.lblFinalPath.Size = new System.Drawing.Size(249, 18);
this.lblFinalPath.TabIndex = 13; this.lblFinalPath.TabIndex = 13;
// //
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 4;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 20.16807F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 79.83193F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 56F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 254F));
this.tableLayoutPanel1.Controls.Add(this.lblCreated, 3, 1);
this.tableLayoutPanel1.Controls.Add(this.HGrundpath, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.HFilnamn, 0, 0);
this.tableLayoutPanel1.Controls.Add(this.HSlutpath, 2, 2);
this.tableLayoutPanel1.Controls.Add(this.HSkapad, 2, 1);
this.tableLayoutPanel1.Controls.Add(this.lblFinalPath, 3, 2);
this.tableLayoutPanel1.Controls.Add(this.lblGroundPath, 1, 2);
this.tableLayoutPanel1.Controls.Add(this.lblPath, 1, 1);
this.tableLayoutPanel1.Controls.Add(this.HPath, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.lblFileName, 1, 0);
this.tableLayoutPanel1.Location = new System.Drawing.Point(35, 12);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 3;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33.33333F));
this.tableLayoutPanel1.Size = new System.Drawing.Size(668, 50);
this.tableLayoutPanel1.TabIndex = 15;
//
// lblCreated
//
this.lblCreated.AutoSize = true;
this.lblCreated.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblCreated.Location = new System.Drawing.Point(416, 16);
this.lblCreated.Name = "lblCreated";
this.lblCreated.Size = new System.Drawing.Size(249, 16);
this.lblCreated.TabIndex = 16;
//
// Form1 // Form1
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(704, 590); this.ClientSize = new System.Drawing.Size(716, 611);
this.Controls.Add(this.label6); this.Controls.Add(this.tableLayoutPanel1);
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.HNyRotKatalog);
this.Controls.Add(this.btnReOrganize); this.Controls.Add(this.btnReOrganize);
this.Controls.Add(this.lblCreated);
this.Controls.Add(this.lstPicFiles); this.Controls.Add(this.lstPicFiles);
this.Controls.Add(this.pictureBox1); this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label1);
this.Controls.Add(this.lblFileName);
this.Controls.Add(this.label2);
this.Controls.Add(this.lblPath);
this.Controls.Add(this.btnFileDialog); this.Controls.Add(this.btnFileDialog);
this.Name = "Form1"; this.Name = "Form1";
this.Text = "Form1"; this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -231,10 +267,12 @@ namespace PictureHandling
#endregion #endregion
private System.Windows.Forms.Label label4; private System.Windows.Forms.Label HGrundpath;
private System.Windows.Forms.Label lblGroundPath; private System.Windows.Forms.Label lblGroundPath;
private System.Windows.Forms.Label label6; private System.Windows.Forms.Label HSlutpath;
private System.Windows.Forms.Label lblFinalPath; private System.Windows.Forms.Label lblFinalPath;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label lblCreated;
} }
} }

View File

@ -20,6 +20,8 @@ namespace PictureHandling
{ {
public RegistryKey CU { get; set; } public RegistryKey CU { get; set; }
public List<LocalPicture> pictureList = new List<LocalPicture>(); public List<LocalPicture> pictureList = new List<LocalPicture>();
public List<string> DeleteList { get; set; } = new List<string>();
private bool noRegReact = false;
public Form1() public Form1()
{ {
InitializeComponent(); InitializeComponent();
@ -47,6 +49,7 @@ namespace PictureHandling
private void txtRootDir_TextChanged(object sender, EventArgs e) private void txtRootDir_TextChanged(object sender, EventArgs e)
{ {
if (noRegReact) return;
try try
{ {
RegistryKey IdoIt4u = CU.OpenSubKey(@"SOFTWARE\IdoIt4u", true); RegistryKey IdoIt4u = CU.OpenSubKey(@"SOFTWARE\IdoIt4u", true);
@ -67,7 +70,14 @@ namespace PictureHandling
} }
else else
{ {
noRegReact = true;
txtRootDir.Text = txtRootDir.Text.Trim().EndsWith(@"\") ? txtRootDir.Text.Trim() : txtRootDir.Text.Trim() + @"\";
noRegReact = false;
PictureHandling.SetValue(@"RootMap", txtRootDir.Text); PictureHandling.SetValue(@"RootMap", txtRootDir.Text);
if (pictureList.Count > 0 && txtRootDir.Text != pictureList[0].RootPosition)
{
btnReOrganize.Enabled = true;
}
} }
} }
catch (Exception ex) catch (Exception ex)
@ -80,6 +90,17 @@ namespace PictureHandling
private void btnReOrganize_Click(object sender, EventArgs e) private void btnReOrganize_Click(object sender, EventArgs e)
{ {
ReorganizeImages(); ReorganizeImages();
pictureList.Clear();
Deleting = true;
lstPicFiles.DataSource = null;
lstPicFiles.Refresh();
pictureBox1.Image = null;
pictureBox1.Refresh();
foreach (var fname in DeleteList)
{
File.Delete(fname);
}
Deleting = false;
} }
private void ReorganizeImages() private void ReorganizeImages()
@ -100,7 +121,7 @@ namespace PictureHandling
} }
catch (Exception ex) catch (Exception ex)
{ {
if (ex.Message == "Det går inte att hitta egenskapen.") if (ex.HResult == -2147024809)
{ {
prp = localPic.AktImage.PropertyItems[0]; prp = localPic.AktImage.PropertyItems[0];
prp.Id = 306; prp.Id = 306;
@ -114,15 +135,25 @@ namespace PictureHandling
prp.Value = System.Text.ASCIIEncoding.ASCII.GetBytes(localPic.CreatedDate); prp.Value = System.Text.ASCIIEncoding.ASCII.GetBytes(localPic.CreatedDate);
localPic.AktImage.SetPropertyItem(prp); localPic.AktImage.SetPropertyItem(prp);
} }
if (localPic.RootPosition != txtRootDir.Text)
{
localPic.RootPosition = txtRootDir.Text;
}
DirectoryInfo dis = new DirectoryInfo(localPic.AarManDir); DirectoryInfo dis = new DirectoryInfo(localPic.AarManDir);
if (!dis.Exists) dis.Create(); if (!dis.Exists) dis.Create();
DirectoryInfo diss = new DirectoryInfo(localPic.AarManDayDir); DirectoryInfo diss = new DirectoryInfo(localPic.AarManDayDir);
if (!diss.Exists) diss.Create(); if (!diss.Exists) diss.Create();
localPic.AktImage.Save(localPic.ImageNewFullpath); localPic.AktImage.Save(localPic.ImageNewFullpath);
localPic.AktImage.Dispose();
DeleteList.Add(localPic.PictureFullPath);
} }
btnReOrganize.Enabled = false; btnReOrganize.Enabled = false;
} }
private void lstPicFiles_SelectedIndexChanged(object sender, EventArgs e) private void lstPicFiles_SelectedIndexChanged(object sender, EventArgs e)
@ -131,9 +162,11 @@ namespace PictureHandling
{ {
string fName = ((ListBox)sender).SelectedValue.ToString(); string fName = ((ListBox)sender).SelectedValue.ToString();
var lp = ((ListBox)sender).SelectedItem; var lp = ((ListBox)sender).SelectedItem;
//var lp = lstPicFiles.SelectedValue;
lblFileName.Text = fName; lblFileName.Text = fName;
lblCreated.Text = "Skapad: " + ((LocalPicture)lp).CreatedDate; lblCreated.Text = ((LocalPicture)lp).CreatedDate;
lblGroundPath.Text = ((LocalPicture)lp).AarManDir; lblGroundPath.Text = ((LocalPicture)lp).AarManDir;
lblFinalPath.Text = ((LocalPicture)lp).AarManDayDir; lblFinalPath.Text = ((LocalPicture)lp).AarManDayDir;
int w = ((LocalPicture)lp).AktImWidth; int w = ((LocalPicture)lp).AktImWidth;
@ -141,8 +174,12 @@ namespace PictureHandling
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)((LocalPicture)lp).AktImage.Clone(), w * ph / h, ph);
pictureBox1.Image = to_bm; using (var bmpTmp = new Bitmap(((LocalPicture)lp).PictureFullPath))
{
pictureBox1.Image = new Bitmap(bmpTmp, w * ph / h,ph);
}
} }
} }
@ -159,7 +196,6 @@ namespace PictureHandling
} }
} }
} }
//actPic.Dispose();
return sPropDatTaken; return sPropDatTaken;
} }
@ -170,8 +206,20 @@ namespace PictureHandling
openFileDialog1.Filter = "Picture files (*.jpg)|*.jpg;*.jpeg|All files (*.*)|*.*"; openFileDialog1.Filter = "Picture files (*.jpg)|*.jpg;*.jpeg|All files (*.*)|*.*";
openFileDialog1.FilterIndex = 1; openFileDialog1.FilterIndex = 1;
openFileDialog1.RestoreDirectory = true; openFileDialog1.RestoreDirectory = true;
openFileDialog1.Multiselect = true;
openFileDialog1.ShowDialog(); openFileDialog1.ShowDialog();
openFileDialog1.Multiselect = false; var fnames = openFileDialog1.FileNames;
if (fnames.Length > 1)
{
var outPut = new List<FileInfo>();
foreach (var fname in fnames)
{
outPut.Add(new FileInfo(fname));
}
listLocalFiles(outPut);
}
else
{
string fName = openFileDialog1.FileName; string fName = openFileDialog1.FileName;
if (fName.Trim() != "") if (fName.Trim() != "")
{ {
@ -191,13 +239,17 @@ namespace PictureHandling
} }
} }
}
private void listLocalFiles() private void listLocalFiles(List<FileInfo> files = null)
{
if (files == null)
{ {
DirectoryInfo di = new DirectoryInfo(lblPath.Text); DirectoryInfo di = new DirectoryInfo(lblPath.Text);
var files = new List<FileInfo>(); files = new List<FileInfo>();
files.AddRange(di.GetFiles("*.jpg")); files.AddRange(di.GetFiles("*.jpg"));
files.AddRange(di.GetFiles("*.jpeg")); files.AddRange(di.GetFiles("*.jpeg"));
}
// //
Deleting = true; Deleting = true;
lstPicFiles.DataSource = null; lstPicFiles.DataSource = null;
@ -206,16 +258,17 @@ namespace PictureHandling
lstPicFiles.DisplayMember = "PictureFileName"; lstPicFiles.DisplayMember = "PictureFileName";
lstPicFiles.ValueMember = "PictureFullPath"; lstPicFiles.ValueMember = "PictureFullPath";
Deleting = false; Deleting = false;
files.Clear();
files = null;
btnReOrganize.Enabled = true; btnReOrganize.Enabled = true;
} }
public List<LocalPicture> listBoxDataSource(List<FileInfo> fileInfos) public List<LocalPicture> listBoxDataSource(List<FileInfo> fileInfos)
{ {
Cursor.Current = Cursors.WaitCursor;
var outPut = new List<LocalPicture>(); var outPut = new List<LocalPicture>();
txtRootDir.Text = txtRootDir.Text.Trim().EndsWith(@"\") ? txtRootDir.Text.Trim() : txtRootDir.Text.Trim() + @"\";
foreach (var fi in fileInfos) foreach (var fi in fileInfos)
{ {
@ -237,12 +290,13 @@ namespace PictureHandling
outPut.Add(bufPicture); outPut.Add(bufPicture);
} }
Cursor.Current = Cursors.Default;
return FillupDateGaps(outPut); return FillupDateGaps(outPut);
} }
private List<LocalPicture> FillupDateGaps(List<LocalPicture> inPut) private List<LocalPicture> FillupDateGaps(List<LocalPicture> inPut)
{ {
Debug.WriteLine($"FillupDateGaps input has {inPut.Count} files.");
var picReg = new SortedList<string, LocalPicture>(); var picReg = new SortedList<string, LocalPicture>();
foreach (var pict in inPut) foreach (var pict in inPut)
{ {
@ -281,7 +335,6 @@ namespace PictureHandling
outPut.Add(lPic.Value); outPut.Add(lPic.Value);
} }
} }
Debug.WriteLine($"FillupDateGaps output has {outPut.Count} files.");
return outPut; return outPut;
} }
} }