using System.Collections.Generic;
using System.Windows.Controls;

using BS.Shared.DataContracts;

namespace BeWo.View.Report.FLSReport
{
    public partial class FLSOverview : BeWoView
    {
        private readonly List<FLSAnalysisRootDC> _UnfilteredFLSRootDCs;

        public FLSOverview(List<FLSAnalysisRootDC> pFLSAnalysisRootDCs, FLSOverviewConfig config)
        {
            this.InitializeComponent();
            this.FLSOverviewConfig = config;

            this._UnfilteredFLSRootDCs = pFLSAnalysisRootDCs;

            this.FLSOverviewRows = FLSOverviewGenerator.CreateFLSOverviewRows(pFLSAnalysisRootDCs, config);
            this.DataContext = this.FLSOverviewRows;
        }

        public FLSOverviewConfig FLSOverviewConfig { get; set; }

        public List<FLSOverviewRow> FLSOverviewRows { get; set; }

        public ListView ListView
        {
            get
            {
                return this.listview_list;
            }
        }

        public void RefreshReport(FLSOverviewConfig config)
        {
            this.FLSOverviewConfig = config;
            this.FLSOverviewRows = FLSOverviewGenerator.CreateFLSOverviewRows(this._UnfilteredFLSRootDCs, config);

            this.DataContext = this.FLSOverviewRows;
        }

        private void listview_list_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (this.listview_list.SelectedItem != null)
            {
                (this.listview_list.ItemContainerGenerator.ContainerFromItem(this.listview_list.SelectedItem) as ListViewItem).IsSelected = false;
            }
        }
    }
}