private List<Container> unpackHorizontalBlock(List<Container> tempList, HorizontalBlock hBlock)
 {
     foreach (var cont in hBlock.Blocks)
     {
         if (cont is Container)
         {
             tempList.Add(cont);
         }
         // else if (cont is VerticalBlock) { tempList= unpackVerticalBlock(tempList,(VerticalBlock) cont); }
         else
         {
             MessageBox.Show("В процедуру unpackHorizontalBlock передан неизвестный объект");
         }
     }
     return tempList;
 }
        private List<Container> ProcessingChassis(List<Container> tempList, int maxTonnage)
        {
            List<Container> tempRama =
                tempList.Where(s => s.Length > 1500 & s.Width > 6000).OrderBy(s => s.Width).ToList();
            tempList = tempList.Where(s => s.Length <= 1500 | s.Width <= 6000).ToList();
            if (!tempRama.Any())
            {
                return tempList;
            }
            HorizontalBlock hBlock = new HorizontalBlock();
            hBlock.RowCount = 2;
            hBlock.Width = tempRama[0].Width + 800;
            hBlock.Length = 2400;
            //добавляем в подушку ящики размеров 1200х800х800
            List<Container> temp500 = tempList.Where(s => s.Length == 1200 & s.Width == 800 & s.Height == 800).ToList();
            if (temp500.Count() >= 6)
            {
                tempList = tempList.Where(s => s.Length != 1200 | s.Width != 800 | s.Height != 800).ToList();
                foreach (Container c in temp500)
                {
                    if (hBlock.Add(c))
                    {
                        /*продолжаем*/
                    }
                    else
                    {
                        tempList.Add(c);
                    }
                }
            }
            //добавляем в подушку ящики размеров 1100х800х720
            temp500 = tempList.Where(s => s.Length == 1100 & s.Width == 800 & s.Height == 720).ToList();

            if (NotEmpty() | temp500.Count() >= 6)
            {
                tempList = tempList.Where(s => s.Length != 1100 | s.Width != 800 | s.Height != 720).ToList();
                foreach (Container c in temp500)
                {
                    if (!hBlock.Add(c))
                    {
                        tempList.Add(c);
                    }
                }
            }

            VerticalBlock vBlock = new VerticalBlock();
            if (hBlock.NotEmpty() & (vehicle.Mass + hBlock.Mass) <= maxTonnage)
            {
                vBlock.Add(hBlock, vehicle.Height - 250);
            }
            else
            {
                hBlock.ToContainerList(tempList);
            }

            foreach (Container r in tempRama)
            {
                if ((vehicle.Mass + r.Mass) <= maxTonnage)
                {
                    if (vBlock.Add(r, vehicle.Height - 350) == false)
                    {
                        MessageBox.Show("не удалось добавить раму в вертикальный блок.Сообщите администратору");
                        tempList.Add(r);
                    }
                }
            }
            RowBlock rBlock = new RowBlock();
            rBlock.Add(vBlock, vehicle.Width);
            AddRowToVehicle(rBlock);
            return tempList;
        }