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

namespace FSI.Lib.Guis.Rdp.Mgt
{
    /// <summary>
    /// Interaktionslogik für FrmMain.xaml
    /// </summary>
    public partial class FrmMain : Window
    {
        public ViewModel Rdps { get; set; }
        public bool CloseAtLostFocus { get; set; }
        public IEnumerable<IInterface> InputData { get; set; }

        public string FrmTitle { get; set; }    

        public string Exe { 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 = FrmTitle + " v" + Assembly.GetExecutingAssembly().GetName().Version; // Version in Titel eintragen

            Rdps = new ViewModel(new DataProvider())
            {
                InputData = InputData,
                Exe = Exe,
            };
            DataContext = Rdps;

            Rdps.Load();
        }

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

    }
}

