コード例 #1
0
        public MainWindow()
        {
            InitializeComponent();

            Helicopter helicopter1 = new Helicopter($"Jonny", "Boeing", new Coords(100, 100), 4800, true);
            Helicopter helicopter2 = new Helicopter($"Sunny", "Lockheed", new Coords(0, 0), 6100, false);
            Helicopter helicopter3 = new Helicopter($"Will", "Apache", new Coords(900, 300), 3902, true);
            Helicopter helicopter4 = new Helicopter(helicopter1)
            {
                Name = "April"
            };
            Helicopter helicopter5 = new Helicopter(helicopter2)
            {
                Name = "Mary"
            };
            Helicopter helicopter6 = new Helicopter(helicopter1)
            {
                Name = "Moon"
            };

            helicoptersList.Add(helicopter1);
            helicoptersList.Add(helicopter2);
            helicoptersList.Add(helicopter3);
            helicoptersList.Add(helicopter4);
            helicoptersList.Add(helicopter5);
            helicoptersList.Add(helicopter6);

            EnterField_Helicopters_List.ItemsSource = helicoptersList;
        }
コード例 #2
0
 public Helicopter(Helicopter helicopter)                                   // Copy Constructor
 {
     this.Name     = helicopter.Name;
     this.Model    = helicopter.Model;
     this.Position = helicopter.Position;
     this.Weight   = helicopter.Weight;
     this.Armed    = helicopter.Armed;
 }
コード例 #3
0
 public AddHelicopterWindow(Helicopter h)
 {
     InitializeComponent();
     Helicopter  = h;
     DataContext = Helicopter;
 }
コード例 #4
0
        private bool TryCreateHelicopter(out Helicopter helicopter)

        {
            helicopter = null;

            string tempName = "";

            if (EnterField_Name.Text.Length > 0)
            {
                tempName = EnterField_Name.Text;
            }
            else
            {
                MessageBox.Show(
                    "Enter NAME please",
                    "       ~~~~  Warning Message ~~~~~",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
                return(false);
            }

            string tempModel = "";

            if (EnterField_Model.Text.Length > 0)
            {
                tempModel = EnterField_Model.Text;
            }
            else
            {
                MessageBox.Show(
                    "Enter MODEL please",
                    "       ~~~~  Warning Message ~~~~~",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
                return(false);
            }

            int tempLatitude = 0;

            if ((Int32.TryParse(EnterField_Latitude.Text, out tempLatitude)) != true)
            {
                MessageBox.Show(
                    "As Position is avaliable to enter only numbers",
                    "       ~~~~  Warning Message ~~~~~",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
                return(false);
            }

            int tempLongitude = 0;

            if ((Int32.TryParse(EnterField_Longitude.Text, out tempLongitude)) != true)
            {
                MessageBox.Show(
                    "As Position is avaliable to enter only numbers",
                    "       ~~~~  Warning Message ~~~~~",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
                return(false);
            }

            int tempWeight = 0;

            if (Int32.TryParse(EnterField_Weight.Text, out tempWeight) == true)
            {
                if (tempWeight < 100 && tempWeight > 20000)
                {
                    MessageBox.Show(
                        "Weight have to be in range between 100 and 20000",
                        "       ~~~~  Warning Message ~~~~~",
                        MessageBoxButton.OK,
                        MessageBoxImage.Warning);
                    return(false);
                }
            }
            else
            {
                MessageBox.Show(
                    "Weight have to consist from numbers",
                    "       ~~~~  Warning Message ~~~~~",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
                return(false);
            }

            if (RadioButton_Armed_No.IsChecked == RadioButton_Armed_Yes.IsChecked)
            {
                MessageBox.Show(
                    "Choose Armed flag.",
                    "       ~~~~  Warning Message ~~~~~",
                    MessageBoxButton.OK,
                    MessageBoxImage.Warning);
                return(false);
            }


            helicopter = new Helicopter();

            helicopter.Name               = tempName;
            helicopter.Model              = tempModel;
            helicopter.Position.Latitude  = tempLatitude;
            helicopter.Position.Longitude = tempLongitude;
            helicopter.Weight             = tempWeight;

            if (RadioButton_Armed_Yes.IsChecked == true)
            {
                helicopter.Armed = true;
            }

            else
            {
                helicopter.Armed = false;
            }

            EnterField_Name.Text      = "";
            EnterField_Model.Text     = "";
            EnterField_Latitude.Text  = "";
            EnterField_Longitude.Text = "";
            EnterField_Weight.Text    = "";

            RadioButton_Armed_Yes.IsChecked = false;
            RadioButton_Armed_No.IsChecked  = false;


            return(true);
        }