using DryIoc;
using ImTools;
using PDF_Office.Model.Dialog.HomePageToolsDialogs;
using PDF_Office.ViewModels.Dialog.HomePageToolsDialogs;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows.Controls;
using System.Windows.Input;
using System.Xml.Linq;

namespace PDF_Office.Views.Dialog.HomePageToolsDialogs
{
    /// <summary>
    /// Interaction logic for HomePagePictureToPDFDialogs
    /// </summary>
    public partial class HomePagePictureToPDFDialog : UserControl
    {
        public HomePagePictureToPDFDialog()
        {
            InitializeComponent();
        }

        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;
            ((HomePagePictureToPDFDialogViewModel)this.DataContext).fileNamesView.Clear();
            foreach (var item in list)
            {
                a = (System.Data.DataRowView)item;
                ((HomePagePictureToPDFDialogViewModel)this.DataContext).fileNamesView.Add(lists.IndexOf(a));
            }
            if (((HomePagePictureToPDFDialogViewModel)this.DataContext).fileNamesView.Count > 0)
            {
                ((HomePagePictureToPDFDialogViewModel)this.DataContext).RemoveIsEnable = "True";
            }
            else
            {
                ((HomePagePictureToPDFDialogViewModel)this.DataContext).RemoveIsEnable = "False";
            }

        }

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

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

        private void RadioButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            var radiobutton = sender as RadioButton;
            switch (radiobutton.Name.ToString())
            {
                case "NewFilesRadioButtom":
                    {
                        ((HomePagePictureToPDFDialogViewModel)this.DataContext).pictureToPDFModel.Mode = HomePagePictureToPDFDialogModel.ToPDFFileMode.NewFiles;
                    }
                    break;
                case "OneNewFileNameRadioButtom":
                    {
                        ((HomePagePictureToPDFDialogViewModel)this.DataContext).pictureToPDFModel.Mode = HomePagePictureToPDFDialogModel.ToPDFFileMode.OneNewFile;
                    }
                    break;
                case "SelectFileNameRadioButton":
                    {
                        ((HomePagePictureToPDFDialogViewModel)this.DataContext).pictureToPDFModel.Mode = HomePagePictureToPDFDialogModel.ToPDFFileMode.SelectFileName;
                    }
                    break;
                default:
                    break;

            }
        }

       
    }
}
