using System;
using System.Collections.Generic;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;

namespace FSI.Lib.Guis.Folder.Mgt
{
    /// <summary>
    /// Interaktionslogik für FrmMain.xaml
    /// </summary>
    public partial class FrmMain : Window
    {

        public ViewModel Folder { get; set; }
        public bool CloseAtLostFocus { get; set; }
        public IEnumerable<IInterface> Data { get; set; }
   
        public FrmMain()
        {
            InitializeComponent();

            Loaded += Main_Loaded;
            Deactivated += FrmMain_Deactivated;            
        }

        private void FrmMain_Deactivated(object sender, System.EventArgs e)
        {
            if (CloseAtLostFocus)
                Visibility = Visibility.Hidden;
        }

        private void Main_Loaded(object sender, RoutedEventArgs e)
        {

            Title = "FSI Ordner-Auswahl";
            Title += " v" + Assembly.GetExecutingAssembly().GetName().Version; // Version in Titel eintragen

            Folder = new ViewModel(new DataProvider())
            {
                InputData  = Data
            };
            DataContext = Folder;

            Folder.Load();
        }

        private void tbSearch_TextChanged(object sender, TextChangedEventArgs e)
        {
            tbSearch.Select(tbSearch.Text.Length, 0);
        }

    }
}
