Ejemplo n.º 1
0
        public void DrawBlock(Size sizeCell, SchemeCell[] cells, double fontSizeString, AddressPallet addressPallet = null)
        {
            _schemeAddressPallets.Clear();

            Brush brushArticle      = Brushes.Azure;
            Brush brushArticleCount = Brushes.Azure;
            Brush brushCell         = Brushes.CornflowerBlue;
            Brush brushCellBorder   = Brushes.Azure;
            Brush brushHeader       = Brushes.Black;

            double opacity = 1;

            if (addressPallet != null)
            {
                opacity = 0.5;
            }

            var offsetTotalBorder = 5;

            int countFloors       = cells.Max(c => c.Address.Floor) - cells.Min(c => c.Address.Floor) + 1;
            int countCellsInFloor = cells.Length / countFloors;

            double newHeaderY = 0;
            double newHeaderX = 20 + offsetTotalBorder;

            for (int i = 0; i < countCellsInFloor; i++)
            {
                var headerValue   = (i + 1) + " паллет";
                var offsetHeaderX = (sizeCell.Width / 2) - (_schemeDrawing.GetSizeString(headerValue, 13).Width / 2);
                newHeaderX += offsetHeaderX;
                _schemeDrawing.DrawString(new Point(newHeaderX, newHeaderY), headerValue, brushHeader, 13, 1, 0, true);
                newHeaderX += sizeCell.Width - offsetHeaderX;
            }

            newHeaderY = 11;

            var maxFloor = cells.Max(cell => cell.Address.Floor);

            for (int floor = maxFloor; floor >= maxFloor - countFloors + 1; floor--)
            {
                var headerValue   = floor + " этаж";
                var offsetHeaderY = (sizeCell.Height / 2) - (_schemeDrawing.GetSizeString(headerValue, 13).Height / 2);
                newHeaderY += offsetHeaderY;
                _schemeDrawing.DrawString(new Point(0, newHeaderY + offsetTotalBorder), headerValue, brushHeader, 13, 1, -90, true);
                newHeaderY += sizeCell.Height - offsetHeaderY;
            }

            newHeaderY = 20 + offsetTotalBorder;
            newHeaderX = 20 + offsetTotalBorder;

            for (int floor = maxFloor; floor >= maxFloor - countFloors + 1; floor--)
            {
                double newY = sizeCell.Height * (maxFloor - floor) + newHeaderY;
                for (int cell = 1; cell <= countCellsInFloor; cell++)
                {
                    var cellInFloor = cells.First(c => c.Address.Floor == floor && c.Address.Cell == cell);

                    double opacityPallet = opacity;
                    if (addressPallet != null && addressPallet.Floor == floor && addressPallet.Cell == cell)
                    {
                        opacityPallet = 1;
                    }

                    double newX = sizeCell.Width * (cell - 1) + newHeaderX;
                    _schemeDrawing.DrawRectangle(new Point(newX, newY), sizeCell, brushCellBorder, brushCell, opacityPallet);
                    FillCoordinates(floor, cell, new Point(newX, newY), sizeCell);
                    if (cellInFloor.CarParts.Any())
                    {
                        var firstCarPart = cellInFloor.CarParts[0];

                        string firstValueName = firstCarPart.CarPart.FullCarPartName;
                        var    sizeString     = _schemeDrawing.GetSizeString(firstValueName, 12);

                        double offsetY  = 0;
                        double distance = (sizeCell.Height - (sizeString.Height * cellInFloor.CarParts.Length)) /
                                          (cellInFloor.CarParts.Length + 1);
                        foreach (var carPart in cellInFloor.CarParts)
                        {
                            string article      = carPart.CarPart.FullCarPartName;
                            string countArticle = carPart.CountCarParts + " шт.";
                            offsetY += distance;
                            _schemeDrawing.DrawString(new Point(newX + 10, newY + offsetY), article, brushArticle, 12, opacityPallet);
                            _schemeDrawing.DrawString(new Point(newX + sizeCell.Width / 3 * 2, newY + offsetY), countArticle, brushArticleCount,
                                                      12, opacityPallet);
                            offsetY += sizeString.Height;
                        }
                    }
                }
            }

            double x = sizeCell.Width * countCellsInFloor + newHeaderX;
            double y = sizeCell.Height * countFloors + newHeaderY;

            Size = new Size(x, y);

            _schemeDrawing.DrawRectangle(new Point(20, 20), new Size(x + offsetTotalBorder - 20, y + offsetTotalBorder - 20),
                                         Brushes.Black, Brushes.Transparent, 1, 2);

            _schemeDrawing.DrawRectangle(new Point(0, 0), new Size(x + offsetTotalBorder, y + offsetTotalBorder),
                                         Brushes.Black, Brushes.Transparent, 1, 2);
        }
Ejemplo n.º 2
0
        public void DrawWarehouse(Size sizeCell, Size sizeRoad, double fontSizeString, AddressBlock addressBlock = null)
        {
            _schemeAddressBlocks.Clear();

            var   converter         = new BrushConverter();
            Brush brushRoad         = (Brush)converter.ConvertFromString("#FFFFFFFF");
            Brush brushHeader       = Brushes.RoyalBlue;
            Brush brushHeaderBorder = Brushes.RoyalBlue;
            Brush brushHeaderText   = Brushes.Azure;
            Brush brushHeaderTitle  = Brushes.Black;

            double opacity = 1;

            if (addressBlock != null)
            {
                opacity = 0.3;
            }

            const double offsetTotalBorder = 5;

            double totalHeightRoads = 0;
            double totalWidthRoads  = 0;

            var widthWarehouse   = sizeCell.Width * _schemeData.CountPlaces;
            var titleHeaderValue = "Места";
            var titleHeaderX     = (widthWarehouse + sizeCell.Height + 20 + offsetTotalBorder * 2) / 2 - _schemeDrawing.GetSizeString(titleHeaderValue, 13).Width / 2;

            _schemeDrawing.DrawString(new Point(titleHeaderX, 0), titleHeaderValue, brushHeaderTitle, 13, 1, 0, true);

            double titleHeaderY = 20 + offsetTotalBorder;

            titleHeaderX = 20 + offsetTotalBorder;
            for (int place = 1; place <= _schemeData.CountPlaces; place++)
            {
                double headerX = sizeCell.Width * (place - 1) + totalWidthRoads + sizeCell.Height + titleHeaderX;

                _schemeDrawing.DrawRectangle(new Point(headerX, titleHeaderY), new Size(sizeCell.Width, sizeCell.Width),
                                             brushHeaderBorder, brushHeader);

                if (_schemeData.IsRoad(RoadType.Place, place, place + 1, _schemeData.CountRows))
                {
                    _schemeDrawing.DrawRectangle(new Point(headerX + sizeCell.Width, titleHeaderY), new Size(sizeRoad.Width, sizeCell.Width), brushRoad, brushRoad);
                    totalWidthRoads += sizeRoad.Width;
                }

                double halfCellWidth  = sizeCell.Width / 2;
                double halfCellHeight = sizeCell.Width / 2;
                var    sizeString     = _schemeDrawing.GetSizeString(place.ToString(), 12);
                _schemeDrawing.DrawString(new Point(halfCellWidth - sizeString.Width / 2 + headerX, halfCellHeight - sizeString.Height / 2 + titleHeaderY), place.ToString(),
                                          brushHeaderText, 12);
            }

            double heightWarehouse = 0;

            titleHeaderX = 20 + offsetTotalBorder;
            for (int row = _schemeData.CountRows; row >= 1; row--)
            {
                double headerY = sizeCell.Height * (_schemeData.CountRows - row) + totalHeightRoads + sizeCell.Width + titleHeaderY;
                _schemeDrawing.DrawRectangle(new Point(titleHeaderX, headerY), new Size(sizeCell.Height, sizeCell.Height), brushHeaderBorder, brushHeader);
                if (_schemeData.IsRoad(RoadType.Row, row, row - 1, 1))
                {
                    _schemeDrawing.DrawRectangle(new Point(titleHeaderX, headerY + sizeCell.Height), new Size(sizeCell.Height, sizeRoad.Height), brushRoad, brushRoad);
                    totalHeightRoads += sizeRoad.Height;
                }

                double halfCellWidth  = sizeCell.Height / 2;
                double halfCellHeight = sizeCell.Height / 2;
                var    sizeString     = _schemeDrawing.GetSizeString(row.ToString(), 12);
                _schemeDrawing.DrawString(new Point((halfCellWidth - sizeString.Width / 2 + titleHeaderX), halfCellHeight - sizeString.Height / 2 + headerY), row.ToString(),
                                          brushHeaderText, 12);

                heightWarehouse = headerY + sizeCell.Height;
            }

            titleHeaderValue = "Ряды";
            titleHeaderY     = (heightWarehouse / 2) - (_schemeDrawing.GetSizeString(titleHeaderValue, 13).Height / 2);
            _schemeDrawing.DrawString(new Point(0, titleHeaderY), titleHeaderValue, brushHeaderTitle, 13, 1, -90, true);

            titleHeaderY = 20 + offsetTotalBorder;

            _schemeDrawing.DrawRectangle(new Point(titleHeaderX, titleHeaderY), new Size(sizeCell.Height, sizeCell.Width), brushHeaderBorder, brushHeader);

            totalHeightRoads = 0;
            for (int row = _schemeData.CountRows; row >= 1; row--)
            {
                bool isRoadRow = false;

                double newY = sizeCell.Height * (_schemeData.CountRows - row) + totalHeightRoads + sizeCell.Width + titleHeaderY;

                totalWidthRoads = 0;
                for (int place = 1; place <= _schemeData.CountPlaces; place++)
                {
                    double maxCells = _schemeData.GetMaxCells(row, place);

                    double newX = sizeCell.Width * (place - 1) + totalWidthRoads + sizeCell.Height + titleHeaderX;

                    if (!_schemeData.IsDisableCells(row, place))
                    {
                        int countFullCells = _schemeData.GetCountFullCells(row, place);

                        double percentage = countFullCells / maxCells;

                        Brush brushCell;
                        Brush brushText = Brushes.Black;
                        if (percentage < 0.00001)
                        {
                            brushCell = Brushes.CornflowerBlue;
                            brushText = Brushes.Azure;
                        }
                        else if (percentage < 0.16)
                        {
                            brushCell = Brushes.BurlyWood;
                        }
                        else if (percentage < 0.24)
                        {
                            brushCell = Brushes.DarkOrange;
                        }
                        else
                        {
                            brushCell = Brushes.OrangeRed;
                        }

                        double opacityBlock = opacity;
                        if (addressBlock != null && addressBlock.Row == row && addressBlock.Place == place)
                        {
                            opacityBlock = 1;
                        }
                        _schemeDrawing.DrawRectangle(new Point(newX, newY), new Size(sizeCell.Width, sizeCell.Height),
                                                     Brushes.Azure, brushCell, opacityBlock);
                        FillCoordinates(row, place, new Point(newX, newY), sizeCell);

                        var sizeString = _schemeDrawing.GetSizeString(countFullCells.ToString(), fontSizeString);

                        _schemeDrawing.DrawString(new Point(newX + sizeCell.Width / 2 - sizeString.Width / 2,
                                                            newY + sizeCell.Height / 2 - sizeString.Height / 2),
                                                  countFullCells.ToString(), brushText, fontSizeString, opacityBlock);
                    }
                    else
                    {
                        _schemeDrawing.DrawRectangle(new Point(newX, newY - 1), new Size(sizeCell.Width, sizeCell.Height + 2), brushRoad, brushRoad, opacity);
                    }

                    if (_schemeData.IsRoad(RoadType.Row, row, row - 1, place))
                    {
                        _schemeDrawing.DrawRectangle(new Point(newX, newY + sizeCell.Height), new Size(sizeCell.Width, sizeRoad.Height), brushRoad, brushRoad, opacity);

                        if (!isRoadRow)
                        {
                            totalHeightRoads += sizeRoad.Height;
                            isRoadRow         = true;
                        }
                    }

                    if (_schemeData.IsRoad(RoadType.Place, place, place + 1, row))
                    {
                        _schemeDrawing.DrawRectangle(new Point(newX + sizeCell.Width, newY - 1), new Size(sizeRoad.Width, sizeCell.Height + 2), brushRoad, brushRoad, opacity);
                        totalWidthRoads += sizeRoad.Width;
                    }

                    if (_schemeData.IsRoad(RoadType.Row, row, row - 1, place) && _schemeData.IsRoad(RoadType.Place, place, place + 1, row))
                    {
                        _schemeDrawing.DrawRectangle(new Point(newX + sizeCell.Width, newY + sizeCell.Height), new Size(sizeRoad.Width, sizeRoad.Height),
                                                     brushRoad, brushRoad, opacity);
                    }
                }
            }

            double x = sizeCell.Width * (_schemeData.CountPlaces - 1) + totalWidthRoads + sizeCell.Height + sizeCell.Width + titleHeaderX;
            double y = sizeCell.Height * (_schemeData.CountRows - 1) + totalHeightRoads + sizeCell.Width + sizeCell.Height + titleHeaderY;

            Size = new Size(x, y);

            _schemeDrawing.DrawRectangle(new Point(20, 20), new Size(x + offsetTotalBorder - 20, y + offsetTotalBorder - 20),
                                         Brushes.Black, Brushes.Transparent, 1, 2);

            _schemeDrawing.DrawRectangle(new Point(0, 0), new Size(x + offsetTotalBorder, y + offsetTotalBorder),
                                         Brushes.Black, Brushes.Transparent, 1, 2);
        }