/// <summary> /// Adds system to equipage. If editing component, removes old component and adds edited component. /// </summary> public void ApplySystem() { bool exception = false; ObservableCollection <AFSLSystem> tempSystem = this.componentTracker.Systems; try { AFSLSystem newSys = new AFSLSystem(this.name, this.description, wingType: this.wingType); this.manager.AcquireEquipage().AddSystem(newSys); this.componentTracker.UpdateSystemDisplay(); } catch (System.Exception ex) { exception = true; MessageBox.Show(ex.Message, "Add System", MessageBoxButton.OK, MessageBoxImage.Warning); } if (exception == false) { if (this.componentTracker.IsInEditMode) { tempSystem.Remove(this.componentTracker.SelectedSystem); this.manager.AcquireEquipage().RemoveSystem(this.componentTracker.SelectedSystem.Name); } tempSystem.Add(this.system); this.clearFields(); componentTracker.AddSystemWindow.Close(); } }
/// <summary> /// Initialize and instantiate private fields that are not controllers, commands, or error token (these are initialized in other methods) /// </summary> private void initializePrivateFields() { this.equipageModel = EquipageModel.Instance; this.equipageFilePath = string.Empty; this.systems = new ObservableCollection <AFSLSystem>(this.equipageModel.AcquireEquipage().Fleet); this.selectedSystem = null; this.isInEditMode = false; }
/// <summary> /// Initialize and instantiate private fields that are not controllers, commands, or error token (these are initialized in other methods) /// </summary> private void initializeOtherPrivateFields() { this.system = initializeSystem(); }