aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Catalogs/Views/CatalogView.xaml.cs
blob: 4ba37416d88267035d638c2849c27cef1c0231ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Tango.MachineStudio.Catalogs.ViewModels;

namespace Tango.MachineStudio.Catalogs.Views
{
    /// <summary>
    /// Interaction logic for CatalogsView.xaml
    /// </summary>
    public partial class CatalogView : UserControl
    {
        private MainViewVM _vm;

        public CatalogView()
        {
            InitializeComponent();
            Loaded += (_, __) => _vm = DataContext as MainViewVM;
        }

        private void OnGroupsGrid_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete && gridGroups.SelectedItem != null)
            {
                _vm.OnGroupDeleted(gridGroups.SelectedItem as BL.Entities.ColorCatalogsGroup);
                e.Handled = true;
            }
        }

        private void OnItemsGrid_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete && gridItems.SelectedItem != null)
            {
                _vm.OnItemDeleted(gridItems.SelectedItem as BL.Entities.ColorCatalogsItem);
                e.Handled = true;
            }
        }

        private void OnRecipesGrid_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Delete && gridRecipes.SelectedItem != null)
            {
                _vm.OnRecipeDeleted(gridRecipes.SelectedItem as BL.Entities.ColorCatalogsItemsRecipe);
                e.Handled = true;
            }
        }
    }
}