private void Button_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            string surnameAndName = StewardName.Text;

            if (surnameAndName != "" && surnameAndName != null && surnameAndName.Contains(" "))
            {
                string[] split                   = surnameAndName.Split(' ');
                string   surname                 = split[0];
                string   name                    = split[1];
                bool     canBeTheManager         = manager.IsChecked ?? false;
                bool     canUseTheControlPanel   = panel.IsChecked ?? false;
                bool     canServeWithAMicrophone = microphone.IsChecked ?? false;
                Steward  steward                 =
                    new Steward(surname, name, canBeTheManager, canUseTheControlPanel, canServeWithAMicrophone);
                steward.saveToFile();
                StewardName.Text     = "";
                manager.IsChecked    = false;
                panel.IsChecked      = false;
                microphone.IsChecked = false;
            }
            else
            {
                MessageBox.Show("Неверный ввод фамилии и имени. Образец: Иванов Иван");
            }
        }
Ejemplo n.º 2
0
 private void SaveButton_Click(object sender, RoutedEventArgs e)
 {
     if (StewardBox.SelectedIndex >= 0)
     {
         string   surnameAndName = StewardBox.Text;
         string[] split          = surnameAndName.Split(' ');
         string   surname        = split[0];
         string   name           = split[1];
         int      index          = StewardBox.SelectedIndex;
         bool     m   = manager.IsChecked ?? false;
         bool     p   = panel.IsChecked ?? false;
         bool     mic = microphone.IsChecked ?? false;
         properties[index, 0] = m;
         properties[index, 1] = p;
         properties[index, 2] = mic;
         Steward temp = new Steward(surname, name, m, p, mic);
         temp.saveToFile();
     }
     else
     {
         manager.IsChecked = panel.IsChecked = microphone.IsChecked = false;
     }
 }
Ejemplo n.º 3
0
 public void UpdateStewards()
 {
     try
     {
         string[] dirs = Directory.GetFiles("Stewards/", "*.cstw");
         if (dirs.Length > 0)
         {
             SaveButton.IsEnabled = true;
         }
         int index = 0;
         properties = new bool[dirs.Length, 3];
         List <ComboData> ListData = new List <ComboData>();
         foreach (string dir in dirs)
         {
             string  surnameAndName = dir.Replace("Stewards/", "").Replace(".cstw", "");
             Steward temp           = new Steward(dir);
             properties[index, 0] = temp.CanBeTheManager;
             properties[index, 1] = temp.CanUseTheControlPanel;
             properties[index, 2] = temp.CanServeWithAMicrophone;
             ListData.Add(new ComboData {
                 Id = index, Value = surnameAndName
             });
             index++;
         }
         StewardBox.ItemsSource       = ListData;
         StewardBox.DisplayMemberPath = "Value";
         StewardBox.SelectedValuePath = "Id";
         StewardBox.SelectedIndex     = 0;
         manager.IsChecked            = properties[0, 0];
         panel.IsChecked      = properties[0, 1];
         microphone.IsChecked = properties[0, 2];
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ошибка: {0}", ex.ToString());
     }
 }