Пример #1
0
 public Auto(string brand, int passengersNum, string bitmapPath, int weight, Wheels wheels) : base(wheels, weight, bitmapPath, passengersNum)
 {
     this.brand = brand;
     autos.Add(this);
 }
Пример #2
0
 public GroundTr(Wheels wheels, int weight, string bitmapPath, int capacity) : base(weight, bitmapPath, capacity)
 {
     this.wheels = wheels;
 }
Пример #3
0
 public Train(string route, string bitmapPath, int passengersNum, int weight, int numCarriage, Wheels wheels) : base(wheels, weight, bitmapPath, passengersNum)
 {
     this.route       = route;
     this.numCarriage = numCarriage;
     trains.Add(this);
 }
Пример #4
0
        private void saveButton_Click(object sender, EventArgs e)
        {
            int   i = 0, weight = 0, carriageNum = 0;
            Train a = new Train();
            int   k = 0;
            float f = 0.0f;

            if (Int32.TryParse(capacityTextBox.Text, out i) && Int32.TryParse(weightTextBox.Text, out weight) &&
                Int32.TryParse(carriageTextBox.Text, out carriageNum))
            {
                List <Transport> t = ProjectContainer.instance.getExistingTransport(a.GetType().Name);
                if (t != null)
                {
                    foreach (Transport tr in t)
                    {
                        if (tr.getTransportName() == routeTextBox.Text)
                        {
                            try
                            {
                                a                 = (Train)tr;
                                a.capacity        = i;
                                a.transportBitmap = (Bitmap)trainPictureBox.Image;
                                a._bitmapPath     = bitmapPath; //TODO bitmapPath <-- пустой
                                a._weight         = weight;
                                a.numCarriage     = carriageNum;
                                if (Int32.TryParse(quantityWheelsTextBox.Text, out k) && (float.TryParse(diameterWheelsTextBox.Text, out f)))
                                {
                                    a.SetWheels(k, f, tireWheelsTextBox.Text);
                                }
                                else
                                {
                                    MessageBox.Show("Incorrect wheels input parameters!!");
                                    return;
                                }
                                ProjectContainer.instance.putNewTransports(a.GetType().Name, a.getList());
                                form.Enabled = true;
                                this.Visible = false;
                                return;
                            }
                            catch (Exception exc)
                            {
                                exc.ToString();
                                MessageBox.Show("The form does not suit!");
                            }
                        }
                    }
                }
                if (Int32.TryParse(quantityWheelsTextBox.Text, out k) && (float.TryParse(diameterWheelsTextBox.Text, out f)))
                {
                    Wheels wheels = new Wheels(k, f, tireWheelsTextBox.Text);
                    a = new Train(routeTextBox.Text, bitmapPath, i, weight, carriageNum, wheels);
                    a.transportBitmap = (Bitmap)trainPictureBox.Image;
                    ProjectContainer.instance.putNewTransports(a.GetType().Name, a.getList());
                    form.Enabled = true;
                    this.Visible = false;
                }
                else
                {
                    MessageBox.Show("Incorrect wheels input parameters!!");
                }
            }
            else
            {
                MessageBox.Show("Incorrect passengers number or weight or number of carriages!");
            }
        }