MainWindow.xaml.cs 1.36 KB
Newer Older
M1888's avatar
M1888 committed
1 2
using System;
using System.Collections.Generic;
M1888's avatar
10.4.  
M1888 committed
3
using System.Collections.Specialized;
M1888's avatar
M1888 committed
4 5 6 7 8 9 10 11 12 13 14 15
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;
M1888's avatar
10.4.  
M1888 committed
16
using Lottokone.Model;
M1888's avatar
M1888 committed
17 18 19 20 21 22 23 24

namespace Lottokone
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
M1888's avatar
10.4.  
M1888 committed
25 26

        private Lotto kone;
M1888's avatar
M1888 committed
27 28 29
        public MainWindow()
        {
            InitializeComponent();
M1888's avatar
10.4.  
M1888 committed
30 31 32 33 34 35 36 37 38
            kone = new Lotto();
            spLotto.DataContext = kone;
            lstStatus.ItemsSource = kone.StatusHistory;
            ((INotifyCollectionChanged)lstStatus.Items).CollectionChanged += lstStatus_CollectionChanged;
        }

        private void btnNext_Click(object sender, RoutedEventArgs e)
        {
            kone.Tick();
M1888's avatar
M1888 committed
39
        }
M1888's avatar
10.4.  
M1888 committed
40 41 42 43 44 45 46 47 48 49

        private void lstStatus_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                // scroll the new item into view
                lstStatus.ScrollIntoView(e.NewItems[0]);
            }
        }

M1888's avatar
M1888 committed
50 51
    }
}