using System.Collections.Generic;
using BeWo.ServiceProxy;
using System.Windows.Controls;
using BS.Shared.DataContracts;

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


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

            _UnfilteredFLSRootDCs = pFLSAnalysisRootDCs;

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

        public FLSOverviewConfig FLSOverviewConfig { get; set; }

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

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


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

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