From a7b501dac8aec6c2a024eb30008d95a4edaeff5f Mon Sep 17 00:00:00 2001 From: Manuel Kamper Date: Fri, 5 Apr 2019 10:52:47 +0200 Subject: [PATCH 1/6] Dateizuordnung --- Mk0.Software.ImageSorter/Cropper.Designer.cs | 2 +- Mk0.Software.ImageSorter/FileAssociation.cs | 66 +++++++++++++++++ Mk0.Software.ImageSorter/Main.Designer.cs | 1 + Mk0.Software.ImageSorter/Main.cs | 69 +++++++++++++++++- .../Mk0.Software.ImageSorter.csproj | 1 + .../Properties/Resources.Designer.cs | 70 +++++++++++++++++++ .../Properties/Resources.resx | 21 ++++++ Mk0.Software.ImageSorter/Settings.cs | 1 + 8 files changed, 228 insertions(+), 3 deletions(-) create mode 100644 Mk0.Software.ImageSorter/FileAssociation.cs diff --git a/Mk0.Software.ImageSorter/Cropper.Designer.cs b/Mk0.Software.ImageSorter/Cropper.Designer.cs index 6f6c813..639e103 100644 --- a/Mk0.Software.ImageSorter/Cropper.Designer.cs +++ b/Mk0.Software.ImageSorter/Cropper.Designer.cs @@ -65,7 +65,7 @@ this.ClientSize = new System.Drawing.Size(800, 564); this.Controls.Add(this.label1); this.Controls.Add(this.rubberBand1); - this.Cursor = System.Windows.Forms.Cursors.Cross; + this.Cursor = System.Windows.Forms.Cursors.Default; this.MaximizeBox = false; this.MinimizeBox = false; this.MinimumSize = new System.Drawing.Size(816, 603); diff --git a/Mk0.Software.ImageSorter/FileAssociation.cs b/Mk0.Software.ImageSorter/FileAssociation.cs new file mode 100644 index 0000000..72e0789 --- /dev/null +++ b/Mk0.Software.ImageSorter/FileAssociation.cs @@ -0,0 +1,66 @@ +using Microsoft.Win32; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Mk0.Tools.FileAssociaton +{ + class FileAssociation + { + [System.Runtime.InteropServices.DllImport("Shell32.dll")] + private static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2); + + private const int SHCNE_ASSOCCHANGED = 0x8000000; + private const int SHCNF_FLUSH = 0x1000; + + public static void Add(string progId, string extension, string applicationFilePath, string fileTypeDescription, string iconPath) + { + bool madeChanges = false; + madeChanges |= SetAssociation( + extension, + progId, + fileTypeDescription, + applicationFilePath); + + if (madeChanges) + { + SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_FLUSH, IntPtr.Zero, IntPtr.Zero); + } + } + + public static void Remove(string progId, string extension, string applicationFilePath, string fileTypeDescription, string iconPath) + { + //remove reg + } + + public static void Check(string progId, string extension, string applicationFilePath, string fileTypeDescription, string iconPath) + { + //add or update reg + } + + private static bool SetAssociation(string extension, string progId, string fileTypeDescription, string applicationFilePath) + { + bool madeChanges = false; + madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + extension, progId); + madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + progId, fileTypeDescription); + madeChanges |= SetKeyDefaultValue($@"Software\Classes\{progId}\shell\open\command", "\"" + applicationFilePath + "\" \"%1\""); + return madeChanges; + } + + private static bool SetKeyDefaultValue(string keyPath, string value) + { + using (var key = Registry.CurrentUser.CreateSubKey(keyPath)) + { + if (key.GetValue(null) as string != value) + { + key.SetValue(null, value); + return true; + } + } + + return false; + } + } +} diff --git a/Mk0.Software.ImageSorter/Main.Designer.cs b/Mk0.Software.ImageSorter/Main.Designer.cs index 29c210d..c4b2a3b 100644 --- a/Mk0.Software.ImageSorter/Main.Designer.cs +++ b/Mk0.Software.ImageSorter/Main.Designer.cs @@ -471,6 +471,7 @@ this.KeyPreview = true; this.MinimumSize = new System.Drawing.Size(983, 605); this.Name = "Main"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Image Sorter v1.27 | © 2015-2019 by manuelkamper.com"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing); diff --git a/Mk0.Software.ImageSorter/Main.cs b/Mk0.Software.ImageSorter/Main.cs index da8e2eb..ea23175 100644 --- a/Mk0.Software.ImageSorter/Main.cs +++ b/Mk0.Software.ImageSorter/Main.cs @@ -1,12 +1,13 @@ using Microsoft.VisualBasic.FileIO; using Mk0.GUI.Banner; +using Mk0.Software.ImageSorter.Properties; using Mk0.Tools.Calculation; +using Mk0.Tools.FileAssociaton; using Mk0.Tools.Images; using Mk0.Tools.Randomization; using System; using System.Collections.Generic; using System.ComponentModel; -using System.Data; using System.Diagnostics; using System.Drawing; using System.Drawing.Imaging; @@ -54,6 +55,47 @@ namespace Mk0.Software.ImageSorter startupimage = Path.GetFileName(startuppath); } SetDefaultPath(); + + if (Properties.Settings.Default.fileAssociation) + { + ExtractAssocIcons(); + + FileAssociation.Check("Image_Sorter", ".jpg", Application.StartupPath, "JPG Bild", $@"{Application.StartupPath}\AssocIcons\jpg.ico"); + FileAssociation.Check("Image_Sorter", ".png", Application.StartupPath, "PNG Bild", $@"{Application.StartupPath}\AssocIcons\png.ico"); + FileAssociation.Check("Image_Sorter", ".gif", Application.StartupPath, "GIF Bild", $@"{Application.StartupPath}\AssocIcons\gif.ico"); + FileAssociation.Check("Image_Sorter", ".jpeg", Application.StartupPath, "JPEG Bild", $@"{Application.StartupPath}\AssocIcons\jpeg.ico"); + FileAssociation.Check("Image_Sorter", ".bmp", Application.StartupPath, "BMP Bild", $@"{Application.StartupPath}\AssocIcons\bmp.ico"); + FileAssociation.Check("Image_Sorter", ".tif", Application.StartupPath, "TIF Bild", $@"{Application.StartupPath}\AssocIcons\tif.ico"); + FileAssociation.Check("Image_Sorter", ".tiff", Application.StartupPath, "TIFF Bild", $@"{Application.StartupPath}\AssocIcons\tiff.ico"); + } + } + + /// + /// Extrahiert die Icons für die Fileassociation + /// + private void ExtractAssocIcons() + { + Directory.CreateDirectory($@"{Application.StartupPath}\AssocIcons"); + WriteResource($@"{Application.StartupPath}\AssocIcons\jpg.ico", Resources.jpg); + WriteResource($@"{Application.StartupPath}\AssocIcons\png.ico", Resources.png); + WriteResource($@"{Application.StartupPath}\AssocIcons\gif.ico", Resources.gif); + WriteResource($@"{Application.StartupPath}\AssocIcons\jpeg.ico", Resources.jpeg); + WriteResource($@"{Application.StartupPath}\AssocIcons\bmp.ico", Resources.bmp); + WriteResource($@"{Application.StartupPath}\AssocIcons\tif.ico", Resources.tif); + WriteResource($@"{Application.StartupPath}\AssocIcons\tiff.ico", Resources.tiff); + } + + /// + /// Helfer um Resources auf die Platte zu schreiben + /// + /// Zielpfad + /// Resource + private void WriteResource(string path, Icon icon) + { + using (var fileStream = new FileStream(path, FileMode.Create)) + { + icon.Save(fileStream); + } } /// @@ -258,9 +300,32 @@ namespace Mk0.Software.ImageSorter s.ShowDialog(); zielPath = Properties.Settings.Default.targetPath; - labelZielPath.Text = this.zielPath; + labelZielPath.Text = zielPath; imageIndex = 0; + if (Properties.Settings.Default.fileAssociation) + { + ExtractAssocIcons(); + FileAssociation.Add("Image_Sorter", ".jpg", Application.ExecutablePath, "JPG Bild", $@"{Application.StartupPath}\AssocIcons\jpg.ico"); + FileAssociation.Add("Image_Sorter", ".png", Application.ExecutablePath, "PNG Bild", $@"{Application.StartupPath}\AssocIcons\png.ico"); + FileAssociation.Add("Image_Sorter", ".gif", Application.ExecutablePath, "GIF Bild", $@"{Application.StartupPath}\AssocIcons\gif.ico"); + FileAssociation.Add("Image_Sorter", ".jpeg", Application.ExecutablePath, "JPEG Bild", $@"{Application.StartupPath}\AssocIcons\jpeg.ico"); + FileAssociation.Add("Image_Sorter", ".bmp", Application.ExecutablePath, "BMP Bild", $@"{Application.StartupPath}\AssocIcons\bmp.ico"); + FileAssociation.Add("Image_Sorter", ".tif", Application.ExecutablePath, "TIF Bild", $@"{Application.StartupPath}\AssocIcons\tif.ico"); + FileAssociation.Add("Image_Sorter", ".tiff", Application.ExecutablePath, "TIFF Bild", $@"{Application.StartupPath}\AssocIcons\tiff.ico"); + } + else + { + Directory.Delete($@"{Application.StartupPath}\AssocIcons", true); + FileAssociation.Remove("Image_Sorter", ".jpg", Application.ExecutablePath, "JPG Bild", $@"{Application.StartupPath}\AssocIcons\jpg.ico"); + FileAssociation.Remove("Image_Sorter", ".png", Application.ExecutablePath, "PNG Bild", $@"{Application.StartupPath}\AssocIcons\png.ico"); + FileAssociation.Remove("Image_Sorter", ".gif", Application.ExecutablePath, "GIF Bild", $@"{Application.StartupPath}\AssocIcons\gif.ico"); + FileAssociation.Remove("Image_Sorter", ".jpeg", Application.ExecutablePath, "JPEG Bild", $@"{Application.StartupPath}\AssocIcons\jpeg.ico"); + FileAssociation.Remove("Image_Sorter", ".bmp", Application.ExecutablePath, "BMP Bild", $@"{Application.StartupPath}\AssocIcons\bmp.ico"); + FileAssociation.Remove("Image_Sorter", ".tif", Application.ExecutablePath, "TIF Bild", $@"{Application.StartupPath}\AssocIcons\tif.ico"); + FileAssociation.Remove("Image_Sorter", ".tiff", Application.ExecutablePath, "TIFF Bild", $@"{Application.StartupPath}\AssocIcons\tiff.ico"); + } + CheckSubfolders(); SearchImages(); CountPicsInPath(); diff --git a/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj b/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj index 89e6b0e..962b988 100644 --- a/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj +++ b/Mk0.Software.ImageSorter/Mk0.Software.ImageSorter.csproj @@ -114,6 +114,7 @@ Cropper.cs + Form diff --git a/Mk0.Software.ImageSorter/Properties/Resources.Designer.cs b/Mk0.Software.ImageSorter/Properties/Resources.Designer.cs index c02786f..9f8c8cb 100644 --- a/Mk0.Software.ImageSorter/Properties/Resources.Designer.cs +++ b/Mk0.Software.ImageSorter/Properties/Resources.Designer.cs @@ -60,6 +60,16 @@ namespace Mk0.Software.ImageSorter.Properties { } } + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol). + /// + internal static System.Drawing.Icon bmp { + get { + object obj = ResourceManager.GetObject("bmp", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// @@ -80,6 +90,16 @@ namespace Mk0.Software.ImageSorter.Properties { } } + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol). + /// + internal static System.Drawing.Icon gif { + get { + object obj = ResourceManager.GetObject("gif", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// Sucht eine lokalisierte Ressource vom Typ System.Byte[]. /// @@ -100,6 +120,26 @@ namespace Mk0.Software.ImageSorter.Properties { } } + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol). + /// + internal static System.Drawing.Icon jpeg { + get { + object obj = ResourceManager.GetObject("jpeg", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol). + /// + internal static System.Drawing.Icon jpg { + get { + object obj = ResourceManager.GetObject("jpg", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// @@ -110,6 +150,36 @@ namespace Mk0.Software.ImageSorter.Properties { } } + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol). + /// + internal static System.Drawing.Icon png { + get { + object obj = ResourceManager.GetObject("png", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol). + /// + internal static System.Drawing.Icon tif { + get { + object obj = ResourceManager.GetObject("tif", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol). + /// + internal static System.Drawing.Icon tiff { + get { + object obj = ResourceManager.GetObject("tiff", resourceCulture); + return ((System.Drawing.Icon)(obj)); + } + } + /// /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. /// diff --git a/Mk0.Software.ImageSorter/Properties/Resources.resx b/Mk0.Software.ImageSorter/Properties/Resources.resx index c2fe0a4..99f7c4a 100644 --- a/Mk0.Software.ImageSorter/Properties/Resources.resx +++ b/Mk0.Software.ImageSorter/Properties/Resources.resx @@ -118,21 +118,42 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\bmp.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\crop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\gif.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Cursors\grab.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 ..\Cursors\grabbing.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\jpeg.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\jpg.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\move.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\png.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\tif.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\tiff.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\undo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a diff --git a/Mk0.Software.ImageSorter/Settings.cs b/Mk0.Software.ImageSorter/Settings.cs index 6c612be..9732cf3 100644 --- a/Mk0.Software.ImageSorter/Settings.cs +++ b/Mk0.Software.ImageSorter/Settings.cs @@ -23,6 +23,7 @@ namespace Mk0.Software.ImageSorter Properties.Settings.Default.Save(); } checkBoxSingleInstance.Checked = Properties.Settings.Default.singleInstance; + checkBoxFileAssociation.Checked = Properties.Settings.Default.fileAssociation; } private void ButtonChangeTargetPath_Click(object sender, EventArgs e) From bda8a696f9a1c634ddc638ecf351979483f0a210 Mon Sep 17 00:00:00 2001 From: Manuel Kamper Date: Fri, 5 Apr 2019 10:59:34 +0200 Subject: [PATCH 2/6] Merging --- Mk0.Software.ImageSorter/Main.Designer.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Mk0.Software.ImageSorter/Main.Designer.cs b/Mk0.Software.ImageSorter/Main.Designer.cs index 9a4c723..9a63f5e 100644 --- a/Mk0.Software.ImageSorter/Main.Designer.cs +++ b/Mk0.Software.ImageSorter/Main.Designer.cs @@ -77,8 +77,8 @@ // // pictureBox // - this.pictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.pictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.pictureBox.BackColor = System.Drawing.SystemColors.Control; this.pictureBox.ContextMenuStrip = this.contextMenuStrip; @@ -191,7 +191,7 @@ // // groupBox2 // - this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Right))); this.groupBox2.Controls.Add(this.labelZielPath); this.groupBox2.Controls.Add(this.panel2); @@ -216,7 +216,7 @@ // // panel2 // - this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + this.panel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left))); this.panel2.AutoScroll = true; this.panel2.Controls.Add(this.labelNoTargets); @@ -335,8 +335,8 @@ // // panel1 // - this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.panel1.BackColor = System.Drawing.SystemColors.Control; this.panel1.Controls.Add(this.labelNoImages); @@ -349,8 +349,8 @@ // // labelNoImages // - this.labelNoImages.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) + this.labelNoImages.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.labelNoImages.Font = new System.Drawing.Font("Microsoft Sans Serif", 13.875F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelNoImages.ForeColor = System.Drawing.Color.Maroon; @@ -374,7 +374,7 @@ // // panel3 // - this.panel3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + this.panel3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.panel3.BackColor = System.Drawing.SystemColors.Highlight; this.panel3.Controls.Add(this.pictureBox2); @@ -472,9 +472,8 @@ this.KeyPreview = true; this.MinimumSize = new System.Drawing.Size(983, 605); this.Name = "Main"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Show; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Image Sorter v1.29 | © 2015-2019 by manuelkamper.com"; + this.Text = "Image Sorter v1.30 | © 2015-2019 by manuelkamper.com"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing); this.Load += new System.EventHandler(this.Main_Load); this.Shown += new System.EventHandler(this.Main_Shown); @@ -536,4 +535,3 @@ private System.Windows.Forms.Label label3; } } - From ea50fadffecbac47d6df39e33e6db89b68527d28 Mon Sep 17 00:00:00 2001 From: Manuel Kamper Date: Fri, 5 Apr 2019 11:53:41 +0200 Subject: [PATCH 3/6] bereinigung --- Mk0.Software.ImageSorter/Main.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Mk0.Software.ImageSorter/Main.cs b/Mk0.Software.ImageSorter/Main.cs index 0e013e6..d75d780 100644 --- a/Mk0.Software.ImageSorter/Main.cs +++ b/Mk0.Software.ImageSorter/Main.cs @@ -31,15 +31,14 @@ namespace Mk0.Software.ImageSorter private bool moving; private bool moveable = false; private Point startLocation; //verschieben - private Cursor grabCursor = new Cursor(new MemoryStream(Properties.Resources.grab)); - private Cursor grabbingCursor = new Cursor(new MemoryStream(Properties.Resources.grabbing)); + private Cursor grabCursor = new Cursor(new MemoryStream(Resources.grab)); + private Cursor grabbingCursor = new Cursor(new MemoryStream(Resources.grabbing)); private double xFaktor = 0.0; private double yFaktor = 0.0; private static object locker = new object(); private Thread folderThread; private bool threadIsRunning = false; private Banner banner; - //private string zoomType = "auto"; private string startuppath; private string startupimage; public string[] Args; From 15ccbd6bdcef362d03154b7aad88f374fdcd8bbc Mon Sep 17 00:00:00 2001 From: Manuel Kamper Date: Fri, 5 Apr 2019 21:16:57 +0200 Subject: [PATCH 4/6] FileAssoc Icons --- Mk0.Software.ImageSorter/FileAssociation.cs | 11 ++++--- Mk0.Software.ImageSorter/Main.Designer.cs | 2 +- Mk0.Software.ImageSorter/Main.cs | 28 +++++++++--------- .../dll/Mk0.GUI.Banner.dll | Bin 8192 -> 8192 bytes 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Mk0.Software.ImageSorter/FileAssociation.cs b/Mk0.Software.ImageSorter/FileAssociation.cs index 72e0789..7971504 100644 --- a/Mk0.Software.ImageSorter/FileAssociation.cs +++ b/Mk0.Software.ImageSorter/FileAssociation.cs @@ -1,9 +1,5 @@ using Microsoft.Win32; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Mk0.Tools.FileAssociaton { @@ -22,7 +18,8 @@ namespace Mk0.Tools.FileAssociaton extension, progId, fileTypeDescription, - applicationFilePath); + applicationFilePath, + iconPath); if (madeChanges) { @@ -40,12 +37,14 @@ namespace Mk0.Tools.FileAssociaton //add or update reg } - private static bool SetAssociation(string extension, string progId, string fileTypeDescription, string applicationFilePath) + private static bool SetAssociation(string extension, string progId, string fileTypeDescription, string applicationFilePath, string iconPath) { + //todo add file assoc icon bool madeChanges = false; madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + extension, progId); madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + progId, fileTypeDescription); madeChanges |= SetKeyDefaultValue($@"Software\Classes\{progId}\shell\open\command", "\"" + applicationFilePath + "\" \"%1\""); + madeChanges |= SetKeyDefaultValue($@"Software\Classes\{progId}\DefaultIcon", "\"" + iconPath + "\""); return madeChanges; } diff --git a/Mk0.Software.ImageSorter/Main.Designer.cs b/Mk0.Software.ImageSorter/Main.Designer.cs index 9a63f5e..61ca9af 100644 --- a/Mk0.Software.ImageSorter/Main.Designer.cs +++ b/Mk0.Software.ImageSorter/Main.Designer.cs @@ -473,7 +473,7 @@ this.MinimumSize = new System.Drawing.Size(983, 605); this.Name = "Main"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Image Sorter v1.30 | © 2015-2019 by manuelkamper.com"; + this.Text = "Image Sorter v1.31 | © 2015-2019 by manuelkamper.com"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Main_FormClosing); this.Load += new System.EventHandler(this.Main_Load); this.Shown += new System.EventHandler(this.Main_Shown); diff --git a/Mk0.Software.ImageSorter/Main.cs b/Mk0.Software.ImageSorter/Main.cs index d75d780..29b60ba 100644 --- a/Mk0.Software.ImageSorter/Main.cs +++ b/Mk0.Software.ImageSorter/Main.cs @@ -320,24 +320,24 @@ namespace Mk0.Software.ImageSorter if (Properties.Settings.Default.fileAssociation) { ExtractAssocIcons(); - FileAssociation.Add("Image_Sorter", ".jpg", Application.ExecutablePath, "JPG Bild", $@"{Application.StartupPath}\AssocIcons\jpg.ico"); - FileAssociation.Add("Image_Sorter", ".png", Application.ExecutablePath, "PNG Bild", $@"{Application.StartupPath}\AssocIcons\png.ico"); - FileAssociation.Add("Image_Sorter", ".gif", Application.ExecutablePath, "GIF Bild", $@"{Application.StartupPath}\AssocIcons\gif.ico"); - FileAssociation.Add("Image_Sorter", ".jpeg", Application.ExecutablePath, "JPEG Bild", $@"{Application.StartupPath}\AssocIcons\jpeg.ico"); - FileAssociation.Add("Image_Sorter", ".bmp", Application.ExecutablePath, "BMP Bild", $@"{Application.StartupPath}\AssocIcons\bmp.ico"); - FileAssociation.Add("Image_Sorter", ".tif", Application.ExecutablePath, "TIF Bild", $@"{Application.StartupPath}\AssocIcons\tif.ico"); - FileAssociation.Add("Image_Sorter", ".tiff", Application.ExecutablePath, "TIFF Bild", $@"{Application.StartupPath}\AssocIcons\tiff.ico"); + FileAssociation.Add("Image_Sorter_JPG", ".jpg", Application.ExecutablePath, "JPG Bild", $@"{Application.StartupPath}\AssocIcons\jpg.ico"); + FileAssociation.Add("Image_Sorter_PNG", ".png", Application.ExecutablePath, "PNG Bild", $@"{Application.StartupPath}\AssocIcons\png.ico"); + FileAssociation.Add("Image_Sorter_GIF", ".gif", Application.ExecutablePath, "GIF Bild", $@"{Application.StartupPath}\AssocIcons\gif.ico"); + FileAssociation.Add("Image_Sorter_JPEG", ".jpeg", Application.ExecutablePath, "JPEG Bild", $@"{Application.StartupPath}\AssocIcons\jpeg.ico"); + FileAssociation.Add("Image_Sorter_BMP", ".bmp", Application.ExecutablePath, "BMP Bild", $@"{Application.StartupPath}\AssocIcons\bmp.ico"); + FileAssociation.Add("Image_Sorter_TIF", ".tif", Application.ExecutablePath, "TIF Bild", $@"{Application.StartupPath}\AssocIcons\tif.ico"); + FileAssociation.Add("Image_Sorter_TIFF", ".tiff", Application.ExecutablePath, "TIFF Bild", $@"{Application.StartupPath}\AssocIcons\tiff.ico"); } else { Directory.Delete($@"{Application.StartupPath}\AssocIcons", true); - FileAssociation.Remove("Image_Sorter", ".jpg", Application.ExecutablePath, "JPG Bild", $@"{Application.StartupPath}\AssocIcons\jpg.ico"); - FileAssociation.Remove("Image_Sorter", ".png", Application.ExecutablePath, "PNG Bild", $@"{Application.StartupPath}\AssocIcons\png.ico"); - FileAssociation.Remove("Image_Sorter", ".gif", Application.ExecutablePath, "GIF Bild", $@"{Application.StartupPath}\AssocIcons\gif.ico"); - FileAssociation.Remove("Image_Sorter", ".jpeg", Application.ExecutablePath, "JPEG Bild", $@"{Application.StartupPath}\AssocIcons\jpeg.ico"); - FileAssociation.Remove("Image_Sorter", ".bmp", Application.ExecutablePath, "BMP Bild", $@"{Application.StartupPath}\AssocIcons\bmp.ico"); - FileAssociation.Remove("Image_Sorter", ".tif", Application.ExecutablePath, "TIF Bild", $@"{Application.StartupPath}\AssocIcons\tif.ico"); - FileAssociation.Remove("Image_Sorter", ".tiff", Application.ExecutablePath, "TIFF Bild", $@"{Application.StartupPath}\AssocIcons\tiff.ico"); + FileAssociation.Remove("Image_Sorter_JPG", ".jpg", Application.ExecutablePath, "JPG Bild", $@"{Application.StartupPath}\AssocIcons\jpg.ico"); + FileAssociation.Remove("Image_Sorter_PNG", ".png", Application.ExecutablePath, "PNG Bild", $@"{Application.StartupPath}\AssocIcons\png.ico"); + FileAssociation.Remove("Image_Sorter_GIF", ".gif", Application.ExecutablePath, "GIF Bild", $@"{Application.StartupPath}\AssocIcons\gif.ico"); + FileAssociation.Remove("Image_Sorter_JPEG", ".jpeg", Application.ExecutablePath, "JPEG Bild", $@"{Application.StartupPath}\AssocIcons\jpeg.ico"); + FileAssociation.Remove("Image_Sorter_BMP", ".bmp", Application.ExecutablePath, "BMP Bild", $@"{Application.StartupPath}\AssocIcons\bmp.ico"); + FileAssociation.Remove("Image_Sorter_TIF", ".tif", Application.ExecutablePath, "TIF Bild", $@"{Application.StartupPath}\AssocIcons\tif.ico"); + FileAssociation.Remove("Image_Sorter_TIFF", ".tiff", Application.ExecutablePath, "TIFF Bild", $@"{Application.StartupPath}\AssocIcons\tiff.ico"); } CheckSubfolders(); diff --git a/Mk0.Software.ImageSorter/dll/Mk0.GUI.Banner.dll b/Mk0.Software.ImageSorter/dll/Mk0.GUI.Banner.dll index 35e70ab28c3af22263510c7742ce37c9fb90dfd5..190af6eb97892d41867e0c2a3b0858686a8b3c48 100644 GIT binary patch delta 1402 zcmZ9Me`u6-9LL|^=jW|$*Ikdh?b+|Ub2HsF$5t(@)G_}s(>l*GwR3Haku3CN=l;k^ zx5G8ul5l*962dk|LNNq6B_<(r6bysVKLX_vwn6?gNJfdY+Scd$y>AP8{&+o~*XR9t zzI^X_?s@vR_isOU#+VHaEsvZnXVW8Jzr_-qu?^y?G)uYT&5*}V zq6QNUwZP{-fblW6c|58yHpKVp?|33i4D{)|-gNmL{YFXyj6OdhQ2{(r)wrTLmfwm* z5OC}|mqz~^sHA~f`0e5Yj_tRro?bB=kKgl5mWB+mKo#Y{rtW{eT)5U}u4S8?1_NVq zhwxKk0sNNXW!3ziag_!6CuSY-x;elq`8MlPX*DfSa^PUHn9hl^+-ka9EwgG(YN-nd zBBoy?ZZ$6v+azC;w2W`S(57D|=HUv_Cs~MVRIeij5n_|#T1iMo@f~%#iDA^4Q#3h% z8RA{Z%fu*c3K%SLtRGVp><$V|V^q(=##|_8x5)DFx3X(w`IrccY!Fd>9)-BOW(#yH z^!2%Hx4}>ZN7)}_0fd!ZBrC?V%1&BENR?n$jkxf%XTf>|7cpg~E$oo8K~vbf$_}wV z$-0#tm)4Ur`c3nconNyBRA6e&EV?s4tLvUJVhFy1`${*{-hz0b>;{D){HE+4Wg$FP zc7(DpR+W83Ss0$$%!m2yEVT`jaI77~CVLmL8ZlxmaSkv)RsR>cy zi;}G}coqApvrl&3mh40?b>7F9#3UwIJL|&|>z7O`p2jL0mGzjS=uFA_rlRP~%6d*R zHOEAYX<|91iMmDBEwXNxb%&xz`(>S06rE97Pf5;7LKmww;s_Er37!72Cg`=pLu-YY zXA2ISf^DTtqmRQ0$=3~=>c^5_88+|rwz4>%^oEOu5ussv2_FkR4bRAD{+kLt4GxdQK3ti!R-7+@LkGdQAr|zDNw{%I@zHiR>D<86v2KygO CQzDoE delta 1317 zcmYk6eQZ-z7>9r7ey)6!j!M^Vu=TbXh$C~3#EM^G=?JL9RU6b{H@3`%ud$l7OHhbi z-E5~ZhUOR@f#_sWKn;mhjZ=h4BohAc>kosXZi8qrkf6puq6og{aI$!l``q92zW2Vl zJ@@twtQ=UmYuNDpu>ZZ{iwoH+#e7_VOId2DV2aw>3l! zCN90rx_*EmwYWO1aeHP^3 znsvl$<`8rEp!HT|4V~nFtSwzZ$5fTLLffIs8KtN_u4VVY!NdCN#Cy##Vu$2|l9sU_ z3?2GAL>CSbJ(6>AnDR|T2O;*MxKh zON|ysXbz+LY1r5kx?!itT=+=Y2V}FcDJ*(<#Pmtb#mh5x9_2Wuti@nhfUlJOMdrh# zvVCL~_+8o4)&gYxuxP=7!Lke1p9sLM%(R91l;urf)ymeh%Vdj{Jt?jJhS6`Dq~5w2 zJC8-!Ib#;BOi^7o-)Mz%A9gFfmF~^KK4nL#8N%DjzNcOYC1sna7se;bo}*qEpVyX- z&+cT|yJ^|IRugf#y_y(AD{(RL4?JbY@jSjZEzH3gtCjLEmPPdwl;_Zz_7KvYIS zwi@(ga7FS>!{FoYC~M>Yy2Gr%oq67+1&oO)pnvqtRzSoQ^8ebdQv1BP?HN0^;^${x zy143S;d)swe$4O*U!%)qTUvR$rfK||ua@6jvCuSv^khoS6~in*b2eO_eof5NXdkBi z2z`K#`1x6XX!V!L_V1oO=f3|yVg1JketY!`x>rQ+Osq>M`_hSRUA_IuM02XUe_OIQ zlTJLcIo;pY6O3p2pV*uVHa6TANyPe6Taw)w-Wa%NevkTw(Fo*44i+6B+s;Pm5w0rl}BasU7T From 522226bec7be8a9701df348d4e27b55a8182c7a5 Mon Sep 17 00:00:00 2001 From: Manuel Kamper Date: Fri, 5 Apr 2019 21:18:55 +0200 Subject: [PATCH 5/6] file assoc --- Mk0.Software.ImageSorter/FileAssociation.cs | 5 ++--- Mk0.Software.ImageSorter/Main.cs | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Mk0.Software.ImageSorter/FileAssociation.cs b/Mk0.Software.ImageSorter/FileAssociation.cs index 7971504..20aafac 100644 --- a/Mk0.Software.ImageSorter/FileAssociation.cs +++ b/Mk0.Software.ImageSorter/FileAssociation.cs @@ -29,17 +29,16 @@ namespace Mk0.Tools.FileAssociaton public static void Remove(string progId, string extension, string applicationFilePath, string fileTypeDescription, string iconPath) { - //remove reg + //remove reg todo } public static void Check(string progId, string extension, string applicationFilePath, string fileTypeDescription, string iconPath) { - //add or update reg + //add or update reg todo } private static bool SetAssociation(string extension, string progId, string fileTypeDescription, string applicationFilePath, string iconPath) { - //todo add file assoc icon bool madeChanges = false; madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + extension, progId); madeChanges |= SetKeyDefaultValue(@"Software\Classes\" + progId, fileTypeDescription); diff --git a/Mk0.Software.ImageSorter/Main.cs b/Mk0.Software.ImageSorter/Main.cs index 29b60ba..a6fe7c2 100644 --- a/Mk0.Software.ImageSorter/Main.cs +++ b/Mk0.Software.ImageSorter/Main.cs @@ -51,6 +51,8 @@ namespace Mk0.Software.ImageSorter DoubleBuffered = true; SetDefaultPath(); comboBoxZoom.SelectedIndex = Properties.Settings.Default.zoom; + + //todo file assoc prüfen } private void Main_Load(object sender, EventArgs e) From d5fa68333300a68cbb4b6ae4ff97276e261cd97c Mon Sep 17 00:00:00 2001 From: manuelkamp <48356947+manuelkamp@users.noreply.github.com> Date: Sun, 14 Apr 2019 16:38:52 +0200 Subject: [PATCH 6/6] Update LICENSE --- LICENSE | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/LICENSE b/LICENSE index 8b23445..9435247 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,9 @@ -MIT License +Copyright 2000-2019 mk0.at and Manuel Kamper -Copyright (c) 2019 +This is valid for all kind of software published via GitHub from "manuelkamp" and NuGet packages published via NuGet from "Manuel Kamper". -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.