using Remontor.Connector;
using Remontor.Picter;
using Remontor.Seacher;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Remontor
{
    internal partial class BarButtonControl : UserControl
    {
        Connect connect = null;
        Color Background;
        public BarButtonControl()
        {
            InitializeComponent();
        }
        public BarButtonControl(Connect connect, bool backColor)
        {
            InitializeComponent();
            if(backColor) this.BackColor = Color.Gainsboro;
            this.connect = connect;
            NameBtn.Text = connect.toString();
            this.Width = NameBtn.Width + 72;
            Background = this.BackColor;
            connect.Update += UpdateAct;

            SPicManager.PictureSet(PbPerson, connect.GetComp);
        }

        private void UpdateAct()
        {
            if (connect.ActiveOn)
            {
                this.BackColor = SystemColors.ActiveCaption;
            }
            else
            {
                this.BackColor = Background;
            }
        }

     
        private void NameBtn_Click(object sender, EventArgs e)
        {
            SConnector.Activ(connect);
        }

        private void CloseBtn_Click(object sender, EventArgs e)
        {
           
            connect.Delete();
        }
    }
}
