public UC_ListAllocation(ExtBindingList <Ploeg> BindingSourceList, int NrOfOuutputLists = 2)
     : this()
 {
     _NrOfOutputLists   = NrOfOuutputLists;
     _BindingSourceList = BindingSourceList;
     //this creates a copy !!!! - bindig removed
     _inputlist = new ExtBindingList <Ploeg>(_BindingSourceList.ToList());
 }
Example #2
0
        /*void ploeglist_ListChanged(object sender, ListChangedEventArgs e)
         * {
         *
         *  if (e.ListChangedType == ListChangedType.ItemChanged)
         *  {
         *      ReeksAssignment reeks = _reeksAssignmentlist.Where(x => x.Category.Categorynaam == _ploeglist[e.NewIndex].Category.Categorynaam).First();
         *      reeks.AangemeldePloegen = _ploeglist.Where(x => x.Category.Categorynaam == reeks.Category.Categorynaam).Where(x => x.Aangemeld == true).Count();
         *      reeks.AantalPloegen = _ploeglist.Where(x => x.Category.Categorynaam == reeks.Category.Categorynaam).Count();
         *
         *      UC_ListAllocation _UC_ListAllocation = List_UC_ListAllocation.Where(x => x.Name == reeks.Category.Categorynaam).First();
         *
         *      if (_ploeglist[e.NewIndex].Aangemeld)
         *      {
         *          _UC_ListAllocation.InputList.Add(_ploeglist[e.NewIndex]);
         *      }
         *      else
         *      {
         *          if (_UC_ListAllocation.InputList.Contains (_ploeglist[e.NewIndex]))
         *          {
         *              _UC_ListAllocation.InputList.Remove (_ploeglist[e.NewIndex]);
         *          }
         *          else
         *          {
         *              foreach (BindingList<Ploeg> output in _UC_ListAllocation.Outputlist)
         *              {
         *                  if (output.Contains(_ploeglist[e.NewIndex]))
         *                  {
         *                      output.Remove(_ploeglist[e.NewIndex]);
         *                  }
         *              }
         *          }
         *      }
         *  }
         * }*/

        private void CreateOverview()
        {
            try
            {
                foreach (Category cat in Category.Categories)
                {
                    _reeksAssignmentlist.Add(new ReeksAssignment()
                    {
                        Category          = cat,
                        AantalPloegen     = _ploeglist.Where(x => x.Category.Categorynaam == cat.Categorynaam).Count(),
                        AangemeldePloegen = _ploeglist.Where(x => x.Category.Categorynaam == cat.Categorynaam).Where(x => x.Aangemeld == true).Count(),
                    });

                    ExtBindingList <Ploeg> PloegList = new ExtBindingList <Ploeg>(_ploeglist.Where(x => x.Category.Categorynaam == cat.Categorynaam).Where(x => x.Aangemeld == true).ToList())
                    {
                        Name = _reeksAssignmentlist.Last <ReeksAssignment>().Category.Categorynaam
                    };

                    SortedDictionary <string, int> _differentSeries = new SortedDictionary <string, int>();

                    foreach (Ploeg pl in PloegList.ToList())
                    {
                        if (pl.Reeksnaam == null)
                        {
                            pl.Reeksnaam = "";
                        }

                        if (pl.Reeksnaam != "")
                        {
                            if (_differentSeries.ContainsKey(pl.Reeksnaam))
                            {
                                _differentSeries[pl.Reeksnaam]++;
                            }
                            else
                            {
                                _differentSeries.Add(pl.Reeksnaam, 1);
                            }
                        }
                    }
                    _differentSeries.OrderBy(key => key.Key);
                    _reeksAssignmentlist.Last <ReeksAssignment>().NrOfReeksen = _differentSeries.Count();
                    //populate the control list to keep the current states*/
                    List_UC_ListAllocation.Add(new UC_ListAllocation(PloegList)
                    {
                        Name = PloegList.Name
                    });
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }