Пример #1
0
		public LobbyForm(List<CrewSlotConfiguration> crewSlotConfigurations, Nation selectedNation, NationSelectForm nationSelectForm, VehicleType vehicleType = null)
		{
			InitializeComponent();

			_crewSlotConfigurations = crewSlotConfigurations;
			_nationSelectForm = nationSelectForm;

			if(_vehicleType == null && vehicleType != null)
				_vehicleType = vehicleType;

			Rectangle screenBounds = Screen.FromControl(this).Bounds;

			_groupBoxSize = new Size(149, 85);
			_vehicleTypeSize = new Size(138, 32);
			_crewSkillsSize = new Size(138, 32);

			ScreenWidth = screenBounds.Width;
			int offsetFromTopOfScreen = screenBounds.Height - Constants.OffsetFromTheBottomOfTheScreenForTheLobbyFormToStart;

			NationStartingXCoordinate = 198;

			Top = offsetFromTopOfScreen;
			Width = ScreenWidth;

			cbSelectedNation.Items.AddRange(Enum.GetValues(typeof(Nation)).Cast<object>().ToArray());

			SetSelectedNationAndStartingCoordinates(selectedNation);
			PopulateGroupBoxDictionary();

			cbSelectedNation_SelectedIndexChanged(null, null);
		}
		private void SetupElements(NationSelectForm nationSelectForm, Nation selectedNation, int numberOfCrewSlots)
		{
			_nationSelectForm = nationSelectForm;
			_selectedNation = selectedNation;
			_numberOfCrewSlots = numberOfCrewSlots;
			_vehicleType = new VehicleType();	// Crappy default value
			_crewSlotData = Helpers.LoadCrewSlotDataFromFile(CrewSlotDataFileName) ?? new List<CrewSlotData>();	// Load from file, if null is returned, creates a new (empty) list

			if (_crewSlotData.Count < 1) // Happens only when nothing comes from reading the file with data.
			{
				_crewSlotData.Add(new CrewSlotData(_selectedNation));
			}

			#region Setup fields for form controls
			List<string> vehicleNames = Helpers.LoadVehicleDataFromJson(Helpers.GetVehicleJsonDataForNation(_selectedNation)).OrderBy(v => v.VehicleName).Select(v => v.VehicleName).ToList();
			_faytVehicleSource = new AutoCompleteStringCollection();
			_faytVehicleSource.AddRange(vehicleNames.ToArray());

			List<string> vehicleTypes = Helpers.LoadVehicleTypesDataFromJson(Helpers.GetVehicleTypesJsonData()).OrderBy(t => t.VehicleTypeLongName).Select(t => t.VehicleTypeLongName).ToList();
			_faytVehicleTypeSource = new AutoCompleteStringCollection();
			_faytVehicleTypeSource.AddRange(vehicleTypes.ToArray());

			_crewSlotConfigurations = new List<CrewSlotConfiguration>();
			_crewSlotGroupBoxes = new Dictionary<int, GroupBox>();
			_crewNameComboBoxes = new Dictionary<int, ComboBox>();
			_crewTrainedMembersNumericScrollers = new Dictionary<int, NumericUpDown>();
			_crewVehicleTypeComboBoxes = new Dictionary<int, ComboBox>();
			#endregion

			SetFormHeight();
			Helpers.ChangeBackground(this, selectedNation);
			PopulateFormControls();
		}