Skip to content

Commit

Permalink
Merge pull request #18311 from unoplatform/dev/doti/resourcesextracto…
Browse files Browse the repository at this point in the history
…r-colors

feat: Add Color resources to ResourcesExtractor
  • Loading branch information
morning4coffe-dev authored Oct 12, 2024
2 parents c0d7d87 + 2c266a4 commit 5fd8ce0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 deletions.
30 changes: 29 additions & 1 deletion tools/ResourcesExtractor/ResourcesExtractor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft/* UWP don't rename */.UI.Xaml;
using Windows.Storage;
using Windows.System;

namespace ResourcesExtractor;

Expand All @@ -12,8 +16,15 @@ public sealed partial class MainWindow : Window
private static List<(string ResourceName, int ResourceId)> GetResources()
{
var allResources = new List<(string ResourceName, int ResourceId)>();

for (var i = 5114; i <= 5155; i++)
{
allResources.Add((i.ToString(CultureInfo.InvariantCulture), i));
}

allResources.AddRange(GetResourcesFromFile("dxaml\\phone\\lib\\PhoneResource.h"));
allResources.AddRange(GetResourcesFromFile("dxaml\\xcp\\inc\\localizedResource.h"));

return allResources;
}

Expand All @@ -39,10 +50,12 @@ public MainWindow()
{
this.InitializeComponent();

var rootDirectory = "C:\\GeneratedResources\\";

var resources = GetResources();
foreach (var lang in Enum.GetValues<Magic.Languages>())
{
var filePath = $"C:\\GeneratedResources\\{lang.ToString().Replace('_', '-')}\\Resources.resw";
var filePath = $"{rootDirectory}{lang.ToString().Replace('_', '-')}\\Resources.resw";
var directory = Path.GetDirectoryName(filePath);
Directory.CreateDirectory(directory);
var writer = new StreamWriter(new FileStream(filePath, FileMode.CreateNew));
Expand All @@ -64,5 +77,20 @@ public MainWindow()
writer.Write(Constants.ReswFileEnd);
writer.Close();
}

OpenFileManagerAsync(rootDirectory).ConfigureAwait(false);
}

private async Task OpenFileManagerAsync(string directoryPath)
{
try
{
var folder = await StorageFolder.GetFolderFromPathAsync(directoryPath);
await Launcher.LaunchFolderAsync(folder);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error: {ex.Message}");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<RootNamespace>ResourcesExtractor</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;ARM64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
<UseWinUI>true</UseWinUI>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<EnableMsixTooling>true</EnableMsixTooling>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

Expand Down

0 comments on commit 5fd8ce0

Please sign in to comment.