Added Slop
This commit is contained in:
46
Views/PartSearchDialog.axaml.cs
Normal file
46
Views/PartSearchDialog.axaml.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using Lagerprogramm.Models;
|
||||
using Lagerprogramm.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Lagerprogramm.Views;
|
||||
|
||||
public partial class PartSearchDialog : Window
|
||||
{
|
||||
public Part? SelectedPart { get; private set; }
|
||||
|
||||
public PartSearchDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
KeyDown += OnKeyDown;
|
||||
}
|
||||
|
||||
public async Task<Part?> ShowPartSearch(IEnumerable<Part> parts, Window parent)
|
||||
{
|
||||
SelectedPart = null;
|
||||
var viewModel = new PartSearchDialogViewModel(parts);
|
||||
DataContext = viewModel;
|
||||
await ShowDialog(parent);
|
||||
return SelectedPart;
|
||||
}
|
||||
|
||||
private void OnDoubleTapped(object? sender, TappedEventArgs e)
|
||||
{
|
||||
if (PartListBox.SelectedItem is Part part)
|
||||
{
|
||||
SelectedPart = part;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnKeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key == Key.Enter && PartListBox.SelectedItem is Part part)
|
||||
{
|
||||
SelectedPart = part;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user