﻿
using MvvmCross.Wpf.Views;
using System.Windows.Input;

namespace OpenLearningPlayer.Forms
{
    public partial class SubtitleEditor : MvxWpfView
    {


        public SubtitleEditor()
        {
            InitializeComponent();
            ((SubtitleEditor_ViewModel_WPF)DataContext).Player.SetHost(VideoHost,App.MainMetroWindow);

            //Messenger.Default.Send(new ContainerUnregister(this));

        }

        private void SubDataGrid_OnPreviewKeyDown(object sender, KeyEventArgs e)
        {

            if (SubDataGrid.CurrentColumn == null) return;
            string ElmName =  DataGridUtil.GetName(SubDataGrid.CurrentColumn);
            if (ElmName == null) return;

            if ((ElmName == "Text" || ElmName == "Text2") && e.Key == Key.Enter && Keyboard.IsKeyDown(Key.LeftAlt))
            {
                SubDataGrid.BeginEdit();
                e.Handled = true;
                return;
            }

            ((SubtitleEditor_ViewModel_WPF)DataContext).SubtitleDataGrid_OnPreviewKeyDown(sender,e);
        }
    }
}


