コード例 #1
0
        /// <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 });
        }
コード例 #2
0
        /// <summary>
        /// Добавляет кнопку на контрол
        /// </summary>
        public void Add(BaseComponent baseComponent)
        {
            if (baseComponent == null ||
                _allControls.FirstOrDefault(c => c.BaseComponent.ItemId == baseComponent.ItemId) != null)
            {
                return;
            }

            BaseComponentControl button = new BaseComponentControl(baseComponent)
            {
                Tag = baseComponent
            };

            button.StatusChanged    += ButtonStatusChanged;
            button.ComponentMovedTo += ButtonOnComponentMovedTo;
            _allControls.Add(button);

            BaseComponentType dt = baseComponent.BaseComponentType;

            #region Frame and APUs Buttons
            if (dt == BaseComponentType.Frame || dt == BaseComponentType.Apu)
            {
                _framesApus.Add(button);

                if (ContainerFrameApus.Visible == false)
                {
                    ContainerFrameApus.Visible = true;
                }
                if (_framesApus.Count > 2)
                {
                    ContainerFrameApus.EnableExtendedControl = true;
                    ContainerFrameApus.Extended = false;
                }
                else
                {
                    ContainerFrameApus.EnableExtendedControl = false;
                }

                ContainerFrameApus.AddButton(button);

                button.Name     = "FrameApu" + _framesApus.Count;
                button.TabIndex = _framesApus.Count;
            }
            #endregion

            #region Engines Buttons

            if (dt == BaseComponentType.Engine)
            {
                _enginesControls.Add(button);
                if (ContainerEngines.Visible == false)
                {
                    ContainerEngines.Visible = true;
                }
                //Определение необходимости расштряемого контейнера для кнопок двигателей);
                if (_enginesControls.Count > 2)
                {
                    ContainerEngines.EnableExtendedControl = true;
                    ContainerEngines.Extended = false;
                }
                else
                {
                    ContainerEngines.EnableExtendedControl = false;
                }

                ContainerEngines.AddButton(button);

                button.Name     = "Engine" + _enginesControls.Count;
                button.TabIndex = _enginesControls.Count;
            }
            #endregion

            #region Propellers Buttons

            if (dt == BaseComponentType.Propeller)
            {
                _propellersControls.Add(button);

                if (ContainerPropellers.Visible == false)
                {
                    ContainerPropellers.Visible = true;
                }
                //Определение необходимости расширяемого контейнера для кнопок винтов
                if (_propellersControls.Count > 2)
                {
                    ContainerPropellers.EnableExtendedControl = true;
                    ContainerPropellers.Extended = false;
                }
                else
                {
                    ContainerPropellers.EnableExtendedControl = false;
                }

                ContainerPropellers.AddButton(button);

                button.Name     = "Propeller" + _propellersControls.Count;
                button.TabIndex = _propellersControls.Count;
            }
            #endregion

            #region Landing gears Buttons

            if (dt == BaseComponentType.LandingGear)
            {
                _landingGearsControls.Add(button);

                if (ContainerLG.Visible == false)
                {
                    ContainerLG.Visible = true;
                }
                //Определение необходимости расширяемого контейнера для кнопок винтов
                if (_landingGearsControls.Count > 3)
                {
                    ContainerLG.EnableExtendedControl = true;
                    ContainerLG.Extended = false;
                }
                else
                {
                    ContainerLG.EnableExtendedControl = false;
                }

                ContainerLG.AddButton(button);

                button.Name     = "LG" + _landingGearsControls.Count;
                button.TabIndex = _landingGearsControls.Count;
            }
            #endregion
        }
コード例 #3
0
        /// <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
        }