private void DrawContainerFront(Canvas canvas, Container container, Vehicle currentVehicle) { var length = container.Width/Scale; var height = container.Length/Scale; var x = container.FirstPoint.X/Scale; var z = (container.FirstPoint.Y - currentVehicle.FirstPoint.Y)/Scale; var r = new Rectangle(); r.Width = length; r.Height = height; Brush brush = new SolidColorBrush(); brush = Brushes.White; r.Stroke = new SolidColorBrush(Colors.Black); r.Fill = brush; Canvas.SetLeft(r, x); Canvas.SetTop(r, z); canvas.Children.Add(r); var t = new TextBlock(); t.Text = Math.Round(container.Mass) + " кг"; t.FontSize = 12; Canvas.SetLeft(t, x + 2); var delta = 2; Canvas.SetTop(t, z + 2); canvas.Children.Add(t); t = new TextBlock {Text = container.ShortName, FontSize = 12}; Canvas.SetLeft(t, x + 2); delta = delta + 15; Canvas.SetTop(t, z + delta); canvas.Children.Add(t); }
public bool Add(Container c, int maxHeight) { if ( (Height + c.Height) <= maxHeight & (((Blocks.Count > 0) & (c.Only4Bottom == 1))) == false & (MaxPress>=c.Mass)) { if (c.DirLength != "a") //если направленность контейнера не подходит, то блок не добавляем { if (DirLength == "a") { DirLength = c.DirLength;} else if (DirLength!=c.DirLength) {return false;} }; if (Order != c.Order & Count != 0) { return false; } //в одном блоке не может быть контейнеров из разных заказов Blocks.Add(c); Height = Height + c.Height; Length = Math.Max(Length, c.Length); Width = Math.Max(Width, c.Width); Mass = Mass + c.Mass; Price = Price + c.Price; MaxPress = Math.Min(MaxPress-c.Mass, c.PressHeight); Count=Count+c.Count; Order = c.Order; RealVolume = RealVolume + c.Volume; Priority = Math.Min(Priority, c.Priority); return true; } return false; }
private void DrawContainerUp(Canvas canvas, Container container, Vehicle currentVehicle) { var length = container.Width/Scale; var height = container.Height/Scale; var x = (container.FirstPoint.X - currentVehicle.FirstPoint.X)/Scale; var z = container.FirstPoint.Z/Scale; var rectangle = new Rectangle(); rectangle.Width = length; rectangle.Height = height; Brush brush = new SolidColorBrush(); brush = Brushes.White; rectangle.Stroke = new SolidColorBrush(Colors.Black); rectangle.Fill = brush; Canvas.SetLeft(rectangle, x); Canvas.SetTop(rectangle, canvas.Height - height - z); canvas.Children.Add(rectangle); var textBlock = new TextBlock {Text = Math.Round(container.Mass) + " кг", FontSize = 12}; Canvas.SetLeft(textBlock, x + 2); var delta = 2; Canvas.SetTop(textBlock, canvas.Height - height - z + 2); canvas.Children.Add(textBlock); textBlock = new TextBlock {Text = container.ShortName, FontSize = 12}; Canvas.SetLeft(textBlock, x + 2); delta = delta + 15; Canvas.SetTop(textBlock, canvas.Height - height - z + delta); canvas.Children.Add(textBlock); }
public bool AddContainer(Container container) { if (0.9*Length*Width >= (area + container.Area) & (Order == container.Order | Blocks.Count == 0)) { Blocks.Add(container); Count = Count + 1; area = area + container.Area; Mass = Mass + container.Mass; heightContainers = Math.Max(heightContainers, container.Height); Order = container.Order; Price = Price + container.Price; return true; } return false; }
public bool Add(Container c) { int currentWidth = 0; foreach (Container b in Blocks) { currentWidth = currentWidth + b.Width; } if (currentWidth + c.Width < Width * RowCount) { Blocks.Add(c); Height = Math.Max(Height, c.Height); Mass = Mass + c.Mass; Count = Count + c.Count; if (c.Height == Height) { PressHeight = PressHeight + c.PressHeight; } Order = c.Order; RealVolume = RealVolume + c.Volume; return true; } return false; }
private void AddContainer(FlowDocument doc, Container c) { var b = new BlockUIContainer(); var canvas = new Canvas(); canvas.Width = c.Width / scale; canvas.Height = c.Height / scale; var r = new Rectangle(); r.Width = c.Length / scale; r.Height = c.Height / scale; Brush brush = new SolidColorBrush(); brush = Brushes.White; r.Stroke = new SolidColorBrush(Colors.Black); r.Fill = brush; Canvas.SetLeft(r, c.FirstPoint.Y / scale); Canvas.SetTop(r, canvas.Height - c.Height / scale - c.FirstPoint.Z / scale); canvas.Children.Add(r); var t = new TextBlock(); t.Text = c.Name + " (" + c.ContainerType + ")"; t.FontSize = 10; Canvas.SetLeft(t, c.FirstPoint.Y / scale + 2); Canvas.SetTop(t, canvas.Height - c.Height / scale - c.FirstPoint.Z / scale + 2); canvas.Children.Add(t); t = new TextBlock(); t.Text = "Габ: " + c.Length + "x" + c.Width + "x" + c.Height + "мм.Вес:" + c.Mass; t.FontSize = 10; Canvas.SetLeft(t, c.FirstPoint.Y / scale + 2); Canvas.SetTop(t, canvas.Height - c.Height / scale - c.FirstPoint.Z / scale + 15); canvas.Children.Add(t); t = new TextBlock(); t.Text = "Цена: " + c.Price + "; Направление загрузки д: " + c.DirLength + "; ш: " + c.DirWidth + "; в: " + c.DirHeight + "; "; t.FontSize = 10; Canvas.SetLeft(t, c.FirstPoint.Y / scale + 2); Canvas.SetTop(t, canvas.Height - c.Height / scale - c.FirstPoint.Z / scale + 28); canvas.Children.Add(t); t = new TextBlock(); t.Text = "Порядок загрузки + " + c.Order + "; Допуст.давление: " + c.PressHeight + "; Хрупкость: " + c.FragilityHeight + "; "; t.FontSize = 10; Canvas.SetLeft(t, c.FirstPoint.Y / scale + 2); Canvas.SetTop(t, canvas.Height - c.Height / scale - c.FirstPoint.Z / scale + 41); canvas.Children.Add(t); t = new TextBlock(); t.Text = "Уровень: " + c.Level + "; Количество: " + c.Quantity + "; На пол: " + c.Only4Bottom + "; "; t.FontSize = 10; Canvas.SetLeft(t, c.FirstPoint.Y / scale + 2); Canvas.SetTop(t, canvas.Height - c.Height / scale - c.FirstPoint.Z / scale + 54); canvas.Children.Add(t); b.Child = canvas; doc.Blocks.Add(b); }
public static ObservableCollection<Container> LoadItemFromXML(String fileName) { NumberFormatInfo nfi = NumberFormatInfo.CurrentInfo; string CurrentDecimalSeparator = nfi.CurrencyDecimalSeparator; string downloadReport = ""; string downloadReportPrice = ""; ObservableCollection<Container> containers = new ObservableCollection<Container>(); XDocument xDoc = XDocument.Load(fileName); XElement dapl = xDoc.Element("dapl"); IEnumerable<XElement> elements = dapl.Element("items").Elements("item"); foreach (XElement element in elements) { string contName = ""; try { IEnumerable<XElement> details = element.Elements(); Container container = new Container(); container.Kind = element.Attribute("kind").Value; foreach (XElement d in details) { switch (d.Name.ToString()) { case "name": container.Name = element.Element("name").Value; contName = element.Element("name").Value; break; case "short_name": container.ShortName = element.Element("short_name").Value; break; case "container_type": container.ContainerType = element.Element("container_type").Value; break; case "ship_to_name": container.ShipToName = element.Element("ship_to_name").Value; break; case "internal_load_num": container.ShipmentId = element.Element("internal_load_num").Value; break; case "length": container.Length = int.Parse(d.Value.Replace(".00000", "")); break; case "height": container.Height = int.Parse(d.Value.Replace(".00000", "")); break; case "width": container.Width = int.Parse(d.Value.Replace(".00000", "")); break; case "price": if (d.Value == "") { container.Price = 0; } else { container.Price = double.Parse(d.Value.Replace(".", CurrentDecimalSeparator)); } break; case "mass": container.Mass = double.Parse(d.Value.Replace(".", CurrentDecimalSeparator)); break; case "level": container.Level = int.Parse(d.Value.Replace(".00000", "")); break; case "press": IEnumerable<XElement> pr = d.Elements(); foreach (XElement p in pr) { if (p.Name.ToString() == "length") container.PressLength = double.Parse(p.Value.Replace(".00000", CurrentDecimalSeparator)); if (p.Name.ToString() == "width") container.PressWidth = double.Parse(p.Value.Replace(".00000", CurrentDecimalSeparator)); if (p.Name.ToString() == "height") { container.PressHeight = double.Parse(p.Value.Replace(".00000", CurrentDecimalSeparator)); if (container.PressHeight == 0) container.PressHeight = 10000; } } break; case "order": if (element.Element("order").Value == "") { container.Order = 0; } else { container.Order = int.Parse(element.Element("order").Value); } break; case "order_type": if (element.Element("order").Value == "СРОЧНЫЙ") { container.Priority = 0; } else { container.Priority = 1; } break; case "dir": IEnumerable<XElement> dir = d.Elements(); foreach (XElement dr in dir) { if (dr.Name.ToString() == "length") { dr.Value = dr.Value.ToLower(); //преобразуем в прописные буквы if (dr.Value == "") { container.DirLength = "a"; } else if (dr.Value == "у") { container.DirLength = "y"; } //заменяем русские буквы на английские else if (dr.Value == "x") { container.DirLength = "x"; } //заменяем русские буквы на английские else if (dr.Value == "а") { container.DirLength = "a"; } //заменяем русские буквы на английские else { container.DirLength = dr.Value; } } } break; case "fragility": IEnumerable<XElement> fragility = d.Elements(); foreach (XElement f in fragility) { if (f.Name.ToString() == "Heigth") container.DirLength = f.Value; } break; case "color": //MessageBox.Show(element.Element("color").Value); container.Color = d.Value; //container.color = System.Drawing.ColorTranslator.FromHtml(element.Element("color").Value) ; break; case "Group": IEnumerable<XElement> group = d.Elements(); foreach (XElement g in group) { if (g.Name.ToString() == "name") container.GroupName = g.Value; if (g.Name.ToString() == "id") container.GroupId = int.Parse(g.Value); if (g.Name.ToString() == "quantity") container.GroupQuantity = int.Parse(g.Value); } break; case "pal_quantity": container.PalQuantity = int.Parse(d.Value); break; case "quantity": container.Quantity = int.Parse(d.Value); break; case "only4bottom": if (d.Value == "") { container.Only4Bottom = 0; } else { container.Only4Bottom = int.Parse(d.Value); } break; } } //Проверяем на нулевые габариты и вес if (container.Length == 0 || container.Width == 0 || container.Height == 0 || container.Mass == 0) { downloadReport = downloadReport + container.Name + ";"; } if (container.Price == 0) { downloadReportPrice = downloadReportPrice + container.Name + ";"; } container.IsChecked = true; containers.Add(container); } catch { MessageBox.Show("Ошибка обработки контейнера " + contName); } } if (downloadReport != "") { MessageBox.Show("Ошибка при загрузке контейнеров. Один или несколько контейнеров имеют нулевые ВГХ: " + downloadReport); //return new List<Container>(); } if (downloadReportPrice != "") { //MessageBox.Show("Ошибка при загрузке контейнеров. Один или несколько контейнеров имеют нулевую стоимость: " + downloadReportPrice); //return new List<Container>(); } return containers; }
private void DrawCube(Container item, GeometryModel3D geomod) { MeshGeometry3D mesh = new MeshGeometry3D(); mesh.Positions.Add(new Point3D(item.FirstPoint.X, item.FirstPoint.Z, item.FirstPoint.Y)); mesh.Positions.Add(new Point3D(item.FirstPoint.X + item.Width, item.FirstPoint.Z, item.FirstPoint.Y)); mesh.Positions.Add(new Point3D(item.FirstPoint.X, item.FirstPoint.Z + item.Height, item.FirstPoint.Y)); mesh.Positions.Add(new Point3D(item.FirstPoint.X + item.Width, item.FirstPoint.Z + item.Height, item.FirstPoint.Y)); mesh.Positions.Add(new Point3D(item.FirstPoint.X, item.FirstPoint.Z, item.FirstPoint.Y + item.Length)); mesh.Positions.Add(new Point3D(item.FirstPoint.X + item.Width, item.FirstPoint.Z, item.FirstPoint.Y + item.Length)); mesh.Positions.Add(new Point3D(item.FirstPoint.X, item.FirstPoint.Z + item.Height, item.FirstPoint.Y + item.Length)); mesh.Positions.Add(new Point3D(item.FirstPoint.X + item.Width, item.FirstPoint.Z + item.Height, item.FirstPoint.Y + item.Length)); mesh.TriangleIndices = new Int32Collection(new int[] { 0, 2, 1, 1, 2, 3, 0, 4, 2, 2, 4, 6, 0, 1, 4, 1, 5, 4, 1, 7, 5, 1, 3, 7, 4, 5, 6, 7, 6, 5, 2, 6, 3, 3, 6, 7 }); geomod.Geometry = mesh; }
private ScreenSpaceLines3D DrawWireCube(Container v) { ScreenSpaceLines3D wireCube = new ScreenSpaceLines3D(); Color c = Colors.Black; const int width = 2; Point3D p0 = new Point3D(v.FirstPoint.X, v.FirstPoint.Z, v.FirstPoint.Y); Point3D p1 = new Point3D(v.FirstPoint.X + v.Width, v.FirstPoint.Z, v.FirstPoint.Y); Point3D p2 = new Point3D(v.FirstPoint.X + v.Width, v.FirstPoint.Z, v.FirstPoint.Y + v.Length); Point3D p3 = new Point3D(v.FirstPoint.X, v.FirstPoint.Z, v.FirstPoint.Y + v.Length); Point3D p4 = new Point3D(v.FirstPoint.X, v.FirstPoint.Z + v.Height, v.FirstPoint.Y); Point3D p5 = new Point3D(v.FirstPoint.X + v.Width, v.FirstPoint.Z + v.Height, v.FirstPoint.Y); Point3D p6 = new Point3D(v.FirstPoint.X + v.Width, v.FirstPoint.Z + v.Height, v.FirstPoint.Y + v.Length); Point3D p7 = new Point3D(v.FirstPoint.X, v.FirstPoint.Z + v.Height, v.FirstPoint.Y + v.Length); wireCube.Thickness = width; wireCube.Color = c; //рисуем нижнюю грань wireCube.Points.Add(p0); wireCube.Points.Add(p1); wireCube.Points.Add(p1); wireCube.Points.Add(p2); wireCube.Points.Add(p2); wireCube.Points.Add(p3); wireCube.Points.Add(p3); wireCube.Points.Add(p0); //рисуем верхнюю грань wireCube.Points.Add(p4); wireCube.Points.Add(p5); wireCube.Points.Add(p5); wireCube.Points.Add(p6); wireCube.Points.Add(p6); wireCube.Points.Add(p7); wireCube.Points.Add(p7); wireCube.Points.Add(p4); //рисуем Боковую грань wireCube.Points.Add(p0); wireCube.Points.Add(p4); wireCube.Points.Add(p1); wireCube.Points.Add(p5); wireCube.Points.Add(p2); wireCube.Points.Add(p6); wireCube.Points.Add(p3); wireCube.Points.Add(p7); if (v.Kind == "VerticalPallet") {//рисуем диагональные линии на боковую грань wireCube.Points.Add(p6); wireCube.Points.Add(p3); wireCube.Points.Add(p2); wireCube.Points.Add(p7); } return wireCube; }
public virtual object Clone() { Container container = new Container { Count = Count, Length = Length, Width = Width, Height = Height, Priority = Priority, Kind = Kind, Name = Name, ShipToName = ShipToName, ShipmentId = ShipmentId, ContainerType = ContainerType, Mass = Mass, Price = Price, DirLength = DirLength, DirWidth = DirWidth, DirHeight = DirHeight, Order = Order, GroupName = GroupName, GroupId = GroupId, GroupQuantity = GroupQuantity, PressLength = PressLength, PressWidth = PressWidth, PressHeight = PressHeight, FragilityLength = FragilityLength, FragilityWidth = FragilityWidth, FragilityHeight = FragilityHeight, Freezable = Freezable, Level = Level, Color = Color, Quantity = Quantity, Only4Bottom = Only4Bottom, FirstPoint = new Point3D(FirstPoint.X, FirstPoint.Y, FirstPoint.Z), IsChecked = IsChecked }; return container; }
public bool AreSame01(Container container) { if ((Length <= container.Length & Length >= 0.8 * container.Length) & (Width <= container.Width & Width >= 0.8 * container.Width)) return true; return false; }
private void AddCabinToRow(Container c) { VerticalBlock vBlock = new VerticalBlock(); if (vBlock.Add(c, 10000) == false) { MessageBox.Show("Ошибка добавления кабины в вертикальный блок.Сообщите администратору"); return; } //добавляем вертикальный ряд в горизонтальный ряд RowBlock rBlock = new RowBlock(); rBlock.Add(vBlock, vehicle.MaxLength); if (vehicle.MaxLength >= rBlock.Width & vehicle.Tonnage >= rBlock.Mass + vehicle.Mass) { AddRowToVehicle(rBlock); } else { //помещаем кабину в список невместившихся контейнеров wasteList.Add(c); } }