aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs
blob: c3eca4c762d066620f5130a4e9dced8a08894095 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
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.BL;
using Tango.BL.Catalogs;
using Tango.Core;
using Tango.Core.Commands;
using Tango.DragAndDrop;
using Tango.SharedUI;

namespace Tango.UITests
{
    public class VM : ViewModel
    {
        public List<String> Names { get; set; }

        private String _email;
        public String Email
        {
            get { return _email; }
            set { _email = value; RaisePropertyChangedAuto(); }
        }

        private String _password;

        public String Password
        {
            get { return _password; }
            set { _password = value; RaisePropertyChangedAuto(); }
        }

        public RelayCommand LoginCommand { get; set; }

        public VM()
        {
            LoginCommand = new RelayCommand(Login);

            Names = new List<string>();

            for (int i = 0; i < 100; i++)
            {
                Names.Add("ITEM " + (i + 1).ToString());
            }
        }

        private void Login()
        {
            Validate();
        }

        protected override void OnValidating()
        {
            base.OnValidating();

            if (Email == "1234")
            {
                InsertError(nameof(Email), "This email is not good");
            }
        }
    }

    public class Person : ExtendedObject
    {
        public String FirstName { get; set; }
        public String LastName { get; set; }
        private int _index;

        public int Index
        {
            get { return _index; }
            set { _index = value; RaisePropertyChangedAuto(); }
        }

        public int Age { get; set; }

        public override string ToString()
        {
            return FirstName;
        }
    }

    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {


        public ObservableCollection<Person> Persons
        {
            get { return (ObservableCollection<Person>)GetValue(PersonsProperty); }
            set { SetValue(PersonsProperty, value); }
        }
        public static readonly DependencyProperty PersonsProperty =
            DependencyProperty.Register("Persons", typeof(ObservableCollection<Person>), typeof(MainWindow), new PropertyMetadata(null));


        public RelayCommand<DropEventArgs> DropCommand { get; set; }

        public int Value
        {
            get { return (int)GetValue(ValueProperty); }
            set { SetValue(ValueProperty, value); }
        }
        public static readonly DependencyProperty ValueProperty =
            DependencyProperty.Register("Value", typeof(int), typeof(MainWindow), new PropertyMetadata(0));

        public MainWindow()
        {
            Persons = new ObservableCollection<Person>();

            for (int i = 1; i < 10; i++)
            {
                Persons.Add(new Person()
                {
                    Age = i,
                    FirstName = i.ToString() + " Roy",
                    LastName = "Ben Shabat " + i.ToString(),
                    Index = i,
                });
            }

            DropCommand = new RelayCommand<DropEventArgs>(OnDrop);

            Value = 10;

            InitializeComponent();

            //DataContext = new VM();
        }

        private void OnDrop(DropEventArgs e)
        {
            var dragPerson = (e.Draggable as FrameworkElement).DataContext as Person;
            var dropPerson = (e.Droppable as FrameworkElement).DataContext as Person;

            Debug.WriteLine(dragPerson.FirstName + " dropped on " + dropPerson.FirstName);

            int dragIndex = dragPerson.Index;
            dragPerson.Index = dropPerson.Index;
            dropPerson.Index = dragIndex;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Done");
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Persons.Add(new Person()
            {
                FirstName = "New",
                LastName = "Person",
                Age = 200,
                Index = 0
            });
        }

        private void TouchButton_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show("Clicked");
        }
    }
}