using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ButcherFactory.BO;

namespace ButcherFactory.Controls
{
    public partial class CodePanel : UserControl
    {
        public CodePanel()
        {
            InitializeComponent();
        }

        public void Add(Control v, bool top = false)
        {

            flowLayoutPanel1.Controls.Add(v);
            if (top)
            {
                flowLayoutPanel1.Controls.SetChildIndex(v, 0);
            }
        }

        internal void RemoveBar(string barCode)
        {
            ColorButton target = null;
            foreach (ColorButton item in flowLayoutPanel1.Controls)
            {
                var tag = (SegmentProduction)item.Tag;
                if (tag.BarCode == barCode)
                {
                    target = item;
                    break;
                }
            }
            if (target != null)
            {
                flowLayoutPanel1.Controls.Remove(target);
            }
        }
    }
}
