-
Notifications
You must be signed in to change notification settings - Fork 429
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow extraction of icons for shortcuts (#1143)
- Loading branch information
1 parent
96ed476
commit 81c6512
Showing
11 changed files
with
95 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Reflection; | ||
using System.Windows.Markup; | ||
|
||
namespace Bloxstrap.Models.SettingTasks | ||
{ | ||
public class ExtractIconsTask : BoolBaseTask | ||
{ | ||
public ExtractIconsTask() : base("ExtractIcons") | ||
{ | ||
OriginalState = Directory.Exists(Paths.Icons); | ||
} | ||
|
||
public override void Execute() | ||
{ | ||
if (NewState) | ||
{ | ||
Directory.CreateDirectory(Paths.Icons); | ||
|
||
var assembly = Assembly.GetExecutingAssembly(); | ||
var resourceNames = assembly.GetManifestResourceNames().Where(x => x.EndsWith(".ico")); | ||
|
||
foreach (string name in resourceNames) | ||
{ | ||
string path = Path.Combine(Paths.Icons, name.Replace("Bloxstrap.Resources.", "")); | ||
var stream = assembly.GetManifestResourceStream(name)!; | ||
|
||
using var memoryStream = new MemoryStream(); | ||
stream.CopyTo(memoryStream); | ||
|
||
Filesystem.AssertReadOnly(path); | ||
File.WriteAllBytes(path, memoryStream.ToArray()); | ||
} | ||
} | ||
else if (Directory.Exists(Paths.Icons)) | ||
{ | ||
Directory.Delete(Paths.Icons, true); | ||
} | ||
|
||
OriginalState = NewState; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters