Exemple #1
0
        /// <summary>
        /// Добавить группу танков в объект
        /// </summary>
        /// <param name="luaName">Lua-имя группы</param>
        /// <param name="name">Отображаемое имя группы</param>
        public void AddTankGroup(string luaName, string name)
        {
            var newGroup = new AttachedObjects(string.Empty, null,
                                               new AttachedObjectStrategy.AttachedTanksStrategy(name,
                                                                                                luaName));

            tankGroups.Add(newGroup);
        }
Exemple #2
0
        /// <summary>
        /// Копия объекта
        /// </summary>
        /// <returns></returns>
        public BaseTechObject Clone()
        {
            var cloned = new BaseTechObject(Owner);

            cloned.Name = Name;

            var aggregateParameters = new List <BaseParameter>();

            foreach (var aggrPar in AggregateParameters)
            {
                aggregateParameters.Add(aggrPar.Clone());
            }
            cloned.AggregateParameters = aggregateParameters;
            if (MainAggregateParameter != null)
            {
                cloned.MainAggregateParameter = MainAggregateParameter.Clone()
                                                as MainAggregateParameter;
            }

            var baseOperations = new List <BaseOperation>();

            foreach (var baseOperation in BaseOperations)
            {
                baseOperations.Add(baseOperation.Clone());
            }
            cloned.BaseOperations = baseOperations;

            cloned.BasicName = BasicName;
            cloned.EplanName = EplanName;

            var equipment = new List <BaseParameter>();

            foreach (var equip in Equipment)
            {
                var newEquip = equip.Clone();
                newEquip.Owner = this;
                equipment.Add(newEquip);
            }
            cloned.Equipment = equipment;

            cloned.S88Level    = S88Level;
            cloned.BindingName = BindingName;
            cloned.IsPID       = IsPID;

            cloned.tankGroups = new List <AttachedObjects>();
            foreach (var tankGroup in tankGroups)
            {
                var clonedStrategy = new AttachedObjectStrategy
                                     .AttachedTanksStrategy(tankGroup.WorkStrategy.Name,
                                                            tankGroup.WorkStrategy.LuaName);
                var clonedGroup = new AttachedObjects(tankGroup.Value,
                                                      tankGroup.Owner, clonedStrategy);
                cloned.tankGroups.Add(clonedGroup);
            }

            return(cloned);
        }
        /// <summary>
        /// Добавить группу объектов в объект
        /// </summary>
        /// <param name="luaName">Lua-имя группы</param>
        /// <param name="name">Отображаемое имя группы</param>
        /// <param name="allowedObjects">Разрешенные типы объектов для
        /// добавления в группу</param>
        public void AddObjectGroup(string luaName, string name,
                                   string allowedObjects)
        {
            AttachedObjects newGroup = MakeObjectGroup(luaName, name,
                                                       allowedObjects);

            if (newGroup != null)
            {
                objectGroups.Add(newGroup);
            }
        }
Exemple #4
0
        /// <summary>
        /// Удалить объект из привязки объекта
        /// </summary>
        /// <param name="attachedObjects">Элемент с привязанными объектами
        /// </param>
        /// <param name="objNum">Номер удаляемого объекта</param>
        private void RemoveAttachingToUnit(AttachedObjects attachedObjects,
                                           int objNum)
        {
            if (attachedObjects?.Value == string.Empty)
            {
                return;
            }

            List <int> attachedObjectsNums = attachedObjects.Value.Split(' ')
                                             .Select(int.Parse).ToList();

            if (attachedObjectsNums.Contains(objNum))
            {
                attachedObjectsNums.Remove(objNum);
                attachedObjects
                .SetNewValue(string.Join(" ", attachedObjectsNums));
            }
        }
Exemple #5
0
        /// <summary>
        /// Изменение привязки объекта при перемещении объекта по дереву
        /// </summary>
        /// <param name="attachedObjects">Элемент с объектами</param>
        /// <param name="oldNum">Старый номер объекта</param>
        /// <param name="newNum">Новый номер объекта</param>
        private void ChangeAttachedObjectAfterMove(
            AttachedObjects attachedObjects, int oldNum, int newNum)
        {
            string attachingObjectsStr = attachedObjects.Value;

            string[] attachingObjectsArr = attachingObjectsStr.Split(' ');
            for (int index = 0; index < attachingObjectsArr.Length; index++)
            {
                if (attachingObjectsArr[index] == newNum.ToString())
                {
                    attachingObjectsArr[index] = oldNum.ToString();
                }
                else if (attachingObjectsArr[index] == oldNum.ToString())
                {
                    attachingObjectsArr[index] = newNum.ToString();
                }
            }
            attachedObjects.SetValue(string.Join(" ", attachingObjectsArr));
        }
Exemple #6
0
        /// <summary>
        /// Изменение привязки объекта при удалении объекта из дерева
        /// </summary>
        /// <param name="attachedObjects">Элемент для обработки</param>
        /// <param name="deletedObjectNum">Номер удаленного объекта</param>
        private void ChangeAttachedObjectAfterDelete(
            AttachedObjects attachedObjects, int deletedObjectNum)
        {
            if (attachedObjects?.Value == string.Empty)
            {
                return;
            }

            string attachingObjectsStr = attachedObjects.Value;

            int[] attachingObjectsArr = attachingObjectsStr.Split(' ')
                                        .Select(int.Parse).ToArray();
            for (int index = 0; index < attachingObjectsArr.Length; index++)
            {
                int attachedObjectNum = attachingObjectsArr[index];
                if (attachedObjectNum > deletedObjectNum)
                {
                    attachingObjectsArr[index] = attachedObjectNum - 1;
                }
            }
            attachedObjects.SetValue(string.Join(" ", attachingObjectsArr));
        }
Exemple #7
0
        /// <summary>
        /// Копия объекта
        /// </summary>
        /// <returns></returns>
        public BaseTechObject Clone()
        {
            var cloned = new BaseTechObject(Owner);

            cloned.Name = Name;

            var aggregateParameters = new List <BaseParameter>();

            foreach (var aggrPar in AggregateParameters)
            {
                aggregateParameters.Add(aggrPar.Clone());
            }
            cloned.AggregateParameters = aggregateParameters;
            if (MainAggregateParameter != null)
            {
                cloned.MainAggregateParameter = MainAggregateParameter.Clone()
                                                as MainAggregateParameter;
            }

            var baseOperations = new List <BaseOperation>();

            foreach (var baseOperation in BaseOperations)
            {
                baseOperations.Add(baseOperation.Clone());
            }
            cloned.BaseOperations = baseOperations;

            cloned.BasicName = BasicName;
            cloned.EplanName = EplanName;

            var equipment = new List <BaseParameter>();

            foreach (var equip in Equipment)
            {
                var newEquip = equip.Clone();
                newEquip.Owner = this;
                equipment.Add(newEquip);
            }
            cloned.Equipment = equipment;

            cloned.S88Level    = S88Level;
            cloned.BindingName = BindingName;
            cloned.IsPID       = IsPID;

            cloned.objectGroups = new List <AttachedObjects>();
            foreach (var objectGroup in objectGroups)
            {
                var clonedStrategy = new AttachedObjectStrategy
                                     .AttachedWithoutInitStrategy(
                    objectGroup.WorkStrategy.Name,
                    objectGroup.WorkStrategy.LuaName,
                    objectGroup.WorkStrategy.AllowedObjects);
                var clonedGroup = new AttachedObjects(objectGroup.Value,
                                                      objectGroup.Owner, clonedStrategy);
                cloned.objectGroups.Add(clonedGroup);
            }

            cloned.SystemParams  = SystemParams.Clone();
            cloned.Parameters    = Parameters.Clone();
            cloned.LuaModuleName = LuaModuleName;
            cloned.MonitorName   = MonitorName;

            return(cloned);
        }