Пример #1
0
 // Constructor.
 public ContainerObject(BayObject _bay, int _row, int _tier)
 {
     this.Name            = generateContainerName(_bay, _row, _tier);
     this.BayObject       = _bay;
     this.Bay             = Convert.ToInt16(_bay.Id);
     this.Row             = _row;
     this.Tier            = _tier;
     this.BayNumberString = _bay.Id;
     this.ContainerType   = (_bay.GetNumber() % 2 == 0) ? ContainerTypes.Big : ContainerTypes.Small;
     this.Visible         = false;
 }
Пример #2
0
 // Generates container index naming.
 private string generateContainerName(BayObject b, int r, int t)
 {
     return(b.Id + r.ToString("D2") + t.ToString("D2"));
 }
Пример #3
0
        public void LoadContainersStructureFromXML(string filename)
        {
            BaysList.Clear();
            ContainerList.Clear();
            XDocument xml = XDocument.Load(filename);

            xml.Descendants("Bay").Select(x => new
            {
                Name              = x.Attribute("Name").Value.ToString(),
                LcgDeck           = Convert.ToDouble(x.Attribute("LcgDeck").Value),
                LcgHold           = Convert.ToDouble(x.Attribute("LcgHold").Value),
                NearLivingQuarter = Convert.ToBoolean(x.Attribute("NearLivingQuarter").Value),
                Stack             = x.Descendants("Stack").Where(s => Convert.ToInt16(s.Attribute("StartTier").Value) >= 80).Select(s => new
                {
                    Row       = Convert.ToInt16(s.Attribute("Row").Value),
                    StartTier = Convert.ToInt16(s.Attribute("StartTier").Value),
                    LastTier  = Convert.ToInt16(s.Attribute("LastTier").Value),
                    Container = s.Descendants("ContainerType").Where(c => Convert.ToDouble(c.Attribute("Length").Value) < 13).Where(c => Convert.ToInt16(c.Attribute("StartTier").Value) >= 80).Select(c => new
                    {
                        Length = Convert.ToDouble(c.Attribute("Length").Value),
                        Width  = Convert.ToDouble(c.Attribute("Width").Value),
                    }).ToList()
                }).ToList(),
            }).ToList().ForEach(x =>
            {
                // Create Bay object.
                BayObject Bay = new BayObject(x.Name, x.LcgDeck, x.LcgHold, x.NearLivingQuarter);

                int currentBayNumber = Convert.ToInt16(x.Name);

                // Get the bays number.
                if (IsOdd(currentBayNumber) && currentBayNumber > this.LastBayNumber)
                {
                    LastBayNumber = currentBayNumber;
                }

                // Loop through all the bay stacks (floor).
                foreach (var tier in x.Stack)
                {
                    // Get the width and the length of the container type.
                    double width  = tier.Container[0].Width;
                    double length = tier.Container[0].Length;
                    if (LastTierNumber < tier.LastTier)
                    {
                        LastTierNumber = tier.LastTier;
                    }
                    // Loop through all the possible tiers.
                    for (var t = tier.StartTier; t <= tier.LastTier; t += 2)
                    {
                        if (Bay.MaxRow < tier.Row)
                        {
                            // Get the rows number.
                            Bay.MaxRow = tier.Row;
                        }
                        // Save the top tier number.
                        if (Bay.MaxTier < tier.LastTier)
                        {
                            Bay.MaxTier = tier.LastTier;
                        }
                        // Create the container as a unit object.
                        ContainerObject Container = new ContainerObject(Bay, tier.Row, t, width, length);
                        // Attach container object to the bay object.
                        Bay.AddContainerToList(Container);
                        // Add the container to the container list of the vessel.
                        this.AddContainerToList(Container);

                        if (LastRowNumber < Bay.MaxRow)
                        {
                            LastRowNumber = Bay.MaxRow;
                        }
                    }
                }
                // Add bay to the vessel.
                this.AddBaysToList(Bay);
            });
        }
Пример #4
0
        // Function to add the container to the list.
        //public void AddContainerToList(ContainerObject _container)
        //{
        //    this.ContainersList.Add(_container);
        //}

        public void AddBaysToList(BayObject _bay)
        {
            this.BaysList.Add(_bay);
        }