diff --git a/SoundSwitch/Localization/Factory/Lang/ILang.cs b/SoundSwitch/Localization/Factory/Lang/ILang.cs index a8929e73df..2d3d03090a 100644 --- a/SoundSwitch/Localization/Factory/Lang/ILang.cs +++ b/SoundSwitch/Localization/Factory/Lang/ILang.cs @@ -9,5 +9,10 @@ public interface ILang : IEnumImpl /// Culture info of this language /// CultureInfo CultureInfo { get; } + + /// + /// Is this language read from Right to left + /// + bool IsRightToLeft { get; } } } \ No newline at end of file diff --git a/SoundSwitch/Localization/Factory/Lang/Langs.cs b/SoundSwitch/Localization/Factory/Lang/Langs.cs index a9c6e4e8dd..48ee8d6d53 100644 --- a/SoundSwitch/Localization/Factory/Lang/Langs.cs +++ b/SoundSwitch/Localization/Factory/Lang/Langs.cs @@ -7,6 +7,7 @@ public abstract class BaseLang : ILang public abstract Language TypeEnum { get; } public string Label => CultureInfo.NativeName; public abstract CultureInfo CultureInfo { get; } + public virtual bool IsRightToLeft { get; } } public class EnglishLang : BaseLang @@ -179,6 +180,8 @@ public class HebrewLang : BaseLang public override CultureInfo CultureInfo => CultureInfo.GetCultureInfo("he"); public override Language TypeEnum => Language.Hebrew; + + public override bool IsRightToLeft => true; } public class Czech : BaseLang @@ -208,6 +211,7 @@ public class Arabic : BaseLang public override CultureInfo CultureInfo => CultureInfo.GetCultureInfo("ar"); public override Language TypeEnum => Language.Arabic; + public override bool IsRightToLeft => true; } } \ No newline at end of file diff --git a/SoundSwitch/UI/Component/TrayIcon.cs b/SoundSwitch/UI/Component/TrayIcon.cs index 890628c5d7..df1b4c5cec 100644 --- a/SoundSwitch/UI/Component/TrayIcon.cs +++ b/SoundSwitch/UI/Component/TrayIcon.cs @@ -34,6 +34,7 @@ using SoundSwitch.Framework.Updater; using SoundSwitch.Framework.Updater.Remind; using SoundSwitch.Localization; +using SoundSwitch.Localization.Factory; using SoundSwitch.Model; using SoundSwitch.Properties; using SoundSwitch.UI.Forms; @@ -80,6 +81,11 @@ public sealed class TrayIcon : IDisposable public TrayIcon() { + //Localization + var rightToLeft = new LanguageFactory().Get(AppModel.Instance.Language).IsRightToLeft ? RightToLeft.Yes : RightToLeft.No; + _selectionMenu.RightToLeft = rightToLeft; + _settingsMenu.RightToLeft = rightToLeft; + UpdateIcon(); _showContextMenu = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic); _tooltipInfoManager = new TooltipInfoManager(NotifyIcon); @@ -102,7 +108,7 @@ public TrayIcon() if (e.Button != MouseButtons.Left) return; - if (_updateMenuItem.Tag != null && !_postponeService.ShouldPostpone((Release) _updateMenuItem.Tag)) + if (_updateMenuItem.Tag != null && !_postponeService.ShouldPostpone((Release)_updateMenuItem.Tag)) { OnUpdateClick(sender, e); return; @@ -144,7 +150,7 @@ public void ReplaceIcon(Icon newIcon) return; var oldIcon = NotifyIcon.Icon; - NotifyIcon.Icon = (Icon) newIcon.Clone(); + NotifyIcon.Icon = (Icon)newIcon.Clone(); try { oldIcon?.Dispose(); @@ -199,7 +205,7 @@ private void OnUpdateClick(object sender, EventArgs eventArgs) StopAnimationIconUpdate(); NotifyIcon.BalloonTipClicked -= OnUpdateClick; - _updateDownloadForm.DownloadRelease((Release) _updateMenuItem.Tag); + _updateDownloadForm.DownloadRelease((Release)_updateMenuItem.Tag); } private void SetEventHandlers() @@ -264,7 +270,7 @@ private void StartAnimationIconUpdate() { if (_animationTimer == null) { - _animationTimer = new TimerForm() {Interval = 1000}; + _animationTimer = new TimerForm() { Interval = 1000 }; var tick = 0; _animationTimer.Tick += (sender, args) => { @@ -335,7 +341,7 @@ private void DeviceClicked(object sender, EventArgs e) { try { - var item = (ToolStripDeviceItem) sender; + var item = (ToolStripDeviceItem)sender; AppModel.Instance.SetActiveDevice(item.AudioDevice); } catch (Exception) diff --git a/SoundSwitch/UI/Forms/About.cs b/SoundSwitch/UI/Forms/About.cs index f444619ab9..8a89029f5e 100644 --- a/SoundSwitch/UI/Forms/About.cs +++ b/SoundSwitch/UI/Forms/About.cs @@ -13,9 +13,10 @@ * GNU General Public License for more details. ********************************************************************/ -using System.Diagnostics; using System.Windows.Forms; using SoundSwitch.Localization; +using SoundSwitch.Localization.Factory; +using SoundSwitch.Model; using SoundSwitch.Properties; using SoundSwitch.Util.Url; @@ -27,6 +28,7 @@ public partial class About : Form public About() { + RightToLeft = new LanguageFactory().Get(AppModel.Instance.Language).IsRightToLeft ? RightToLeft.Yes : RightToLeft.No; InitializeComponent(); Icon = helpIcon; } diff --git a/SoundSwitch/UI/Forms/Settings.cs b/SoundSwitch/UI/Forms/Settings.cs index 38846fe3b9..6579277d02 100644 --- a/SoundSwitch/UI/Forms/Settings.cs +++ b/SoundSwitch/UI/Forms/Settings.cs @@ -294,6 +294,7 @@ private void PopulateAudioDevices() private void LocalizeForm() { + RightToLeft = new LanguageFactory().Get(AppModel.Instance.Language).IsRightToLeft ? RightToLeft.Yes : RightToLeft.No; // TabPages playbackTabPage.Text = SettingsStrings.playback; playbackListView.Groups[0].Header = SettingsStrings.selected; diff --git a/SoundSwitch/UI/Forms/UpdateDownloadForm.cs b/SoundSwitch/UI/Forms/UpdateDownloadForm.cs index d202cc51a9..7be6785c14 100644 --- a/SoundSwitch/UI/Forms/UpdateDownloadForm.cs +++ b/SoundSwitch/UI/Forms/UpdateDownloadForm.cs @@ -19,6 +19,8 @@ using SoundSwitch.Framework.Updater.Installer; using SoundSwitch.Framework.Updater.Remind; using SoundSwitch.Localization; +using SoundSwitch.Localization.Factory; +using SoundSwitch.Model; using SoundSwitch.Properties; using SoundSwitch.UI.Component; @@ -32,6 +34,8 @@ public sealed partial class UpdateDownloadForm : Form public UpdateDownloadForm() { + RightToLeft = new LanguageFactory().Get(AppModel.Instance.Language).IsRightToLeft ? RightToLeft.Yes : RightToLeft.No; + InitializeComponent(); Icon = Resources.UpdateIcon; diff --git a/SoundSwitch/UI/Forms/UpsertProfileExtended.cs b/SoundSwitch/UI/Forms/UpsertProfileExtended.cs index e70b95a0f5..ee3b5a784c 100644 --- a/SoundSwitch/UI/Forms/UpsertProfileExtended.cs +++ b/SoundSwitch/UI/Forms/UpsertProfileExtended.cs @@ -8,6 +8,7 @@ using SoundSwitch.Framework.Profile; using SoundSwitch.Framework.Profile.Trigger; using SoundSwitch.Localization; +using SoundSwitch.Localization.Factory; using SoundSwitch.Model; using SoundSwitch.Properties; using SoundSwitch.UI.Component; @@ -25,6 +26,8 @@ public partial class UpsertProfileExtended : Form public UpsertProfileExtended(Profile profile, IEnumerable playbacks, IEnumerable recordings, SettingsForm settingsForm, bool editing = false) { + RightToLeft = new LanguageFactory().Get(AppModel.Instance.Language).IsRightToLeft ? RightToLeft.Yes : RightToLeft.No; + _oldProfile = editing ? profile : null; _profile = editing ? profile.Copy() : profile; _settingsForm = settingsForm;