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 MeterVision.Dlg
{
    /// <summary>
    /// EditNameDlg.xaml 的交互逻辑
    /// </summary>
    public partial class EditNameDlg : Window
    {
        public string NameTitle;
        public string EditName { get; private set; }
        public EditNameDlg(string nameTitle,string editName)
        {
            InitializeComponent();

            NameTitle = nameTitle;
            EditName = editName;
            InitUI();
        }

        private void InitUI()
        {
            this.Title = $"编辑{NameTitle}名称";
            txtTitle.Text = $"请输入{NameTitle}名称：";
            txtName.Text = EditName;
        }

        private void BtnOK_Click(object sender, RoutedEventArgs e)
        {
            string editName = txtName.Text.Trim();
            if (string.IsNullOrWhiteSpace(editName))
            {
                MessageBox.Show($"请输入{NameTitle}名称。", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            EditName = editName;
            DialogResult = true;
            this.Close();
        }

        private void BtnClose_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            this.Close();
        }
        //-------------------------------------------------------------
    }
}
