Automatically hide main settings window when sensor is repositioned.
parent
2033b5e145
commit
a0cfa9c0c6
|
@ -34,7 +34,7 @@ internal class MaiTouchComConnector(MaiTouchSensorButtonStateManager buttonState
|
||||||
internal set;
|
internal set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task StartTouchSensorPolling()
|
public void StartTouchSensorPolling()
|
||||||
{
|
{
|
||||||
if (!_connected && _shouldReconnect)
|
if (!_connected && _shouldReconnect)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,8 +68,8 @@ public partial class MainWindow : Window
|
||||||
_touchPanel = new TouchPanel();
|
_touchPanel = new TouchPanel();
|
||||||
_touchPanel.onTouch = (value) => { buttonState.PressButton(value); };
|
_touchPanel.onTouch = (value) => { buttonState.PressButton(value); };
|
||||||
_touchPanel.onRelease = (value) => { buttonState.ReleaseButton(value); };
|
_touchPanel.onRelease = (value) => { buttonState.ReleaseButton(value); };
|
||||||
|
_touchPanel.onInitialReposition = () => { WindowState = WindowState.Minimized; };
|
||||||
_touchPanel.Show();
|
_touchPanel.Show();
|
||||||
_touchPanel.Owner = this;
|
|
||||||
|
|
||||||
var dataContext = (MainWindowViewModel)DataContext;
|
var dataContext = (MainWindowViewModel)DataContext;
|
||||||
_touchPanel.DataContext = dataContext;
|
_touchPanel.DataContext = dataContext;
|
||||||
|
@ -90,12 +90,10 @@ public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
e.Cancel = true;
|
e.Cancel = true;
|
||||||
await connector.Disconnect();
|
await connector.Disconnect();
|
||||||
foreach (Window childWindow in OwnedWindows)
|
_touchPanel.Close();
|
||||||
{
|
|
||||||
childWindow.Close();
|
|
||||||
}
|
|
||||||
Closing -= MainWindow_Closing;
|
Closing -= MainWindow_Closing;
|
||||||
e.Cancel = false;
|
e.Cancel = false;
|
||||||
|
Application.Current.Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ExitWithSinmaiLoop()
|
private async void ExitWithSinmaiLoop()
|
||||||
|
@ -168,16 +166,16 @@ public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
if (dataContext.IsAutomaticPortConnectingEnabled)
|
if (dataContext.IsAutomaticPortConnectingEnabled)
|
||||||
{
|
{
|
||||||
await connector.StartTouchSensorPolling();
|
connector.StartTouchSensorPolling();
|
||||||
}
|
}
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async void ConnectToPortButton_Click(object sender, RoutedEventArgs e)
|
private void ConnectToPortButton_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
await connector.StartTouchSensorPolling();
|
connector.StartTouchSensorPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void debugMode_Click(object sender, RoutedEventArgs e)
|
private void debugMode_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
|
@ -12,12 +12,14 @@ public partial class TouchPanel : Window
|
||||||
{
|
{
|
||||||
internal Action<TouchValue>? onTouch;
|
internal Action<TouchValue>? onTouch;
|
||||||
internal Action<TouchValue>? onRelease;
|
internal Action<TouchValue>? onRelease;
|
||||||
|
internal Action? onInitialReposition;
|
||||||
|
|
||||||
private readonly Dictionary<int, Polygon> activeTouches = [];
|
private readonly Dictionary<int, Polygon> activeTouches = [];
|
||||||
private readonly TouchPanelPositionManager _positionManager;
|
private readonly TouchPanelPositionManager _positionManager;
|
||||||
private List<Polygon> buttons = [];
|
private List<Polygon> buttons = [];
|
||||||
private bool isDebugEnabled = Properties.Settings.Default.IsDebugEnabled;
|
private bool isDebugEnabled = Properties.Settings.Default.IsDebugEnabled;
|
||||||
private bool isRingButtonEmulationEnabled = Properties.Settings.Default.IsRingButtonEmulationEnabled;
|
private bool isRingButtonEmulationEnabled = Properties.Settings.Default.IsRingButtonEmulationEnabled;
|
||||||
|
private bool hasRepositioned = false;
|
||||||
|
|
||||||
private enum ResizeDirection
|
private enum ResizeDirection
|
||||||
{
|
{
|
||||||
|
@ -75,6 +77,12 @@ public partial class TouchPanel : Window
|
||||||
Left = position.Value.Left;
|
Left = position.Value.Left;
|
||||||
Width = position.Value.Width;
|
Width = position.Value.Width;
|
||||||
Height = position.Value.Height;
|
Height = position.Value.Height;
|
||||||
|
|
||||||
|
if (!hasRepositioned)
|
||||||
|
{
|
||||||
|
hasRepositioned = true;
|
||||||
|
onInitialReposition?.Invoke();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue