示例#1
0
 public BaggageAdder(Dictionary <string, int> bc, StorageStation station)
 {
     BaggageCount = new Dictionary <string, int>(bc);
     if (station == null)
     {
         throw new Exception("添加包裹类创建失败!");
     }
     else
     {
         this.station = station;
     }
 }
示例#2
0
        private void Initialize()
        {
            algo                       = new Algorithm(2, new Size(8, 8), 9);
            algo.Rearrange            += Algo_Rearrange;
            algo.DepartureTimeReached += Algo_DepartureTimeReached;
            objects.Add(algo);

            station             = new StorageStation(1.0, Color.Transparent, 490, 10);
            station.BorderStyle = BorderStyle.FixedSingle;
            station.Name        = "station";
            station.ZIndex      = 0;
            station.CanCollect += Station_CanCollect;
            Controls.Add(station);
            objects.Add(station);

            shelf1                  = new Shelf(150, 90, 1, Color.Black);
            shelf1.ZIndex           = 0;
            shelf1.Name             = "shelf1";
            shelf1.BaggageDequeued += Shelf1_BaggageDequeued;
            Controls.Add(shelf1);
            objects.Add(shelf1);

            shelf2                  = new Shelf(520, 90, 1, Color.Black);
            shelf2.ZIndex           = 0;
            shelf2.Name             = "shelf2";
            shelf2.BaggageDequeued += Shelf2_BaggageDequeued;
            Controls.Add(shelf2);
            objects.Add(shelf2);

            inputStackerLeft = new Stacker(1.0, Color.Ivory);
            inputStackerLeft.OriginalLocation    = inputStackerLeft.Location = new Point(shelf1.Location.X + shelf1.Size.Width - inputStackerLeft.Size.Width, shelf1.Top - inputStackerLeft.Size.Height - 10);
            inputStackerLeft.BorderStyle         = BorderStyle.FixedSingle;
            inputStackerLeft.ZIndex              = 2;
            inputStackerLeft.Speed               = Speed;
            inputStackerLeft.Name                = "inputStackerLeft";
            inputStackerLeft.TargetPointReached += InputStackerLeft_TargetPointReached;
            Controls.Add(inputStackerLeft);
            objects.Add(inputStackerLeft);

            inputStackerRight = new Stacker(1.0, Color.Ivory);
            inputStackerRight.OriginalLocation    = inputStackerRight.Location = new Point(shelf2.Location.X, shelf2.Top - inputStackerRight.Size.Height - 10);
            inputStackerRight.BorderStyle         = BorderStyle.FixedSingle;
            inputStackerRight.ZIndex              = 2;
            inputStackerRight.Speed               = Speed;
            inputStackerRight.Name                = "inputStackerRight";
            inputStackerRight.TargetPointReached += InputStackerRight_TargetPointReached;
            Controls.Add(inputStackerRight);
            objects.Add(inputStackerRight);

            outputStackerLeft = new Stacker(1.0, Color.HotPink);
            outputStackerLeft.OriginalLocation      = outputStackerLeft.Location = new Point(shelf1.Location.X + shelf1.Size.Width - outputStackerLeft.Size.Width, shelf1.Top + shelf1.Size.Height + 10);
            outputStackerLeft.BorderStyle           = BorderStyle.FixedSingle;
            outputStackerLeft.ZIndex                = 2;
            outputStackerLeft.Speed                 = Speed;
            outputStackerLeft.Name                  = "outputStackerLeft";
            outputStackerLeft.TargetPointReached   += OutputStackerLeft_TargetPointReached;
            outputStackerLeft.OriginalPointReached += OutputStackerLeft_OriginalPointReached;
            Controls.Add(outputStackerLeft);
            objects.Add(outputStackerLeft);

            outputStackerRight = new Stacker(1.0, Color.HotPink);
            outputStackerRight.OriginalLocation      = outputStackerRight.Location = new Point(shelf2.Location.X, shelf2.Top + shelf2.Size.Height + 10);
            outputStackerRight.BorderStyle           = BorderStyle.FixedSingle;
            outputStackerRight.ZIndex                = 2;
            outputStackerRight.Speed                 = Speed;
            outputStackerRight.Name                  = "outputStackerRight";
            outputStackerRight.TargetPointReached   += OutputStackerRight_TargetPointReached;
            outputStackerRight.OriginalPointReached += OutputStackerRight_OriginalPointReached;
            Controls.Add(outputStackerRight);
            objects.Add(outputStackerRight);

            middleStacker = new Stacker(1.0, Color.Green);
            middleStacker.OriginalLocation    = middleStacker.Location = new Point(outputStackerLeft.Location.X + outputStackerLeft.Size.Width + 10, outputStackerLeft.Location.Y);
            middleStacker.BorderStyle         = BorderStyle.None;
            middleStacker.ZIndex              = 2;
            middleStacker.Speed               = Speed;
            middleStacker.Name                = "middleStacker";
            middleStacker.TargetPointReached += MiddleStacker_TargetPointReached;
            Controls.Add(middleStacker);
            objects.Add(middleStacker);

            leftConveyor                 = new Conveyor(1.0, Color.Ivory, outputStackerLeft.Location.X + 3, outputStackerLeft.Location.Y + outputStackerLeft.Size.Height + 10);
            leftConveyor.ZIndex          = 2;
            leftConveyor.Name            = "leftConveyor";
            leftConveyor.FlightChanged  += LeftConveyor_FlightChanged;
            leftConveyor.CollectBaggage += LeftConveyor_CollectBaggage;
            Controls.Add(leftConveyor);
            objects.Add(leftConveyor);

            rightConveyor                 = new Conveyor(1.0, Color.Ivory, outputStackerRight.Location.X + 3, outputStackerRight.Location.Y + outputStackerRight.Size.Height + 10);
            rightConveyor.ZIndex          = 2;
            rightConveyor.Name            = "leftConveyor";
            rightConveyor.FlightChanged  += RightConveyor_FlightChanged;
            rightConveyor.CollectBaggage += RightConveyor_CollectBaggage;
            Controls.Add(rightConveyor);
            objects.Add(rightConveyor);

            config = new XmlHelper("config.xml");
            LoadConfig();

            baggageAdder = new BaggageAdder(algo.FlightBaggageCount, station);

            SetDisplayOrder();
        }