* Feature #307 : New windows setting to use cover art as folder's icon. Incomplete. Need to add to avalonia settings

* Interop refactor
This commit is contained in:
Robert McRackan 2022-08-12 17:55:15 -04:00
parent aea8c11dc4
commit 1524d558a4
33 changed files with 1867 additions and 1794 deletions

View file

@ -1,4 +1,4 @@
using AppScaffolding.OSInterop;
using LibationFileManager;
namespace LinuxConfigApp
{
@ -7,22 +7,7 @@ namespace LinuxConfigApp
public LinuxInterop() { }
public LinuxInterop(params object[] values) { }
// examples until the real interface is filled out
private string InitValue1 { get; }
private int InitValue2 { get; }
public LinuxInterop(string initValue1, int initValue2)
{
InitValue1 = initValue1;
InitValue2 = initValue2;
}
public string TransformInit1() => InitValue1.ToLower();
public int TransformInit2() => InitValue2 + InitValue2;
public void CopyTextToClipboard(string text) => throw new PlatformNotSupportedException();
public void ShowForm() => throw new PlatformNotSupportedException();
public void SetFolderIcon(string image, string directory) => throw new PlatformNotSupportedException();
public void DeleteFolderIcon(string directory) => throw new PlatformNotSupportedException();
}
}

View file

@ -1,4 +1,4 @@
using AppScaffolding.OSInterop;
using AppScaffolding;
namespace LinuxConfigApp
{

View file

@ -1,4 +1,4 @@
using AppScaffolding.OSInterop;
using LibationFileManager;
namespace MacOSConfigApp
{
@ -7,22 +7,7 @@ namespace MacOSConfigApp
public MacOSInterop() { }
public MacOSInterop(params object[] values) { }
// examples until the real interface is filled out
private string InitValue1 { get; }
private int InitValue2 { get; }
public MacOSInterop(string initValue1, int initValue2)
{
InitValue1 = initValue1;
InitValue2 = initValue2;
}
public string TransformInit1() => InitValue1.ToLower();
public int TransformInit2() => InitValue2 + InitValue2;
public void CopyTextToClipboard(string text) => throw new PlatformNotSupportedException();
public void ShowForm() => throw new PlatformNotSupportedException();
public void SetFolderIcon(string image, string directory) => throw new PlatformNotSupportedException();
public void DeleteFolderIcon(string directory) => throw new PlatformNotSupportedException();
}
}

View file

@ -1,4 +1,4 @@
using AppScaffolding.OSInterop;
using AppScaffolding;
namespace MacOSConfigApp
{

View file

@ -1 +1,7 @@
Streamlined example is in \Source\_Demos\LoadByOS
Streamlined example is in \Source\_Demos\LoadByOS
MUST follow naming conventions in InteropFactory
Windows : Path.GetFileName(a).StartsWithInsensitive("win")
Linux : Path.GetFileName(a).StartsWithInsensitive("linux")
MacOs : Path.GetFileName(a).StartsWithInsensitive("mac") || a.StartsWithInsensitive("osx")

View file

@ -1,4 +1,4 @@
using AppScaffolding.OSInterop;
using AppScaffolding;
namespace WindowsConfigApp
{
@ -9,6 +9,7 @@ namespace WindowsConfigApp
{
typeof(Form1),
typeof(Bitmap),
typeof(Icon),
typeof(Accessibility.IAccIdentity),
typeof(Microsoft.Win32.SystemEvents)
};

View file

@ -1,4 +1,11 @@
using AppScaffolding.OSInterop;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Dinah.Core.WindowsDesktop;
using Dinah.Core.WindowsDesktop.Drawing;
using LibationFileManager;
namespace WindowsConfigApp
{
@ -7,27 +14,26 @@ namespace WindowsConfigApp
public WinInterop() { }
public WinInterop(params object[] values) { }
// examples until the real interface is filled out
private string InitValue1 { get; }
private int InitValue2 { get; }
public WinInterop(string initValue1, int initValue2)
public void SetFolderIcon(string image, string directory)
{
InitValue1 = initValue1;
InitValue2 = initValue2;
string iconPath = null;
try
{
var icon = ImageReader.ToIcon(image);
iconPath = Path.Combine(directory, $"{Guid.NewGuid()}.ico");
icon.Save(iconPath);
new DirectoryInfo(directory).SetIcon(iconPath, Directories.FolderTypes.Music);
}
finally
{
if (File.Exists(iconPath))
File.Delete(iconPath);
}
}
public void CopyTextToClipboard(string text) => Clipboard.SetDataObject(text, true, 5, 150);
public void ShowForm()
{
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
public string TransformInit1() => InitValue1.ToUpper();
public int TransformInit2() => InitValue2 * InitValue2;
public void DeleteFolderIcon(string directory)
=> new DirectoryInfo(directory)?.DeleteIcon();
}
}

View file

@ -19,6 +19,10 @@
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dinah.Core.WindowsDesktop" Version="5.2.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\AppScaffolding\AppScaffolding.csproj" />
</ItemGroup>