using MahApps.Metro.Controls;
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.Shapes;

namespace ZKuP
{
    /// <summary>
    /// Interaktionslogik für SetHinweis.xaml
    /// </summary>
    public partial class SetHinweis : MetroWindow
    {
        public string Text { get; set; }

        public SetHinweis()
        {
            InitializeComponent();

            Text = SQL.ReadSingleValue($"SELECT Hinweis FROM {MainWindow.table}.misc");
            lblHinweis.Text = Text;
        }

        private async void btnSetHinweis_Click(object sender, RoutedEventArgs e)
        {
            await SQL.WriteSQL($"REPLACE INTO {MainWindow.table}.misc VALUES (1,'{lblHinweis.Text}','{Environment.UserName}')");
            this.Close();
        }

        private async void btnDeleteHinweis_Click(object sender, RoutedEventArgs e)
        {
            await SQL.WriteSQL($"REPLACE INTO {MainWindow.table}.misc VALUES (1,'','{Environment.UserName}')");
            this.Close();
        }

        private void lblHinweis_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter && lblHinweis.LineCount >= 4)
                e.Handled = true;
        }
    }
}
