diff --git a/App.config b/App.config
index 20ab474..cada091 100644
--- a/App.config
+++ b/App.config
@@ -28,6 +28,12 @@
True
+
+ 0
+
+
+
+
\ No newline at end of file
diff --git a/Assets/conicalGradient.png b/Assets/conicalGradient.png
new file mode 100644
index 0000000..47f92d6
Binary files /dev/null and b/Assets/conicalGradient.png differ
diff --git a/MainWindow.xaml b/MainWindow.xaml
index fa7f6dc..6d7686a 100644
--- a/MainWindow.xaml
+++ b/MainWindow.xaml
@@ -5,31 +5,31 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Closing="MainWindow_Closing"
- Title="MainWindow" Height="384" Width="500" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen">
-
+ Title="MainWindow" Height="400" Width="587" ResizeMode="CanMinimize" WindowStartupLocation="CenterScreen">
+
-
+
+ IsReadOnly="True"
+ HorizontalScrollBarVisibility="Disabled"
+ VerticalScrollBarVisibility="Auto"
+ AcceptsReturn="True"
+ AcceptsTab="True"
+ TextWrapping="Wrap" Margin="376,34,0,0" HorizontalAlignment="Left" Width="88" Height="80" VerticalAlignment="Top" />
+ IsReadOnly="True"
+ HorizontalScrollBarVisibility="Disabled"
+ VerticalScrollBarVisibility="Auto"
+ AcceptsReturn="True"
+ AcceptsTab="True"
+ TextWrapping="Wrap" Margin="480,34,0,0" HorizontalAlignment="Left" Width="88" Height="80" VerticalAlignment="Top" />
-
+
@@ -47,6 +47,14 @@
DisplayMemberPath="NativeName"
SelectedItem="{Binding SelectedLanguage, Mode=TwoWay}"/>
+
+
+
+
+
+
+
+
diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs
index 18c0cb4..3de283b 100644
--- a/MainWindow.xaml.cs
+++ b/MainWindow.xaml.cs
@@ -4,12 +4,19 @@ using WpfMaiTouchEmulator.Managers;
namespace WpfMaiTouchEmulator;
+public enum BorderSetting
+{
+ Disabled,
+ Solid,
+ Rainbow
+}
+
public partial class MainWindow : Window
{
private readonly MaiTouchSensorButtonStateManager buttonState;
private readonly MaiTouchComConnector connector;
private readonly VirtualComPortManager comPortManager;
- private TouchPanel _touchPanel;
+ private TouchPanel? _touchPanel;
public MainWindow()
{
@@ -20,9 +27,12 @@ public partial class MainWindow : Window
IsAutomaticPortConnectingEnabled = Properties.Settings.Default.IsAutomaticPortConnectingEnabled,
IsAutomaticPositioningEnabled = Properties.Settings.Default.IsAutomaticPositioningEnabled,
IsExitWithSinmaiEnabled = Properties.Settings.Default.IsExitWithSinmaiEnabled,
- IsRingButtonEmulationEnabled = Properties.Settings.Default.IsRingButtonEmulationEnabled
+ IsRingButtonEmulationEnabled = Properties.Settings.Default.IsRingButtonEmulationEnabled,
+ BorderColour = Properties.Settings.Default.BorderColour,
};
+ LoadBorderRadioButtonSetting();
+
Title = "Mai Touch Emulator";
buttonState = new MaiTouchSensorButtonStateManager(buttonStateValue);
connector = new MaiTouchComConnector(buttonState, (MainWindowViewModel)DataContext);
@@ -65,14 +75,16 @@ public partial class MainWindow : Window
Loaded += (s, e) => {
+ var dataContext = (MainWindowViewModel)DataContext;
+
Logger.Info("Main window loaded, creating touch panel");
_touchPanel = new TouchPanel();
_touchPanel.onTouch = (value) => { buttonState.PressButton(value); };
_touchPanel.onRelease = (value) => { buttonState.ReleaseButton(value); };
_touchPanel.onInitialReposition = () => { WindowState = WindowState.Minimized; };
+ _touchPanel.SetBorderMode((BorderSetting)Properties.Settings.Default.BorderSetting, dataContext.BorderColour);
_touchPanel.Show();
- var dataContext = (MainWindowViewModel)DataContext;
_touchPanel.DataContext = dataContext;
_touchPanel.SetDebugMode(dataContext.IsDebugEnabled);
@@ -91,7 +103,7 @@ public partial class MainWindow : Window
{
e.Cancel = true;
await connector.Disconnect();
- _touchPanel.Close();
+ _touchPanel?.Close();
Closing -= MainWindow_Closing;
e.Cancel = false;
Application.Current.Shutdown();
@@ -153,7 +165,7 @@ public partial class MainWindow : Window
{
if (dataContext.IsAutomaticPositioningEnabled)
{
- _touchPanel.PositionTouchPanel();
+ _touchPanel?.PositionTouchPanel();
}
await Task.Delay(1000);
@@ -186,7 +198,7 @@ public partial class MainWindow : Window
dataContext.IsDebugEnabled = !enabled;
Properties.Settings.Default.IsDebugEnabled = dataContext.IsDebugEnabled;
Properties.Settings.Default.Save();
- _touchPanel.SetDebugMode(dataContext.IsDebugEnabled);
+ _touchPanel?.SetDebugMode(dataContext.IsDebugEnabled);
}
private void automaticTouchPanelPositioning_Click(object sender, RoutedEventArgs e)
@@ -249,6 +261,55 @@ public partial class MainWindow : Window
dataContext.IsRingButtonEmulationEnabled = !enabled;
Properties.Settings.Default.IsRingButtonEmulationEnabled = dataContext.IsRingButtonEmulationEnabled;
Properties.Settings.Default.Save();
- _touchPanel.SetEmulateRingButton(dataContext.IsRingButtonEmulationEnabled);
+ _touchPanel?.SetEmulateRingButton(dataContext.IsRingButtonEmulationEnabled);
+ }
+
+ private void LoadBorderRadioButtonSetting()
+ {
+ rbBorderDisabled.IsChecked = Properties.Settings.Default.BorderSetting == (int)BorderSetting.Disabled;
+ txtBorderHexColor.IsEnabled = Properties.Settings.Default.BorderSetting == (int)BorderSetting.Solid;
+ rbBorderSolidColour.IsChecked = Properties.Settings.Default.BorderSetting == (int)BorderSetting.Solid;
+ rbBorderRainbow.IsChecked = Properties.Settings.Default.BorderSetting == (int)BorderSetting.Rainbow;
+ }
+
+ private void RadioButton1_Checked(object sender, RoutedEventArgs e)
+ {
+ txtBorderHexColor.IsEnabled = false;
+ Properties.Settings.Default.BorderSetting = (int)BorderSetting.Disabled;
+ Properties.Settings.Default.Save();
+
+ _touchPanel?.SetBorderMode(BorderSetting.Disabled, "");
+ }
+
+ private void RadioButton2_Checked(object sender, RoutedEventArgs e)
+ {
+ txtBorderHexColor.IsEnabled = true;
+ Properties.Settings.Default.BorderSetting = (int)BorderSetting.Solid;
+
+ Properties.Settings.Default.Save();
+
+ _touchPanel?.SetBorderMode(BorderSetting.Solid, Properties.Settings.Default.BorderColour);
+ }
+
+ private void RadioButton3_Checked(object sender, RoutedEventArgs e)
+ {
+ txtBorderHexColor.IsEnabled = false;
+ Properties.Settings.Default.BorderSetting = (int)BorderSetting.Rainbow;
+
+ Properties.Settings.Default.Save();
+
+ _touchPanel?.SetBorderMode(BorderSetting.Rainbow, "");
+ }
+
+ private void txtBorderHexColor_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e)
+ {
+ var textWithoutHash = txtBorderHexColor.Text.TrimStart('#') ?? "";
+ if (textWithoutHash.Length == 6 || textWithoutHash.Length == 8)
+ {
+ var textWithHash = "#" + textWithoutHash;
+ Properties.Settings.Default.BorderColour = textWithHash;
+ Properties.Settings.Default.Save();
+ _touchPanel?.SetBorderMode(BorderSetting.Solid, textWithHash);
+ }
}
}
diff --git a/MainWindowViewModel.cs b/MainWindowViewModel.cs
index 2dbffa7..e6058c6 100644
--- a/MainWindowViewModel.cs
+++ b/MainWindowViewModel.cs
@@ -52,6 +52,22 @@ public class MainWindowViewModel : INotifyPropertyChanged
{
get; set;
}
+ public string LbBorderSettings
+ {
+ get; set;
+ }
+ public string LbBorderDisabled
+ {
+ get; set;
+ }
+ public string LbBorderSolid
+ {
+ get; set;
+ }
+ public string LbBorderRainbow
+ {
+ get; set;
+ }
public string LbListComPorts
{
get; set;
@@ -190,6 +206,7 @@ public class MainWindowViewModel : INotifyPropertyChanged
private bool _isExitWithSinmaiEnabled;
private CultureInfo _selectedLanguage;
private bool _isRingButtonEmulationEnabled;
+ private string _borderColour;
private readonly ResourceManager resourceManager;
private readonly CultureInfo cultureInfo;
@@ -267,7 +284,17 @@ public class MainWindowViewModel : INotifyPropertyChanged
OnPropertyChanged();
}
}
-
+
+ public string BorderColour
+ {
+ get => _borderColour;
+ set
+ {
+ _borderColour = value;
+ OnPropertyChanged();
+ }
+ }
+
public CultureInfo SelectedLanguage
{
@@ -306,6 +333,12 @@ public class MainWindowViewModel : INotifyPropertyChanged
LbEmulateRingButtons = resourceManager.GetString("lbEmulateRingButtons");
LbInstallComPort = resourceManager.GetString("lbInstallComPort");
LbLanguageDropdown = resourceManager.GetString("lbLanguageDropdown");
+
+ LbBorderSettings = resourceManager.GetString("LbBorderSettings");
+ LbBorderDisabled = resourceManager.GetString("LbBorderDisabled");
+ LbBorderSolid = resourceManager.GetString("LbBorderSolid");
+ LbBorderRainbow = resourceManager.GetString("LbBorderRainbow");
+
LbListComPorts = resourceManager.GetString("lbListComPorts");
LbReceivedData = resourceManager.GetString("lbReceivedData");
LbRecievedData = resourceManager.GetString("lbRecievedData");
diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs
index 98e2149..98efe17 100644
--- a/Properties/Settings.Designer.cs
+++ b/Properties/Settings.Designer.cs
@@ -106,5 +106,29 @@ namespace WpfMaiTouchEmulator.Properties {
this["IsRingButtonEmulationEnabled"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public int BorderSetting {
+ get {
+ return ((int)(this["BorderSetting"]));
+ }
+ set {
+ this["BorderSetting"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string BorderColour {
+ get {
+ return ((string)(this["BorderColour"]));
+ }
+ set {
+ this["BorderColour"] = value;
+ }
+ }
}
}
diff --git a/Properties/Settings.settings b/Properties/Settings.settings
index 064ef61..03fb6b6 100644
--- a/Properties/Settings.settings
+++ b/Properties/Settings.settings
@@ -23,5 +23,11 @@
True
+
+ 0
+
+
+
+
\ No newline at end of file
diff --git a/Resources/Strings.Designer.cs b/Resources/Strings.Designer.cs
index 323381b..22125a5 100644
--- a/Resources/Strings.Designer.cs
+++ b/Resources/Strings.Designer.cs
@@ -96,6 +96,42 @@ namespace WpfMaiTouchEmulator.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Disabled.
+ ///
+ internal static string LbBorderDisabled {
+ get {
+ return ResourceManager.GetString("LbBorderDisabled", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Rainbow.
+ ///
+ internal static string LbBorderRainbow {
+ get {
+ return ResourceManager.GetString("LbBorderRainbow", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Border Settings.
+ ///
+ internal static string LbBorderSettings {
+ get {
+ return ResourceManager.GetString("LbBorderSettings", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Solid (#AARRGGBB).
+ ///
+ internal static string LbBorderSolid {
+ get {
+ return ResourceManager.GetString("LbBorderSolid", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Button State.
///
diff --git a/Resources/Strings.ja-JP.resx b/Resources/Strings.ja-JP.resx
index 116a667..850b972 100644
--- a/Resources/Strings.ja-JP.resx
+++ b/Resources/Strings.ja-JP.resx
@@ -129,6 +129,18 @@
Sinmai.exeの上に正しい位置にタッチセンサーウィンドウを自動的に移動しようとする
+
+ 無効
+
+
+ レインボー
+
+
+ 境界線設定
+
+
+ 単色(#AARRGGBB)
+
ボタン状態
diff --git a/Resources/Strings.resx b/Resources/Strings.resx
index 6f97961..7c38ce8 100644
--- a/Resources/Strings.resx
+++ b/Resources/Strings.resx
@@ -129,6 +129,18 @@
Try and automatically move the touch sensor window into the correct position on top of Sinmai.exe
+
+ Disabled
+
+
+ Rainbow
+
+
+ Border Settings
+
+
+ Solid (#AARRGGBB)
+
Button State
diff --git a/Resources/Strings.zh-CN.resx b/Resources/Strings.zh-CN.resx
index 27e69ba..3800ccf 100644
--- a/Resources/Strings.zh-CN.resx
+++ b/Resources/Strings.zh-CN.resx
@@ -129,6 +129,18 @@
尝试自动移动触摸传感器窗口到Sinmai.exe上方的正确位置
+
+ 無効
+
+
+ 彩虹
+
+
+ 境界線設定
+
+
+ 纯色(#AARRGGBB)
+
按钮状态
diff --git a/TouchPanel.xaml b/TouchPanel.xaml
index 4e2fff4..cc8a9fe 100644
--- a/TouchPanel.xaml
+++ b/TouchPanel.xaml
@@ -22,53 +22,57 @@
-
+
diff --git a/TouchPanel.xaml.cs b/TouchPanel.xaml.cs
index 09457db..cfb8f9f 100644
--- a/TouchPanel.xaml.cs
+++ b/TouchPanel.xaml.cs
@@ -2,6 +2,8 @@
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
+using System.Windows.Media.Animation;
+using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WpfMaiTouchEmulator.Managers;
@@ -197,6 +199,47 @@ public partial class TouchPanel : Window
});
}
+ public void SetBorderMode(BorderSetting borderSetting, string borderColour)
+ {
+ if (borderSetting == BorderSetting.Rainbow)
+ {
+ var rotateTransform = new RotateTransform { CenterX = 0.5, CenterY = 0.5 };
+ touchPanelBorder.BorderBrush = new ImageBrush {
+ ImageSource = new BitmapImage(new Uri(@"pack://application:,,,/Assets/conicalGradient.png")),
+ ViewportUnits = BrushMappingMode.RelativeToBoundingBox,
+ Viewport = new Rect(0, 0, 1, 1),
+ TileMode = TileMode.Tile,
+ RelativeTransform = rotateTransform,
+ };
+
+ var animation = new DoubleAnimation
+ {
+ From = 0,
+ To = 360,
+ Duration = new Duration(TimeSpan.FromSeconds(10)),
+ RepeatBehavior = RepeatBehavior.Forever
+ };
+
+ rotateTransform.BeginAnimation(RotateTransform.AngleProperty, animation);
+ return;
+ }
+ else if (borderSetting == BorderSetting.Solid)
+ {
+ try
+ {
+ var colour = (Color)ColorConverter.ConvertFromString(borderColour);
+ touchPanelBorder.BorderBrush = new SolidColorBrush { Color = colour };
+ return;
+
+ }
+ catch (Exception ex)
+ {
+ Logger.Error("Failed to parse solid colour", ex);
+ }
+ }
+ touchPanelBorder.BorderBrush = null;
+ }
+
public void SetEmulateRingButton(bool enabled)
{
isRingButtonEmulationEnabled = enabled;
diff --git a/WpfMaiTouchEmulator.csproj b/WpfMaiTouchEmulator.csproj
index 3fb05a6..4d036b7 100644
--- a/WpfMaiTouchEmulator.csproj
+++ b/WpfMaiTouchEmulator.csproj
@@ -9,6 +9,10 @@
Assets\icon.ico
+
+
+
+
@@ -18,6 +22,12 @@
+
+
+ Never
+
+
+
True