private Element3D GetElement3DFromElementModel(ElementModel element) { return(new Element3D { EWidth = (double)element.Width / 100, EHeight = (double)element.Height / 100, EDepth = (double)element.Depth / 100, EName = element.GetEnumName(), Ex = (double)element.X / 100, Ey = (double)element.Y / 100, Ez = (double)element.Z / 100, Description = element.Description, Horizontal = element.Horizontal }); }
// TODO dodac dodatkowe logowanie i prawidłowe - w fabryce zmiany elementow public ElementModel ChangeElemenet(ElementModel element, EnumElementParameter parameter, string text) { Logger.Info("ChangeElemenet(ElementModel element, EnumElementParameter parameter, string text) in Cabinet"); if (int.TryParse(text, out int result) || parameter == EnumElementParameter.Description) { bool find = false; foreach (var item in CabinetElements) { if (item.GetGuid() == element.GetGuid()) { find = true; SwitchChange(parameter, text, result, item); if (element.GetEnumName() == EnumCabinetElement.Leftside && parameter == EnumElementParameter.Width) { CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Top).SetHeight(_width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).Width, false); CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Bottom).SetHeight(_width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).Width, false); CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Top).SetX(CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width, false); CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Bottom).SetX(CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width, false); } if (element.GetEnumName() == EnumCabinetElement.Rightside && parameter == EnumElementParameter.Width) { CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Top).SetHeight(_width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).Width, false); CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Bottom).SetHeight(_width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Leftside).Width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).Width, false); CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).SetX(_width - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Rightside).Width, false); } if (element.GetEnumName() == EnumCabinetElement.Top && parameter == EnumElementParameter.Width) { CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Top).SetY(_height - CabinetElements.Find(x => x.GetEnumName() == EnumCabinetElement.Top).Width, false); } HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.ReCount()); VerticalBarrier = _mapper.Map <List <ElementModel> >(VerticalBarrierFactory.ReCount()); FrontList = _mapper.Map <List <ElementModel> >(FrontFactory.ReCount()); } if (find) { break; } } foreach (var item in VerticalBarrier) { if (item.GetGuid() == element.GetGuid()) { find = true; VerticalBarrier = _mapper.Map <List <ElementModel> >(VerticalBarrierFactory.Update(parameter, text, result, _mapper.Map <ElementModelDTO>(item))); element = VerticalBarrier.Find(x => x.GetGuid() == element.GetGuid()); } } foreach (var item in HorizontalBarrier) { if (item.GetGuid() == element.GetGuid()) { find = true; HorizontalBarrier = _mapper.Map <List <ElementModel> >(HorizontalBarrierFactory.Update(parameter, text, result, _mapper.Map <ElementModelDTO>(item))); element = HorizontalBarrier.Find(x => x.GetGuid() == element.GetGuid()); } } foreach (var item in FrontList) { if (item.GetGuid() == element.GetGuid()) { find = true; FrontList = _mapper.Map <List <ElementModel> >(FrontFactory.Update(parameter, text, result, _mapper.Map <ElementModelDTO>(item))); element = FrontList.Find(x => x.GetGuid() == element.GetGuid()); break; } } } return(element); }