using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing;
using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter;
using Prism.Ioc;
using Prism.Regions;
using System.Collections;
using System.Windows.Controls;

namespace PDF_Office.Views.Dialog.HomePageToolsDialogs.HomePageBatchProcessing.HomePageConverter
{
    /// <summary>
    /// Interaction logic for HomePageConverterDialog
    /// </summary>
    public partial class HomePageConverterDialog : UserControl
    {
        private IContainerProvider containerProvider;
        public HomePageConverterDialog(IContainerProvider containerProvider)
        {
            InitializeComponent();
            this.containerProvider = containerProvider;
            var regionManager = containerProvider.Resolve<IRegionManager>();
            RegionManager.SetRegionManager(this, regionManager);
            RegionManager.UpdateRegions();
        }
        private void Menu_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            menuPop1.IsOpen = true;
        }

        private void listView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            IList list = listView.SelectedItems;
            var lists = listView.Items;
            System.Data.DataRowView a;
            ((HomePageConverterDialogViewModel)this.DataContext).fileNamesView.Clear();
            foreach (var item in list)
            {
                a = (System.Data.DataRowView)item;
                ((HomePageConverterDialogViewModel)this.DataContext).fileNamesView.Add(lists.IndexOf(a));
            }
            if (((HomePageConverterDialogViewModel)this.DataContext).fileNamesView.Count > 0)
            {
                ((HomePageConverterDialogViewModel)this.DataContext).RemoveIsEnable = "True";
            }
            else
            {
                ((HomePageConverterDialogViewModel)this.DataContext).RemoveIsEnable = "False";
            }

        }

        private void RemoveFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            ((HomePageConverterDialogViewModel)this.DataContext).removepdffile();
        }

        private void OpenFileMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            ((HomePageConverterDialogViewModel)this.DataContext).openfiledialog();
        }

        private void ConverterTypeComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ((HomePageConverterDialogViewModel)this.DataContext).ChangeConverter(ConverterTypeComboBox.SelectedIndex);
        }
    }
}
