Skip to content

Commit

Permalink
localization of depth wallpaper feature
Browse files Browse the repository at this point in the history
  • Loading branch information
rocksdanister committed Jun 17, 2023
1 parent bf5444e commit 4884f0d
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/Lively/Lively.UI.WinUI/Services/DialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
using Windows.ApplicationModel.Resources;
using WinUICommunity;
using static Lively.UI.WinUI.Services.IDialogService;
using static WinUICommunity.LanguageDictionary;

namespace Lively.UI.WinUI.Services
{
Expand Down Expand Up @@ -122,9 +121,9 @@ public async Task<ILibraryModel> ShowDepthWallpaperDialog(string imagePath)
vm.SelectedImage = imagePath;
var depthDialog = new ContentDialog
{
Title = "AI Depth Wallpaper",
Title = i18n.GetString("TitleDepthWallpaper/Content"),
Content = new DepthEstimateWallpaperView(vm),
PrimaryButtonText = i18n.GetString("TextOK"),
PrimaryButtonText = i18n.GetString("TextContinue/Content"),
SecondaryButtonText = i18n.GetString("Cancel/Content"),
DefaultButton = ContentDialogButton.Primary,
XamlRoot = App.Services.GetRequiredService<MainWindow>().Content.XamlRoot,
Expand Down
27 changes: 27 additions & 0 deletions src/Lively/Lively.UI.WinUI/Strings/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1178,4 +1178,31 @@ If still not working, close &amp; start Lively again/restart windows.
<data name="WallpaperPluginGroup.Header" xml:space="preserve">
<value>Plugins</value>
</data>
<data name="AddWallpaperAdvanced.Description" xml:space="preserve">
<value>Create a dynamic wallpaper</value>
</data>
<data name="AddWallpaperAdvanced.Header" xml:space="preserve">
<value>Advanced</value>
</data>
<data name="DescriptionDepthApprox.Content" xml:space="preserve">
<value>Approximating depth..</value>
</data>
<data name="DescriptionDepthWallpaperItem.Content" xml:space="preserve">
<value>Using AI transform photographs into 3D</value>
</data>
<data name="TextContinue.Content" xml:space="preserve">
<value>Continue</value>
</data>
<data name="TitleCreateWallpaperOpenItem.Description" xml:space="preserve">
<value>Create a simple wallpaper</value>
</data>
<data name="TitleDepthWallpaper.Content" xml:space="preserve">
<value>AI Depth Wallpaper</value>
</data>
<data name="TitleDepthWallpaperItem.Content" xml:space="preserve">
<value>Depth Wallpaper</value>
</data>
<data name="DescriptionDepthWallpaperTemplate.Content" xml:space="preserve">
<value>AI generated depth wallpaper</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.Resources;

namespace Lively.UI.WinUI.ViewModels
{
public partial class AddWallpaperCreateViewModel : ObservableObject
{
private readonly ResourceLoader i18n;

[ObservableProperty]
private ObservableCollection<AddWallpaperCreateModel> wallpaperCategories = new();
[ObservableProperty]
Expand All @@ -23,20 +26,22 @@ public partial class AddWallpaperCreateViewModel : ObservableObject

public AddWallpaperCreateViewModel()
{
i18n = ResourceLoader.GetForViewIndependentUse();

WallpaperCategoriesFiltered = new AdvancedCollectionView(WallpaperCategories, true);

WallpaperCategories.Add(new AddWallpaperCreateModel()
{
Title = "Open",
Description = "Create a simple wallpaper",
Title = i18n.GetString("TextOpen/Content"),
Description = i18n.GetString("TitleCreateWallpaperOpenItem/Description"),
TypeSupported = WallpaperType.picture,
CreateType = WallpaperCreateType.none,
Icon = "ms-appx:///Assets/icons8-wallpaper-96.png"
});
WallpaperCategories.Add(new AddWallpaperCreateModel()
{
Title = "Depth Wallpaper",
Description = "Using AI transform photographs into 3D",
Title = i18n.GetString("TitleDepthWallpaperItem/Content"),
Description = i18n.GetString("DescriptionDepthWallpaperItem/Content"),
CreateType = WallpaperCreateType.depthmap,
TypeSupported = WallpaperType.picture,
Icon = "ms-appx:///Assets/icons8-artificial-intelligence-100.png"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.ApplicationModel.Resources;
using static Lively.Common.Helpers.Archive.ZipCreate;

namespace Lively.UI.WinUI.ViewModels
Expand All @@ -31,6 +32,7 @@ public partial class DepthEstimateWallpaperViewModel : ObservableObject
public ILibraryModel NewWallpaper { get; private set; }
public event EventHandler OnRequestClose;
private readonly DispatcherQueue dispatcherQueue;
private readonly ResourceLoader i18n;

private readonly IDepthEstimate depthEstimate;
private readonly IDownloadHelper downloader;
Expand All @@ -48,6 +50,7 @@ public DepthEstimateWallpaperViewModel(IDepthEstimate depthEstimate,
this.userSettings = userSettings;

dispatcherQueue = DispatcherQueue.GetForCurrentThread() ?? DispatcherQueueController.CreateOnCurrentThread().DispatcherQueue;
i18n = ResourceLoader.GetForViewIndependentUse();

_canRunCommand = IsModelExists;
RunCommand.NotifyCanExecuteChanged();
Expand Down Expand Up @@ -101,7 +104,7 @@ private async Task PredictDepth()
IsRunning = true;
_canRunCommand = false;
RunCommand.NotifyCanExecuteChanged();
PreviewText = "Approximating depth..";
PreviewText = i18n.GetString("DescriptionDepthApprox/Content");

if (!Constants.MachineLearning.MiDaSPath.Equals(depthEstimate.ModelPath, StringComparison.Ordinal))
depthEstimate.LoadModel(Constants.MachineLearning.MiDaSPath);
Expand All @@ -112,7 +115,7 @@ private async Task PredictDepth()
var tempImgPath = Path.Combine(Constants.CommonPaths.TempDir, Path.GetRandomFileName() + ".jpg");
img.Write(tempImgPath);
PreviewImage = tempImgPath;
PreviewText = "Completed";
PreviewText = i18n.GetString("TextCompleted");
await Task.Delay(1500);

NewWallpaper = await CreateWallpaper();
Expand Down Expand Up @@ -154,7 +157,7 @@ private async Task<ILibraryModel> CreateWallpaper()
JsonStorage<ILivelyInfoModel>.StoreData(Path.Combine(destDir, "LivelyInfo.json"), new LivelyInfoModel()
{
Title = Path.GetFileNameWithoutExtension(SelectedImage),
Desc = "AI generated depth wallpaper template",
Desc = i18n.GetString("DescriptionDepthWallpaperTemplate/Content"),
Type = WallpaperType.web,
IsAbsolutePath = false,
FileName = "index.html",
Expand Down
3 changes: 1 addition & 2 deletions src/Lively/Lively.UI.WinUI/Views/Pages/AddWallpaperView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@
</controls:SettingsExpander>

<controls:SettingsCard
x:Uid="AddWallpaperAdvanced"
Margin="0,1,0,0"
Command="{Binding CreateWallpaperCommand}"
Description="Create a dynamic wallpaper"
Header="Custom"
IsClickEnabled="True">
<controls:SettingsCard.HeaderIcon>
<FontIcon Glyph="&#xE790;" />
Expand Down

0 comments on commit 4884f0d

Please sign in to comment.