using Remontor.History;
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 FlowContainer : UserControl
    {
        public FlowContainer()
        {
            InitializeComponent();

            HistoryList.Update += UpdateHistory;
            UpdateHistory(HistoryList.Hitem);
        }

        public bool HideBar(BarShow barShow)
        {
            if (barShow == BarShow.ShowHistory)
            {
                this.Visible = true;
            }
            else
            {
                this.Visible = false;
            }

            return this.Visible;
        }

        public void UpdateHistory(List<HistoryItem> items)
        {
            HistoryPanel.SuspendLayout();
            HistoryPanel.Controls.Clear();
            foreach(HistoryItem item in items)
            {
                HistoryControl HistoryItem = new HistoryControl(item);
                HistoryPanel.Controls.Add(HistoryItem);
            }
            HistoryPanel.ResumeLayout();
        }

        private void BtSave_Click(object sender, EventArgs e)
        {
            HistoryList.Clear();
        }
    }
}
