using C1.WPF;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
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;

namespace InputSamples
{
    /// <summary>
    /// Interaction logic for C1CheckListPage.xaml
    /// </summary>
    public partial class C1CheckListPage : UserControl
    {
        string[] PropertyNames = new string[] {
            "Background", "Foreground", "MouseOverBrush", "SelectionBackground", "ShowCheckBoxes", "ShowSelectAll",
            "SelectAllCaption", "UnSelectAllCaption", "DisplayMemberPath", "SelectedItem", "SelectedItems", "SelectionMode"};

        public C1CheckListPage()
        {
            InitializeComponent();
        }

        public ObservableCollection<Customer> Customers { get { return DataProvider.GetCustomers(); } }
 
        private void OnSelectAllClick(object sender, RoutedEventArgs e)
        {
            CheckList.SelectAll();
        }

        private void OnUnselectAllClick(object sender, RoutedEventArgs e)
        {
            CheckList.UnSelectAll();
        }

        private void OnSelectionChanged(object sender, SelectionChangedEventArgs<int> e)
        {
            List<object> addItems = new List<object>();
            foreach (int index in e.AddedItems)
                addItems.Add(CheckList.Items[index]);
            AddItemsViewer.ItemsSource = addItems;
            List<object> removeItems = new List<object>();
            foreach (int index in e.RemovedItems)
                removeItems.Add(CheckList.Items[index]);
            RemoveItemsViewer.ItemsSource = removeItems;
        }

        private void C1PropertyGrid_AddingPropertyBox(object sender, C1.WPF.Extended.ChangingPropertyBoxEventArgs e)
        {
            if (!PropertyNames.Contains(e.Property.Name))
                e.Cancel = true;
        }
    }
}
