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将会为你带来114点功德\n您确定要执行此操作吗？", "提示", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel);
            if (result == MessageBoxResult.OK)
            {
                if (!AccountManager.DeleteTeam()) MessageBox.Show("少爷这已经是最后一个队伍了！\n请新建一个队伍后再放生这个吧~", "提示");
                else EditTeamDialog.Close();
			}

        }
    }
}
