コード例 #1
0
        private void PlanButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (Sys == null)
            {
                Sys = SystemObject.CreateSystem(CanvasMap);
                DataGridWaiting.ItemsSource = Sys.FlightsWaitingList;
                DataGrid.ItemsSource        = Sys.AllFlightsList;
                MenuItemAddRandom.IsEnabled = true;
                MenuItemStart.IsEnabled     = false;
                MenuItemStop.IsEnabled      = true;
                MenuItemPause.IsEnabled     = true;
            }
            int seconds = 0;

            Int32.TryParse(SecondsTextBox.Text, out seconds);
            if (seconds == 0)
            {
                MessageBox.Show("Podaj poprawne sekundy (dodatnia liczba całkowita)");
            }
            else
            {
                foreach (string name in Enum.GetNames(typeof(AircraftType)))
                {
                    if (name == AircraftTypeCoomboBox.SelectedValue.ToString())
                    {
                        Sys.GenerateRandomWaitingFlight((AircraftType)Enum.Parse(typeof(AircraftType), name), DateTime.Now.AddSeconds(seconds).ToString("h:mm:ss"));
                    }
                }
            }
        }
コード例 #2
0
 private void MenuItem_Start_OnClick(object sender, RoutedEventArgs e)
 {
     Sys = SystemObject.CreateSystem(CanvasMap);
     //DataGrid.SetBinding(DataGrid.ItemsSourceProperty, new Binding("Flights")
     //{
     //    Source = Sys.AllFlightsList,
     //    Mode = BindingMode.TwoWay
     //});
     DataGridWaiting.ItemsSource = Sys.FlightsWaitingList;
     DataGrid.ItemsSource        = Sys.AllFlightsList;
     MenuItemAddRandom.IsEnabled = true;
     MenuItemStart.IsEnabled     = false;
     MenuItemStop.IsEnabled      = true;
     MenuItemPause.IsEnabled     = true;
 }
コード例 #3
0
 // pseudo constructor - publicly visuble static method
 // used to create instace of this class unless any instance
 // was previously created
 public static SystemObject CreateSystem(Canvas c)
 {
     // if there isn't any existing instance of this class, create it
     return(_sys ?? (_sys = new SystemObject(c)));
     // and return
 }