using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Navigation;

namespace VideoDistanc.Views
{
    public partial class SettingList : Page
    {

        private ChangeServiceReference.ChangeServiceClient changeSlide;

        public SettingList()
        {
            InitializeComponent();
           this.changeSlide.SuscribeAsync("slide");
        }

        //metoda odesilajici nazvy obrazkoveho souboru uzivatelum
        public void SendImage()
        {
            string s = listBox1.SelectedItem.ToString();
            this.changeSlide.PublishAsync(s);
        }

        // Executes when the user navigates to this page.
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
        }

        private void imageListDomainDataSource_LoadedData(object sender, LoadedDataEventArgs e)
        {

            if (e.HasError)
            {
                System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK);
                e.MarkErrorAsHandled();
            }
        }

        private void chatListDomainDataSource_LoadedData(object sender, LoadedDataEventArgs e)
        {

            if (e.HasError)
            {
                System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK);
                e.MarkErrorAsHandled();
            }
        }

        private void listBox1_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SendImage();
        }

        private void chatListDomainDataSource_LoadedData_1(object sender, LoadedDataEventArgs e)
        {

            if (e.HasError)
            {
                System.Windows.MessageBox.Show(e.Error.ToString(), "Load Error", System.Windows.MessageBoxButton.OK);
                e.MarkErrorAsHandled();
            }
        }

        private void btnActual_Click(object sender, RoutedEventArgs e)
        {
            chatListDomainDataSource.SubmitChanges();
        }

    }
}
