forked from amkovkov/GranuSightSoftware2
feat: implement and move touch controls to separate namespace
This commit is contained in:
@@ -0,0 +1,41 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Input;
|
||||||
|
|
||||||
|
using GSS2.ViewModels;
|
||||||
|
using GSS2.Views;
|
||||||
|
|
||||||
|
namespace GSS2.Controls;
|
||||||
|
|
||||||
|
public class TouchNumericUpDown : NumericUpDown
|
||||||
|
{
|
||||||
|
protected override Type StyleKeyOverride => typeof(NumericUpDown);
|
||||||
|
|
||||||
|
public TouchNumericUpDown()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
AddHandler(PointerPressedEvent, OnPointerPressed, handledEventsToo: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPointerPressed(object? sender, PointerPressedEventArgs ea)
|
||||||
|
{
|
||||||
|
if (ea.Pointer.Type != PointerType.Touch)
|
||||||
|
return;
|
||||||
|
var navigation = (Application.Current as Application)?.Navigation;
|
||||||
|
if (navigation is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var keyboardViewModel = new NumericKeyboardViewModel(navigation);
|
||||||
|
keyboardViewModel.Value = (double?)Value;
|
||||||
|
keyboardViewModel.Closes += (_, ea) =>
|
||||||
|
{
|
||||||
|
if (ea is null)
|
||||||
|
return;
|
||||||
|
Value = (decimal)ea.Value;
|
||||||
|
};
|
||||||
|
var keyboardView = new NumericKeyboardView()
|
||||||
|
{
|
||||||
|
DataContext = keyboardViewModel
|
||||||
|
};
|
||||||
|
navigation.NavigateTo(keyboardView);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Input;
|
||||||
|
|
||||||
|
using GSS2.ViewModels;
|
||||||
|
using GSS2.Views;
|
||||||
|
|
||||||
|
namespace GSS2.Controls;
|
||||||
|
|
||||||
|
public class TouchTextBox : TextBox
|
||||||
|
{
|
||||||
|
protected override Type StyleKeyOverride => typeof(TextBox);
|
||||||
|
|
||||||
|
public TouchTextBox()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
AddHandler(PointerPressedEvent, OnPointerPressed, handledEventsToo: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPointerPressed(object? sender, PointerPressedEventArgs ea)
|
||||||
|
{
|
||||||
|
// if (ea.Pointer.Type != PointerType.Touch)
|
||||||
|
// return;
|
||||||
|
var navigation = (Application.Current as Application)?.Navigation;
|
||||||
|
if (navigation is null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var keyboardViewModel = new TextKeyboardViewModel(navigation);
|
||||||
|
keyboardViewModel.Value = Text;
|
||||||
|
keyboardViewModel.IsMultiline = AcceptsReturn;
|
||||||
|
keyboardViewModel.Closes += (_, ea) =>
|
||||||
|
{
|
||||||
|
if (ea is null)
|
||||||
|
return;
|
||||||
|
Text = ea;
|
||||||
|
};
|
||||||
|
var keyboardView = new TextKeyboardView()
|
||||||
|
{
|
||||||
|
DataContext = keyboardViewModel
|
||||||
|
};
|
||||||
|
navigation.NavigateTo(keyboardView);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Input;
|
|
||||||
|
|
||||||
namespace GSS2;
|
|
||||||
|
|
||||||
public class TouchNumericUpDown : NumericUpDown
|
|
||||||
{
|
|
||||||
protected override Type StyleKeyOverride => typeof(NumericUpDown);
|
|
||||||
|
|
||||||
public TouchNumericUpDown()
|
|
||||||
: base()
|
|
||||||
{
|
|
||||||
AddHandler(PointerPressedEvent, OnPointerPressed, handledEventsToo: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnPointerPressed(object? sender, PointerPressedEventArgs ea)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"TODO: process TouchNumericUpDown.PointerPressed event");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Input;
|
|
||||||
|
|
||||||
namespace GSS2;
|
|
||||||
|
|
||||||
public class TouchTextBox : TextBox
|
|
||||||
{
|
|
||||||
protected override Type StyleKeyOverride => typeof(TextBox);
|
|
||||||
|
|
||||||
public TouchTextBox()
|
|
||||||
: base()
|
|
||||||
{
|
|
||||||
AddHandler(PointerPressedEvent, OnPointerPressed, handledEventsToo: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnPointerPressed(object? sender, PointerPressedEventArgs ea)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"TODO: process TouchTextBox.PointerPressed event");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user