using System;
using System.Collections.Generic;
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;
using ArcGIS.Desktop.Core;
using ArcGIS.Desktop.Internal.Framework.Controls;
using OliviaAddInPro.Helper;

namespace OliviaAddInPro
{
    /// <summary>
    /// Interaction logic for PaneLimpiezaSub1View.xaml
    /// </summary>
    public partial class PaneLimpiezaSub1View : UserControl
    {
        public PaneLimpiezaSub1View()
        {
            InitializeComponent();
        }

        private void ComboBox_DropDownOpened(object sender, EventArgs e)
        {
            
        }

        private void TextBox_velodespl_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            e.Handled = !PanelGlobal.IsValid(((TextBox)sender).Text + e.Text, 1, 100);
        }
        private void TextBox_tiempotto_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            e.Handled = !PanelGlobal.IsValid(((TextBox)sender).Text + e.Text, 1, 100);
        }
        private void txtBox_ancho_via_PreviewTextInput(object sender, TextCompositionEventArgs e)
        {
            e.Handled = !PanelGlobal.IsValid(((TextBox)sender).Text + e.Text, 1, 50);
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            string capa=HelperGdb.OpenFileDialog(HelperGdb.TiposOpenFileDlg.OpenFtrClassLine | HelperGdb.TiposOpenFileDlg.OpenFtrClassPoint);
            if (!string.IsNullOrEmpty(capa))
            {
                label_capalimp.Content = System.IO.Path.GetFileNameWithoutExtension(capa);
                if (DataContext is PaneLimpiezaSub1ViewModel mod)
                {
                    if(!mod.AbiertaCapa(capa))
                        label_capalimp.Content = Resource1.String_selec_capa;
                }
            }
            else
            {
                label_capalimp.Content = Resource1.String_selec_capa;
                if (DataContext is PaneLimpiezaSub1ViewModel mod)
                    mod.AbiertaCapa(null);
            }
        }

        private void comboBox_tto_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int i = -1;
            if (sender is System.Windows.Controls.ComboBox combo)
            { 
                i = combo.SelectedIndex;

                if (DataContext is PaneLimpiezaSub1ViewModel mod)
                {
                    mod.ComboTtoSel(i);
                }
             }   
                
        }

        private void comboBox_ambitos_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int i = -1;
            if (sender is System.Windows.Controls.ComboBox combo)
            {
                i = combo.SelectedIndex;
                if (DataContext is PaneLimpiezaSub1ViewModel mod)
                {
                    mod.ComboAmbSel(i);
                }
            }
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
        }

        private void UserControl_Unloaded(object sender, RoutedEventArgs e)
        {

        }

    }
}
