Dateizuordnung
This commit is contained in:
parent
f84263bb26
commit
a7b501dac8
2
Mk0.Software.ImageSorter/Cropper.Designer.cs
generated
2
Mk0.Software.ImageSorter/Cropper.Designer.cs
generated
@ -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);
|
||||
|
66
Mk0.Software.ImageSorter/FileAssociation.cs
Normal file
66
Mk0.Software.ImageSorter/FileAssociation.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
1
Mk0.Software.ImageSorter/Main.Designer.cs
generated
1
Mk0.Software.ImageSorter/Main.Designer.cs
generated
@ -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);
|
||||
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extrahiert die Icons für die Fileassociation
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helfer um Resources auf die Platte zu schreiben
|
||||
/// </summary>
|
||||
/// <param name="path">Zielpfad</param>
|
||||
/// <param name="icon">Resource</param>
|
||||
private void WriteResource(string path, Icon icon)
|
||||
{
|
||||
using (var fileStream = new FileStream(path, FileMode.Create))
|
||||
{
|
||||
icon.Save(fileStream);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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();
|
||||
|
@ -114,6 +114,7 @@
|
||||
<Compile Include="Cropper.Designer.cs">
|
||||
<DependentUpon>Cropper.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FileAssociation.cs" />
|
||||
<Compile Include="Main.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
@ -60,6 +60,16 @@ namespace Mk0.Software.ImageSorter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon bmp {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("bmp", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
@ -80,6 +90,16 @@ namespace Mk0.Software.ImageSorter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon gif {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("gif", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Ressource vom Typ System.Byte[].
|
||||
/// </summary>
|
||||
@ -100,6 +120,26 @@ namespace Mk0.Software.ImageSorter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon jpeg {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("jpeg", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon jpg {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("jpg", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
@ -110,6 +150,36 @@ namespace Mk0.Software.ImageSorter.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon png {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("png", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon tif {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("tif", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Icon ähnlich wie (Symbol).
|
||||
/// </summary>
|
||||
internal static System.Drawing.Icon tiff {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("tiff", resourceCulture);
|
||||
return ((System.Drawing.Icon)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
@ -118,21 +118,42 @@
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="bmp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\bmp.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="crop" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\crop.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="delete" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="gif" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\gif.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="grab" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Cursors\grab.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="grabbing" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Cursors\grabbing.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</data>
|
||||
<data name="jpeg" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\jpeg.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="jpg" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\jpg.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="move" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\move.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="png" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\png.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="tif" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\tif.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="tiff" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\tiff.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="undo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\undo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user