using System.Windows;
using System.Windows.Controls;
using Zerolauncher.Manager;

namespace Zerolauncher.dialog
{
    /// <summary>
    /// EditTeamControl.xaml 的交互逻辑
    /// </summary>
    public partial class EditTeamControl : UserControl
    {

        bool isEditModle;

        public EditTeamControl(bool isEditModle)
        {
            InitializeComponent();
            this.isEditModle = isEditModle; 
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if(string.IsNullOrEmpty(edit_name.Text))
            {
                MessageBox.Show("昵称不能为空喵!", "提示");
                return;
            }
            if (isEditModle) AccountManager.EditTeamName(edit_name.Text); else TeamManager.AddTeam(edit_name.Text);
            EditTeamDialog.Close();
        }

        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("放生此队伍以及队伍里所有的账号\n为你带来114514点功德\n要执行此操作喵？", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
            if (result == MessageBoxResult.OK)
            {
                if (!AccountManager.DeleteTeam())
                {
                    MessageBox.Show("已经是最后一个队伍了喵！\n新建一个队伍后再放生这个~", "提示");
                }
                else EditTeamDialog.Close();
            }

        }
    }
}
