Skip to content

Commit

Permalink
Polish WPF previewer and update translations
Browse files Browse the repository at this point in the history
  • Loading branch information
t1m0thyj committed Oct 7, 2020
1 parent 8911c95 commit 9e1cca2
Show file tree
Hide file tree
Showing 29 changed files with 101 additions and 55 deletions.
14 changes: 7 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

## `4.3.0`

* Redesign theme selector dialog to show carousel that autocycles through images (thanks @cjvaughter)
* Add Indonesian translation (thanks @ChrisG661)
* Fix error when Windows 10 default wallpaper missing
* Redesigned theme selector dialog to show carousel that autocycles through images (thanks @cjvaughter)
* Added Dutch, Korean, and Indonesian translations (thanks Samuel, jihwan_bong, and @ChrisG661)
* Fixed error when Windows 10 default wallpaper missing

## `4.2.0`

* Add Big Sur and Big Sur Abstract themes
* Add Bulgarian and Japanese translations (thanks Marin and Syoyusensation)
* Improve error checking for theme JSON when new themes are installed
* Fix check for updates failing on Windows 7
* Added Big Sur and Big Sur Abstract themes
* Added Bulgarian and Japanese translations (thanks Marin and Syoyusensation)
* Improved error checking for theme JSON when new themes are installed
* Fixed check for updates failing on Windows 7
2 changes: 1 addition & 1 deletion scripts/i18n_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
projects = client.list_projects()
project_id = [p for p in projects if p["name"] == "WinDynamicDesktop"][0]["id"]
languages = client.list_project_languages(project_id)
language_codes = [l["code"] for l in languages if l["translations"]]
language_codes = [l["code"] for l in languages if l["percentage"] >= 50]

for lc in language_codes:
print(f"Downloading translation for {lc}")
Expand Down
2 changes: 1 addition & 1 deletion scripts/i18n_gettext.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def add_to_pot_data(msgid, filename, lineno):
pot_data[msgid].append((filename, lineno))


for filename in glob.glob("../src/*.cs"):
for filename in glob.glob("../src/**/*.cs", recursive=True):
with open(filename, 'r', encoding="utf8") as cs_file:
if not filename.endswith(".Designer.cs"):
msg_history = []
Expand Down
9 changes: 5 additions & 4 deletions src/Localization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,25 @@ public static void TranslateForm(Form form)
private static void LoadLanguages()
{
AddLanguage("Bahasa Indonesia", "id"); // Indonesian
AddLanguage("Čeština", "cs"); // Czech
AddLanguage("Deutsch", "de"); // German
AddLanguage("English", "en"); // English
AddLanguage("Español", "es"); // Spanish
AddLanguage("Français", "fr"); // French
AddLanguage("Eλληνικά", "el"); // Greek
AddLanguage("Italiano", "it"); // Italian
AddLanguage("Македонски", "mk"); // Macedonian
AddLanguage("Nederlands", "nl"); // Dutch
AddLanguage("Polski", "pl"); // Polish
AddLanguage("Português (do Brasil)", "pt-br"); // Portuguese (BR)
AddLanguage("Română", "ro"); // Romanian
AddLanguage("Pусский", "ru"); // Russian
AddLanguage("Română", "ro"); // Romanian
AddLanguage("Türkçe", "tr"); // Turkish
AddLanguage("Čeština", "cs"); // Czech
AddLanguage("Български", "bg"); // Bulgarian
AddLanguage("Македонски", "mk"); // Macedonian
AddLanguage("हिन्दी", "hi"); // Hindi
AddLanguage("বাংলা", "bn"); // Bengali
AddLanguage("中文 (简体)", "zh-Hans"); // Chinese (Simplified)
AddLanguage("日本語", "ja"); // Japanese
AddLanguage("한국어", "ko"); // Korean
}

private static void AddLanguage(string languageName, string languageCode)
Expand Down
14 changes: 12 additions & 2 deletions src/ThemeDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,27 @@ public ThemeDialog()

Rectangle bounds = Screen.FromControl(this).Bounds;
Size thumbnailSize = ThemeThumbLoader.GetThumbnailSize(this);
int newWidth = thumbnailSize.Width + SystemInformation.VerticalScrollBarWidth + 46;
int newWidth = thumbnailSize.Width + SystemInformation.VerticalScrollBarWidth;
int oldWidth = this.listView1.Size.Width;

using (Graphics g = this.CreateGraphics())
{
newWidth += (int)Math.Ceiling(46 * g.DpiX / 96);
}

this.previewerHost.Anchor &= ~AnchorStyles.Left;
this.listView1.Width = newWidth;
this.downloadButton.Left += (newWidth - oldWidth) / 2;
this.applyButton.Left += (newWidth - oldWidth) / 2;
this.closeButton.Left += (newWidth - oldWidth) / 2;
this.Width += (newWidth - oldWidth);
this.previewerHost.Anchor |= AnchorStyles.Left;
this.Size = new Size(bounds.Width * 5 / 8, bounds.Height * 5 / 8);

int heightDiff = this.Height - this.previewerHost.Height;
int widthDiff = this.Width - this.previewerHost.Width;
int bestHeight = bounds.Height * 5 / 8;
int bestWidth = (bestHeight - heightDiff) * bounds.Width / bounds.Height + widthDiff;
this.Size = new Size(bestWidth, bestHeight);
this.CenterToScreen();
}

Expand Down
38 changes: 14 additions & 24 deletions src/WPF/ThemePreviewer.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1280"
SnapsToDevicePixels="True" UseLayoutRounding="True"
Foreground="White" Background="Gray" BorderBrush="#828790" BorderThickness="1">
Foreground="White" Background="Gray">
<UserControl.Resources>
<FontFamily x:Key="FontAwesome">pack://application:,,,/resources/fonts/fontawesome-webfont.ttf#FontAwesome</FontFamily>
<Style x:Key="CarouselButton" TargetType="{x:Type Button}">
Expand Down Expand Up @@ -50,36 +50,30 @@
<KeyBinding Gesture="Right" Command="{Binding NextCommand}" />
</UserControl.InputBindings>
<Grid>
<Image x:Name="BackImage" Source="{Binding BackImage}" Stretch="UniformToFill" StretchDirection="Both" Focusable="False"
<Image x:Name="BackImage" Source="{Binding BackImage}" Stretch="Fill" StretchDirection="Both" Focusable="False"
RenderOptions.BitmapScalingMode="Fant" />
<Image x:Name="FrontImage" Source="{Binding FrontImage}" Stretch="UniformToFill" StretchDirection="Both" Focusable="False"
<Image x:Name="FrontImage" Source="{Binding FrontImage}" Stretch="Fill" StretchDirection="Both" Focusable="False"
RenderOptions.BitmapScalingMode="Fant" Opacity="0" />

<Grid Visibility="{Binding ControlsVisible}">
<Button HorizontalAlignment="Left" VerticalAlignment="Stretch" Width="80" Command="{Binding PreviousCommand}"
Style="{StaticResource CarouselButton}" Background="Transparent"
Content="&#xf053;" FontSize="20">
<Button.Effect>
<DropShadowEffect ShadowDepth="2" />
</Button.Effect>
Content="&#xf053;" FontSize="20" Cursor="Hand" FocusVisualStyle="{x:Null}">
</Button>
<Button HorizontalAlignment="Right" VerticalAlignment="Stretch" Width="80" Command="{Binding NextCommand}"
Style="{StaticResource CarouselButton}" Background="Transparent"
Content="&#xf054;" FontSize="20">
<Button.Effect>
<DropShadowEffect ShadowDepth="2" />
</Button.Effect>
Content="&#xf054;" FontSize="20" Cursor="Hand" FocusVisualStyle="{x:Null}">
</Button>

<Grid Margin="18" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="200" MinHeight="72">
<Grid HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20">
<Rectangle RadiusX="5" RadiusY="5" Fill="Black" Opacity="0.5"/>
<StackPanel Margin="12">
<TextBlock Text="{Binding Title, FallbackValue='Title'}" FontWeight="Bold" FontSize="20"/>
<StackPanel Margin="10">
<TextBlock Text="{Binding Title, FallbackValue='Title'}" FontWeight="Bold" FontSize="19"/>
<TextBlock Text="{Binding PreviewText, FallbackValue='Preview Text'}" FontSize="16" Margin="0,4,0,0" />
</StackPanel>
</Grid>

<Button HorizontalAlignment="Right" VerticalAlignment="Top" MinWidth="40" MinHeight="40" Margin="18" FontSize="16" Command="{Binding PlayCommand}">
<Button HorizontalAlignment="Right" VerticalAlignment="Top" MinWidth="40" MinHeight="40" Margin="20" FontSize="16" Command="{Binding PlayCommand}">
<Button.Style>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource CarouselButton}">
<Setter Property="Content" Value="&#xf04b;" />
Expand All @@ -92,23 +86,19 @@
</Button.Style>
</Button>

<Grid HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,26" Opacity="0.5" Visibility="{Binding MessageVisible}">
<Rectangle RadiusX="5" RadiusY="5" Fill="Black" />
<TextBlock Text="{Binding Message}" FontSize="14" VerticalAlignment="Center" Margin="8,4,8,4" />
<Grid HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0,0,0,15" Visibility="{Binding MessageVisible}">
<Rectangle RadiusX="5" RadiusY="5" Fill="Black" Opacity="0.5" />
<TextBlock Text="{Binding Message}" FontSize="16" VerticalAlignment="Center" Margin="8,6,8,6" />
</Grid>

<ListBox HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="24"
<ListBox HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="16"
ItemsSource="{Binding Items}" SelectedIndex="{Binding SelectedIndex}" IsSynchronizedWithCurrentItem="True" Visibility="{Binding CarouselIndicatorsVisible}">
<ListBox.Style>
<Style TargetType="{x:Type ListBox}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<StackPanel Orientation="Horizontal" IsItemsHost="True">
<StackPanel.Effect>
<DropShadowEffect ShadowDepth="2" />
</StackPanel.Effect>
</StackPanel>
<StackPanel Orientation="Horizontal" IsItemsHost="True" />
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
6 changes: 5 additions & 1 deletion src/WPF/ThemePreviewer.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using System;
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Media.Animation;
Expand Down
69 changes: 55 additions & 14 deletions src/WPF/ThemePreviewerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
Expand All @@ -19,6 +20,8 @@

namespace WinDynamicDesktop.WPF
{
using ThemeImageData = List<Tuple<int, int>>;

public class ThemePreviewItem
{
public string PreviewText { get; set; }
Expand Down Expand Up @@ -184,7 +187,7 @@ public ThemePreviewerViewModel(Action startAnimation, Action stopAnimation)
this.startAnimation = startAnimation;
this.stopAnimation = stopAnimation;

transitionTimer = new DispatcherTimer
transitionTimer = new DispatcherTimer(DispatcherPriority.Send)
{
Interval = TimeSpan.FromSeconds(TRANSITION_TIME)
};
Expand Down Expand Up @@ -299,31 +302,63 @@ public void PreviewTheme(ThemeConfig theme)
}
}

AddItems(string.Format(_("Previewing {0}"), _("Sunrise")), sunrise, isDownloaded);
AddItems(string.Format(_("Previewing {0}"), _("Day")), day, isDownloaded);
AddItems(string.Format(_("Previewing {0}"), _("Sunset")), sunset, isDownloaded);
AddItems(string.Format(_("Previewing {0}"), _("Night")), night, isDownloaded);
AddItems(_("Sunrise"), sunrise, isDownloaded);
AddItems(_("Day"), day, isDownloaded);
AddItems(_("Sunset"), sunset, isDownloaded);
AddItems(_("Night"), night, isDownloaded);

if (isDownloaded)
{
ThemeImageData imageData = GetThemeImageData(theme);
activeImage = imageData.FindIndex(entry => entry.Item2 == wpState.daySegment4) +
wpState.imageNumber;
}
else
{
activeImage = (Items.Count == 2) ? wpState.daySegment2 : wpState.daySegment4;
}
}
else
{
Author = "Microsoft";
Items.Add(new ThemePreviewItem(string.Empty, ThemeThumbLoader.GetWindowsWallpaper()));
activeImage = 0;
}

if (wpState.daySegment4 >= 1)
Start(activeImage);
}

private ThemeImageData GetThemeImageData(ThemeConfig theme)
{
ThemeImageData imageData = new ThemeImageData();

if (!theme.sunriseImageList.SequenceEqual(theme.dayImageList))
{
activeImage += sunrise?.Length ?? 0;
foreach (int imageId in theme.sunriseImageList)
{
imageData.Add(Tuple.Create(imageId, 0));
}
}
if (wpState.daySegment4 >= 2)

foreach (int imageId in theme.dayImageList)
{
activeImage += day?.Length ?? 0;
imageData.Add(Tuple.Create(imageId, 1));
}
if (wpState.daySegment4 == 3)

if (!theme.sunsetImageList.SequenceEqual(theme.dayImageList))
{
activeImage += sunset?.Length ?? 0;
foreach (int imageId in theme.sunsetImageList)
{
imageData.Add(Tuple.Create(imageId, 2));
}
}

Start(activeImage);
foreach (int imageId in theme.nightImageList)
{
imageData.Add(Tuple.Create(imageId, 3));
}

return imageData;
}

private void Previous()
Expand Down Expand Up @@ -393,15 +428,21 @@ public void Stop()
Items.Clear();
}

private void AddItems(string previewText, string[] items, bool isDownloaded)
private void AddItems(string previewName, string[] items, bool isDownloaded)
{
if (items == null) return;

for (int i = 0; i < items.Length; i++)
{
string previewText = previewName;

if (isDownloaded)
{
previewText += $" ({i + 1}/{items.Length})";
previewText = string.Format(_("Previewing {0} ({1}/{2})"), previewName, i + 1, items.Length);
}
else
{
previewText = string.Format(_("Previewing {0}"), previewName);
}

Items.Add(new ThemePreviewItem(previewText, items[i]));
Expand Down
Binary file modified src/locale/bg.mo
Binary file not shown.
Binary file modified src/locale/bn.mo
Binary file not shown.
Binary file modified src/locale/cs.mo
Binary file not shown.
Binary file modified src/locale/de.mo
Binary file not shown.
Binary file removed src/locale/el.mo
Binary file not shown.
Binary file modified src/locale/es.mo
Binary file not shown.
Binary file modified src/locale/fr.mo
Binary file not shown.
Binary file modified src/locale/hi.mo
Binary file not shown.
Binary file modified src/locale/id.mo
Binary file not shown.
Binary file modified src/locale/it.mo
Binary file not shown.
Binary file modified src/locale/ja.mo
Binary file not shown.
Binary file added src/locale/ko.mo
Binary file not shown.
Binary file modified src/locale/mk.mo
Binary file not shown.
Binary file added src/locale/nl.mo
Binary file not shown.
Binary file modified src/locale/pl.mo
Binary file not shown.
Binary file modified src/locale/pt-br.mo
Binary file not shown.
Binary file modified src/locale/ro.mo
Binary file not shown.
Binary file modified src/locale/ru.mo
Binary file not shown.
Binary file modified src/locale/tr.mo
Binary file not shown.
Binary file modified src/locale/zh-Hans.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion uwp/Package.appxmanifest
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10" IgnorableNamespaces="uap uap3 mp rescap desktop">
<Identity Name="38719TimothyJohnson.WinDynamicDesktop" Publisher="CN=3C822DA5-D64C-40A9-A84A-5502C3EDD8CD" Version="4.2.0.0" />
<Identity Name="38719TimothyJohnson.WinDynamicDesktop" Publisher="CN=3C822DA5-D64C-40A9-A84A-5502C3EDD8CD" Version="4.3.0.0" />
<Properties>
<DisplayName>WinDynamicDesktop</DisplayName>
<PublisherDisplayName>Timothy Johnson</PublisherDisplayName>
Expand Down

0 comments on commit 9e1cca2

Please sign in to comment.