/// <summary> /// Возвращает контрол к изначальному состоянию /// </summary> public void Reset() { flowLayoutPanelMain.Controls.Clear(); foreach (BaseComponentControl c in _framesApus) { c.Dispose(); } _framesApus.Clear(); foreach (BaseComponentControl c in _enginesControls) { c.Dispose(); } _enginesControls.Clear(); foreach (BaseComponentControl c in _landingGearsControls) { c.Dispose(); } _landingGearsControls.Clear(); foreach (BaseComponentControl c in _propellersControls) { c.Dispose(); } _propellersControls.Clear(); _allControls.Clear(); ContainerFrameApus.Reset(); ContainerFrameApus.EnableExtendedControl = false; ContainerFrameApus.Visible = false; ContainerEngines.Reset(); ContainerEngines.EnableExtendedControl = false; ContainerEngines.Visible = false; ContainerPropellers.Reset(); ContainerPropellers.EnableExtendedControl = false; ContainerPropellers.Visible = false; ContainerLG.Reset(); ContainerLG.EnableExtendedControl = false; ContainerLG.Visible = false; flowLayoutPanelMain.Controls.AddRange(new [] { ContainerFrameApus, ContainerEngines, ContainerPropellers, ContainerLG }); }
/// <summary> /// Обновляет информацию о двигателях текущего ВС /// </summary> private void UpdateControl() { flowLayoutPanelMain.Controls.Clear(); if (_frameControl != null) { _frameControl.Dispose(); } if (_apuControl != null) { _apuControl.Dispose(); } foreach (BaseComponentControl c in _enginesControls) { c.Dispose(); } _enginesControls.Clear(); foreach (BaseComponentControl c in _landingGearsControls) { c.Dispose(); } _landingGearsControls.Clear(); foreach (BaseComponentControl c in _propellersControls) { c.Dispose(); } _propellersControls.Clear(); _allControls.Clear(); ContainerFrameApus.Reset(); ContainerEngines.Reset(); ContainerPropellers.Reset(); ContainerLG.Reset(); var baseDetails = GlobalObjects.ComponentCore.GetAicraftBaseComponents(_currentAircraft.ItemId); var frame = baseDetails.Where(bd => bd.BaseComponentType.ItemId == BaseComponentType.Frame.ItemId).FirstOrDefault(); var apu = baseDetails.Where(bd => bd.BaseComponentType.ItemId == BaseComponentType.Apu.ItemId).FirstOrDefault(); var engines = baseDetails.Where(bd => bd.BaseComponentType.ItemId == BaseComponentType.Engine.ItemId).ToArray(); var propellers = baseDetails.Where(bd => bd.BaseComponentType.ItemId == BaseComponentType.Propeller.ItemId).ToArray(); var landingGears = baseDetails.Where(bd => bd.BaseComponentType.ItemId == BaseComponentType.LandingGear.ItemId).ToArray(); _frameControl = new BaseComponentControl(frame); flowLayoutPanelMain.Controls.Add(_frameControl); _frameControl.UpdateBaseDetailCondition(); _frameControl.TabIndex = 1; _frameControl.Tag = frame; _apuControl = new BaseComponentControl(apu); flowLayoutPanelMain.Controls.Add(_apuControl); _apuControl.UpdateBaseDetailCondition(); _apuControl.TabIndex = 2; _apuControl.Tag = apu; #region Engines Buttons //Определение необходимости расштряемого контейнера для кнопок двигателей); if (engines.Length > 0) { flowLayoutPanelMain.Controls.Add(ContainerEngines); } if (engines.Length > 2) { ContainerEngines.EnableExtendedControl = true; ContainerEngines.Extended = false; } else { ContainerEngines.EnableExtendedControl = false; } for (int i = 0; i < engines.Length; i++) { BaseComponentControl baseComponentControl = new BaseComponentControl(engines[i]); _enginesControls.Add(baseComponentControl); ContainerEngines.AddButton(baseComponentControl); baseComponentControl.UpdateBaseDetailCondition(); baseComponentControl.Name = "Engine" + i; baseComponentControl.TabIndex = 3 + i; baseComponentControl.Tag = engines[i]; } //Определение статуса расширяемого контейнера (если он был добавлен) if (_enginesControls.Count > 2) { ConditionState cond = ConditionState.NotEstimated; foreach (BaseComponentControl engineControl in _enginesControls) { if (engineControl.BaseComponentCondition == ConditionState.NotEstimated && cond == ConditionState.NotEstimated) { cond = ConditionState.NotEstimated; } if (engineControl.BaseComponentCondition == ConditionState.Satisfactory && cond != ConditionState.Notify) { cond = ConditionState.Satisfactory; } if (engineControl.BaseComponentCondition == ConditionState.Notify && cond != ConditionState.Satisfactory) { cond = ConditionState.Notify; } if (engineControl.BaseComponentCondition == ConditionState.Overdue) { cond = ConditionState.Overdue; break; } } ContainerEngines.Condition = cond; } #endregion #region Propellers Buttons //Определение необходимости расширяемого контейнера для кнопок винтов if (propellers.Length > 0) { flowLayoutPanelMain.Controls.Add(ContainerPropellers); } if (propellers.Length > 2) { ContainerPropellers.EnableExtendedControl = true; ContainerPropellers.Extended = false; } else { ContainerPropellers.EnableExtendedControl = false; } for (int i = 0; i < propellers.Length; i++) { BaseComponentControl baseComponentControl = new BaseComponentControl(propellers[i]); _propellersControls.Add(baseComponentControl); ContainerPropellers.AddButton(baseComponentControl); baseComponentControl.UpdateBaseDetailCondition(); baseComponentControl.Name = "Propeller" + i; baseComponentControl.TabIndex = 3 + i; } //Определение статуса расширяемого контейнера (если он был добавлен) if (_propellersControls.Count > 2) { ConditionState cond = ConditionState.NotEstimated; foreach (BaseComponentControl engineControl in _propellersControls) { if (engineControl.BaseComponentCondition == ConditionState.NotEstimated && cond == ConditionState.NotEstimated) { cond = ConditionState.NotEstimated; } if (engineControl.BaseComponentCondition == ConditionState.Satisfactory && cond != ConditionState.Notify) { cond = ConditionState.Satisfactory; } if (engineControl.BaseComponentCondition == ConditionState.Notify && cond != ConditionState.Satisfactory) { cond = ConditionState.Notify; } if (engineControl.BaseComponentCondition == ConditionState.Overdue) { cond = ConditionState.Overdue; break; } } ContainerPropellers.Condition = cond; } #endregion #region Landing gears Buttons if (landingGears.Length > 0) { flowLayoutPanelMain.Controls.Add(ContainerLG); } if (landingGears.Length > 3) { ContainerLG.EnableExtendedControl = true; ContainerLG.Extended = false; } else { ContainerLG.EnableExtendedControl = false; } for (int i = 0; i < landingGears.Length; i++) { BaseComponentControl baseComponentControl = new BaseComponentControl(landingGears[i]); _landingGearsControls.Add(baseComponentControl); ContainerLG.AddButton(baseComponentControl); baseComponentControl.UpdateBaseDetailCondition(); baseComponentControl.Name = "LG" + i; baseComponentControl.TabIndex = 2 + engines.Length + propellers.Length + i; baseComponentControl.Tag = landingGears[i]; } //Определение статуса расширяемого контейнера (если он был добавлен) if (_landingGearsControls.Count > 3) { ConditionState cond = ConditionState.NotEstimated; foreach (BaseComponentControl landingGearControl in _landingGearsControls) { if (landingGearControl.BaseComponentCondition == ConditionState.NotEstimated && cond == ConditionState.NotEstimated) { cond = ConditionState.NotEstimated; } if (landingGearControl.BaseComponentCondition == ConditionState.Satisfactory && cond != ConditionState.Notify) { cond = ConditionState.Satisfactory; } if (landingGearControl.BaseComponentCondition == ConditionState.Notify && cond != ConditionState.Satisfactory) { cond = ConditionState.Notify; } if (landingGearControl.BaseComponentCondition == ConditionState.Overdue) { cond = ConditionState.Overdue; break; } } ContainerLG.Condition = cond; } #endregion }