Skip to content

Commit

Permalink
Add RTL support
Browse files Browse the repository at this point in the history
  • Loading branch information
infinitepower18 committed Feb 14, 2024
1 parent 2351ff9 commit f14db90
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 11 deletions.
6 changes: 6 additions & 0 deletions WSA System Control/About.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.Win32;
using System.Diagnostics;
using System.Globalization;

namespace WSA_System_Control
{
Expand All @@ -8,6 +9,11 @@ public partial class About : Form
public About()
{
InitializeComponent();
if (CultureInfo.CurrentUICulture.Name.StartsWith("ar"))
{
this.RightToLeft = RightToLeft.Yes;
this.RightToLeftLayout = true;
}
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.Icon = new Icon("app.ico");
Expand Down
51 changes: 42 additions & 9 deletions WSA System Control/AppContext.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Dark.Net;
using Microsoft.Win32;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using Windows.ApplicationModel;
Expand Down Expand Up @@ -75,7 +76,10 @@ public AppContext()
contextMenu.Items.Add(updateMenuItem);
}
contextMenu.Items.Add(exitMenuItem);

if (CultureInfo.CurrentUICulture.Name.StartsWith("ar"))
{
contextMenu.RightToLeft = RightToLeft.Yes;
}
notifyIcon.ContextMenuStrip = contextMenu;
notifyIcon.Visible = true;

Expand Down Expand Up @@ -118,12 +122,27 @@ private void Win11WSANotFound()
{
string message = rm.GetString("WSANotInstalledWin11");
string caption = rm.GetString("WSANotInstalled");
var result = MessageBox.Show(message, caption,
if (CultureInfo.CurrentUICulture.Name.StartsWith("ar"))
{
var result = MessageBox.Show(message, caption,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
if (result == DialogResult.OK)
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
if (result == DialogResult.OK)
{
Environment.Exit(0);
}
}
else
{
Environment.Exit(0);
var result = MessageBox.Show(message, caption,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
if (result == DialogResult.OK)
{
Environment.Exit(0);
}
}
}

Expand Down Expand Up @@ -155,12 +174,26 @@ private void Win10WSANotFound()
{
string message = rm.GetString("WSANotInstalledWin10");
string caption = rm.GetString("WSANotInstalled");
var result = MessageBox.Show(message, caption,
if (CultureInfo.CurrentUICulture.Name.StartsWith("ar"))
{
var result = MessageBox.Show(message, caption,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
if (result == DialogResult.OK)
MessageBoxIcon.Error,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
if (result == DialogResult.OK)
{
Environment.Exit(0);
}
} else
{
Environment.Exit(0);
var result = MessageBox.Show(message, caption,
MessageBoxButtons.OK,
MessageBoxIcon.Error);
if (result == DialogResult.OK)
{
Environment.Exit(0);
}
}
}

Expand Down
20 changes: 18 additions & 2 deletions WSA System Control/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;

Expand All @@ -17,10 +18,25 @@ static void Main()
ApplicationConfiguration.Initialize();

ResourceManager rm = new ResourceManager("WSA_System_Control.Resources.Strings", Assembly.GetExecutingAssembly());

if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length > 1)
{
MessageBox.Show(rm.GetString("AlreadyRunning"));
if (CultureInfo.CurrentUICulture.Name.StartsWith("ar"))
{
MessageBox.Show("WSA System Control",
rm.GetString("AlreadyRunning"),
MessageBoxButtons.OK,
MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1,
MessageBoxOptions.RightAlign | MessageBoxOptions.RtlReading);
}
else
{
MessageBox.Show("WSA System Control",
rm.GetString("AlreadyRunning"),
MessageBoxButtons.OK,
MessageBoxIcon.Information,
MessageBoxDefaultButton.Button1);
}
Application.Exit();
}
else
Expand Down

0 comments on commit f14db90

Please sign in to comment.