Exemplo n.º 1
0
 /// <summary>
 /// Контрол редактирует данные о залитом масле для одного агрегата
 /// </summary>
 public PowerUnitRunupControl(Aircraft aircraft, RunUp runup)
     : this()
 {
     _currentAircraft = aircraft;
     _componentType   = runup.BaseComponent.BaseComponentType;
     AttachedObject   = runup;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Контрол редактирует данные о залитом масле для одного агрегата
 /// </summary>
 public PowerUnitRunupControl(Aircraft aircraft, AircraftFlight flight, RunUp runup)
     : this()
 {
     _currentAircraft = aircraft;
     _componentType   = runup.BaseComponent.BaseComponentType;
     _outTime         = flight.FlightDate.Date.AddMinutes(flight.OutTime);
     _takeOffTime     = flight.FlightDate.Date.AddMinutes(flight.TakeOffTime);
     _landingTime     = flight.FlightDate.Date.AddMinutes(flight.LDGTime);
     _inTime          = flight.FlightDate.Date.AddMinutes(flight.InTime);
     AttachedObject   = runup;
 }
        /// <summary>
        /// Обновляет информацию о ВС и типе отображаемых деталей
        /// </summary>
        public void UpdateControl(Aircraft aircraft, BaseComponentType componentType)
        {
            if (componentType == null)
            {
                throw new ArgumentNullException("componentType", "can not be null");
            }
            if (aircraft == null)
            {
                throw new ArgumentNullException("aircraft", "can not be null");
            }
            if (aircraft.ItemId <= 0)
            {
                throw new ArgumentException("can't get components on not exist aircraft", "aircraft");
            }

            _currentAircraft = aircraft;
            _componentType   = componentType;

            UpdateControl();
        }
Exemplo n.º 4
0
 /// <summary>
 /// Контрол редактирует данные о залитом масле для одного агрегата
 /// </summary>
 public PowerUnitRunupControl(Aircraft aircraft, BaseComponentType componentType) : this()
 {
     _currentAircraft = aircraft;
     _componentType   = componentType;
     AttachedObject   = new RunUp();
 }
Exemplo n.º 5
0
        //#endregion

        #region  public static void Fill(Type type, object value)
        public static object GetValue(Type type, object value)
        {
            //Проверка, является ли переданный тип наследником BaseSmartCoreObject
            if (type.IsSubclassOf(typeof(AbstractDictionary)))
            {
                try
                {
                    var typeDict = _casEnvironment.GetDictionary(type);
                    return(typeDict == null ? null : typeDict.GetItemById(ToInt32(value)));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            if (type.IsSubclassOf(typeof(StaticDictionary)))
            {
                try
                {
                    //поиск в типе своиства Items
                    PropertyInfo itemsProp = type.GetProperty("Items");
                    //поиск у типа конструктора беза параметров
                    ConstructorInfo ci = type.GetConstructor(new Type[0]);
                    //создание экземпляра статического словаря
                    //(при этом будут созданы все его статические элементы,
                    //которые будут доступны через статическое своиство Items)
                    StaticDictionary instance = (StaticDictionary)ci.Invoke(null);
                    //Получение элементов статического своиства Items
                    IEnumerable staticList = (IEnumerable)itemsProp.GetValue(instance, null);

                    int id = ToInt32(value);
                    StaticDictionary res = staticList.Cast <StaticDictionary>().FirstOrDefault(o => o.ItemId == id) ??
                                           staticList.Cast <StaticDictionary>().FirstOrDefault(o => o.ItemId == -1);
                    return(res);
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            if (type.IsEnum)
            {
                try
                {
                    object o = Enum.Parse(type, value.ToString());
                    return(o);
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            if (type.Name == typeof(Aircraft).Name)
            {
                try
                {
                    var aircraft = _aircraftsCore.GetAircraftById(ToInt32(value));
                    return(aircraft);
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            if (type.Name == typeof(BaseComponent).Name)
            {
                try
                {
                    BaseComponent bd = _casEnvironment.BaseComponents.GetItemById(ToInt32(value));//TODO(Evgenii Babak): использовать ComponentCore
                    return(bd);
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            if (type.Name == typeof(Hangar).Name)
            {
                try
                {
                    Hangar hangar = _casEnvironment.Hangars.GetItemById(ToInt32(value));
                    return(hangar);
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            if (type.Name == typeof(Operator).Name)
            {
                try
                {
                    Operator op = _casEnvironment.Operators.GetItemById(ToInt32(value));
                    return(op);
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            if (type.Name == typeof(Store).Name)
            {
                try
                {
                    Store store = _casEnvironment.Stores.GetItemById(ToInt32(value));
                    return(store);
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            if (type.Name == typeof(WorkShop).Name)
            {
                try
                {
                    WorkShop workShop = _casEnvironment.WorkShops.GetItemById(ToInt32(value));
                    return(workShop);
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            Type nullable = Nullable.GetUnderlyingType(type);

            if (nullable != null)
            {
                //TODO:(Evgenii Babak) использовать Nameof() вместо названия типа
                string typeName = nullable.Name.ToLower();
                switch (typeName)
                {
                case "int32": return(ToInt32Nullable(value));

                case "int16": return(ToInt16Nullable(value));

                case "datetime": return(ToDateTimeNullable(value));

                case "bool": return(ToBoolNullable(value));

                case "boolean": return(ToBoolNullable(value));

                case "double": return(ToDoubleNullable(value));

                default:
                    return(null);
                }
            }
            else
            {
                string typeName = type.Name.ToLower();
                switch (typeName)
                {
                case "string": return(ToString(value));

                case "int32": return(ToInt32(value));

                case "int16": return(ToInt16(value));

                case "datetime": return(ToDateTime(value));

                case "bool": return(ToBool(value));

                case "boolean": return(ToBool(value));

                case "byte[]": return(ToBytes(value));

                case "double": return(ToDouble(value));

                case "adtype":
                    return((ADType)ToInt16(value));

                case "averageutilization":
                    return(ToAverageUtilization(value));

                case "avionicsinventorymarktype":
                //case "atachapter":
                //    return _casEnvironment.Dictionaries[typeof(AtaChapter)].GetItemById(ToInt32(value));
                case "componentdirectivethreshold":
                    return(ToComponentDirectiveThreshold(value));

                case "trainingthreshold":
                    return(ToTrainingThreshold(value));

                case "componenttype": return(BaseComponentType.GetComponentTypeById(ToInt32(value)));

                case "componentrecordtype":
                    return(ComponentRecordType.GetItemById(ToInt32(value)));

                case "detectionphase": return((DetectionPhase)ToInt16(value));

                case "directivethreshold":
                    return(ToDirectiveThreshold(value));

                case "directivetype":
                    return(DirectiveWorkType.GetItemById(ToInt32(value)));

                case "highlight": return(Highlight.GetHighlightById(ToInt32(value)));

                case "componentstatus": return((ComponentStatus)ToInt16(value));

                case "lifelength": return(ToLifelength(value));

                case "landinggearmarktype": return((LandingGearMarkType)ToInt32(value));

                case "maintenancedirectivethreshold":
                    return(ToMaintenanceDirectiveThreshold(value));

                case "maintenancecontrolprocess": return(MaintenanceControlProcess.GetItemById(ToInt32(value)));

                case "powerloss": return((PowerLoss)ToInt16(value));

                case "runupcondition": return((RunUpCondition)ToInt16(value));

                case "runuptype": return((RunUpType)ToInt16(value));

                case "shutdowntype": return((ShutDownType)ToInt16(value));

                case "thrustlever": return((ThrustLever)ToInt16(value));

                case "timespan": return(ToTime(value));

                case "weathercondition": return((WeatherCondition)ToInt16(value));

                case "workpackagestatus": return((WorkPackageStatus)ToInt32(value));

                default:
                    return(null);
                }
            }
        }
        /// <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
        }