public DPDefaultWindow(DistributedPowerInterface dpi, CabViewControl control) : base(dpi, 640, 240)
        {
            var param = (control as CVCScreen).CustomParameters;

            if (param.ContainsKey("fulltable"))
            {
                bool.TryParse(param["fulltable"], out FullTable);
            }
            if (param.ContainsKey("loadunits"))
            {
                string sUnits = param["loadunits"].ToUpper();
                sUnits = sUnits.Replace('/', '_');
                CABViewControlUnits.TryParse(sUnits, out LoadUnits);
            }
            DPITable = new DPITable(FullTable, LoadUnits, fullScreen: true, dpi: dpi);
            AddToLayout(DPITable, new Point(0, 0));
        }
        public ThreeDimCabDPI(Viewer viewer, int iMatrix, string size, string aceFile, PoseableShape trainCarShape, CabViewControlRenderer c)
        //           : base(viewer, iMatrix, size, aceFile, trainCarShape, c)
        {
            Size = int.Parse(size) * 0.001f;//input size is in mm
            if (aceFile != "")
            {
                AceFile = aceFile.ToUpper();
                if (!AceFile.EndsWith(".ACE"))
                {
                    AceFile = AceFile + ".ACE";                            //need to add ace into it
                }
            }
            else
            {
                AceFile = "";
            }

            CVFR          = (DistributedPowerInterfaceRenderer)c;
            DPITable      = CVFR.DPI.DPDefaultWindow.DPITable;
            DPIStatus     = CVFR.DPI.DPIStatus;
            Viewer        = viewer;
            TrainCarShape = trainCarShape;
            XNAMatrix     = TrainCarShape.SharedShape.Matrices[iMatrix];
            // 9 rows, 5 columns plus first one; first one has a couple of triangles for the whole string,
            // the other ones have a couple of triangles for each char, and there are max 7 chars per string;
            // this leads to 1944 vertices
            var maxVertex = 2048;

            //Material = viewer.MaterialManager.Load("Scenery", Helpers.GetRouteTextureFile(viewer.Simulator, Helpers.TextureFlags.None, texture), (int)(SceneryMaterialOptions.None | SceneryMaterialOptions.AlphaBlendingBlend), 0);
            Material = FindMaterial(false); //determine normal material
                                            // Create and populate a new ShapePrimitive
            NumVertices = NumIndices = 0;

            VertexList          = new VertexPositionNormalTexture[maxVertex];
            TriangleListIndices = new short[maxVertex / 2 * 3]; // as is NumIndices

            //start position is the center of the text
            var start    = new Vector3(0, 0, 0);
            var rotation = 0;

            //find the left-most of text
            Vector3 offset;

            offset.X = 0;

            offset.Y = -Size;
            var    param = new string(' ', MaxDigits);
            var    color = ColorYellow;
            var    headerIndex = 0;
            float  tX, tY;
            Matrix rot;

            for (int iRow = 0; iRow < DPITable.NumberOfRowsFull; iRow++)
            {
                // fill with blanks at startup
                tX = 0.875f;
                tY = 0.125f;
                //the left-bottom vertex
                Vector3            v = new Vector3(offset.X, offset.Y, 0.01f);
                v += start; Vertex v1 = new Vertex(v.X, v.Y, v.Z, 0, 0, -1, tX, tY);

                //the right-bottom vertex
                v.X = offset.X + Size * 7 * 0.5f; v.Y = offset.Y;
                v  += start; Vertex v2 = new Vertex(v.X, v.Y, v.Z, 0, 0, -1, tX + 0.125f, tY);

                //the right-top vertex
                v.X = offset.X + Size * 7 * 0.5f; v.Y = offset.Y + Size;
                v  += start; Vertex v3 = new Vertex(v.X, v.Y, v.Z, 0, 0, -1, tX + 0.125f, tY - 0.0625f);

                //the left-top vertex
                v.X = offset.X; v.Y = offset.Y + Size;
                v  += start; Vertex v4 = new Vertex(v.X, v.Y, v.Z, 0, 0, -1, tX, tY - 0.0625f);

                //create first triangle
                TriangleListIndices[NumIndices++] = (short)NumVertices;
                TriangleListIndices[NumIndices++] = (short)(NumVertices + 2);
                TriangleListIndices[NumIndices++] = (short)(NumVertices + 1);
                // Second triangle:
                TriangleListIndices[NumIndices++] = (short)NumVertices;
                TriangleListIndices[NumIndices++] = (short)(NumVertices + 3);
                TriangleListIndices[NumIndices++] = (short)(NumVertices + 2);

                //create vertex
                VertexList[NumVertices].Position     = v1.Position; VertexList[NumVertices].Normal = v1.Normal; VertexList[NumVertices].TextureCoordinate = v1.TexCoord;
                VertexList[NumVertices + 1].Position = v2.Position; VertexList[NumVertices + 1].Normal = v2.Normal; VertexList[NumVertices + 1].TextureCoordinate = v2.TexCoord;
                VertexList[NumVertices + 2].Position = v3.Position; VertexList[NumVertices + 2].Normal = v3.Normal; VertexList[NumVertices + 2].TextureCoordinate = v3.TexCoord;
                VertexList[NumVertices + 3].Position = v4.Position; VertexList[NumVertices + 3].Normal = v4.Normal; VertexList[NumVertices + 3].TextureCoordinate = v4.TexCoord;
                NumVertices += 4;
                headerIndex++;
                offset.X = 0;

                for (int iCol = 1; iCol < NumColumns; iCol++)
                {
                    for (int iChar = 0; iChar < param.Length; iChar++)
                    {
                        tX = GetTextureCoordX(param, iChar);
                        tY = GetTextureCoordY(param, iChar, color);
                        var offX = offset.X + Size * (1 + HeaderMaxDigits + (MaxDigits) * (iCol - 1)) * 0.5f;
                        //the left-bottom vertex
                        Vector3             va = new Vector3(offX, offset.Y, 0.01f);
                        va += start; Vertex v5 = new Vertex(va.X, va.Y, va.Z, 0, 0, -1, tX, tY);

                        //the right-bottom vertex
                        va.X = offX + Size * 0.5f; va.Y = offset.Y;
                        va  += start; Vertex v6 = new Vertex(va.X, va.Y, va.Z, 0, 0, -1, tX + 0.125f, tY);

                        //the right-top vertex
                        va.X = offX + Size * 0.5f; va.Y = offset.Y + Size;
                        va  += start; Vertex v7 = new Vertex(va.X, va.Y, va.Z, 0, 0, -1, tX + 0.125f, tY - 0.0625f);

                        //the left-top vertex
                        va.X = offX; va.Y = offset.Y + Size;
                        va  += start; Vertex v8 = new Vertex(va.X, va.Y, va.Z, 0, 0, -1, tX, tY - 0.0625f);

                        //create first triangle
                        TriangleListIndices[NumIndices++] = (short)NumVertices;
                        TriangleListIndices[NumIndices++] = (short)(NumVertices + 2);
                        TriangleListIndices[NumIndices++] = (short)(NumVertices + 1);
                        // Second triangle:
                        TriangleListIndices[NumIndices++] = (short)NumVertices;
                        TriangleListIndices[NumIndices++] = (short)(NumVertices + 3);
                        TriangleListIndices[NumIndices++] = (short)(NumVertices + 2);

                        //create vertex
                        VertexList[NumVertices].Position     = v5.Position; VertexList[NumVertices].Normal = v5.Normal; VertexList[NumVertices].TextureCoordinate = v5.TexCoord;
                        VertexList[NumVertices + 1].Position = v6.Position; VertexList[NumVertices + 1].Normal = v6.Normal; VertexList[NumVertices + 1].TextureCoordinate = v6.TexCoord;
                        VertexList[NumVertices + 2].Position = v7.Position; VertexList[NumVertices + 2].Normal = v7.Normal; VertexList[NumVertices + 2].TextureCoordinate = v7.TexCoord;
                        VertexList[NumVertices + 3].Position = v8.Position; VertexList[NumVertices + 3].Normal = v8.Normal; VertexList[NumVertices + 3].TextureCoordinate = v8.TexCoord;
                        NumVertices += 4;
                        offset.X    += Size * 0.5f; offset.Y += 0; //move to next digit
                    }
                    offset.X = 0;
                }
                offset.Y -= Size; //move to next digit
            }

            //create the shape primitive
            shapePrimitive = new MutableShapePrimitive(Material, NumVertices, NumIndices, new[] { -1 }, 0);
            UpdateShapePrimitive(Material);
        }