Esempio n. 1
0
        void CloseTabPage()
        {
            if (tabControl1.TabPages.Count > 0)
            {
                if (MessageBox.Show("Would you like to Close this Tab?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    TabPage page = tabControl1.SelectedTab;
                    tabControl1.TabPages.Remove(page);

                    // ev. geöffnete Dateien schließen
                    TabPageData tpd = TabPageData4Page(page);
                    if (tpd != null)
                    {
                        foreach (TreeNode tn in tpd.Tv.Nodes) // alle TreeNodes der 1. Ebene untersuchen
                        {
                            NodeContent nc = Data.NodeContent4TreeNode(tn);
                            GarminCore.BinaryReaderWriter br = null;
                            switch (nc.Type)
                            {
                            case NodeContent.NodeType.PhysicalFile:
                            case NodeContent.NodeType.LogicalFile:
                                br = (nc.Data as NodeContent.Content4File).BinaryReader;
                                break;
                            }
                            if (br != null)
                            {
                                br.Dispose();
                            }
                        }

                        for (int i = RecentUsedPaths.Count - 1; i >= 0; i--)
                        {
                            if (RecentUsedPaths[i] == tpd.Path)
                            {
                                RecentUsedPaths.RemoveAt(i);
                            }
                        }
                        RecentUsedPaths.Insert(0, tpd.Path);
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Funktion für alle RGN-Datei-Infos
        /// </summary>
        /// <param name="info"></param>
        /// <param name="hex"></param>
        /// <param name="firsthexadr"></param>
        /// <param name="filedata"></param>
        /// <param name="nodetype"></param>
        /// <param name="idx"></param>
        /// <param name="tvd"></param>
        public static void SectionAndIndex(StringBuilder info, out byte[] hex, out long firsthexadr, NodeContent.Content4File filedata, NodeContent.NodeType nodetype, int idx, TreeViewData tvd)
        {
            GarminCore.Files.StdFile_RGN rgn = filedata.GetGarminFileAsRGN(tvd.GetTRE(filedata.Basename));
            int hexlen = 0;

            firsthexadr = 0;
            hex         = null;
            AllSubdivInfo asi = null;

            switch (nodetype)
            {
            case NodeContent.NodeType.RGN_PostHeaderData:
                firsthexadr = rgn.PostHeaderDataBlock.Offset;
                if (idx < 0)
                {
                    info.AppendLine("PostHeaderDataBlock: " + rgn.PostHeaderDataBlock.ToString());
                    hexlen = (int)rgn.PostHeaderDataBlock.Length;
                }
                break;

            case NodeContent.NodeType.RGN_SubdivContentBlock:
                firsthexadr = rgn.SubdivContentBlock.Offset;
                if (idx < 0)
                {
                    int tab = 22;
                    info.AppendLine(FillWithSpace("SubdivContent", tab, false, rgn.SubdivList.Count.ToString()));
                    info.AppendLine(FillWithSpace("  Block", tab, false, rgn.SubdivContentBlock.ToString()));
                    hexlen = (int)rgn.SubdivContentBlock.Length;
                    if (hexlen > 0 && rgn.SubdivList.Count == 0)
                    {
                        info.AppendLine("data propably encrypted");
                    }
                }
                else
                {
                    asi = new AllSubdivInfo(rgn, filedata.BinaryReader, idx);

                    info.AppendLine("Info from TRE:");
                    DataTRE.SampleInfo4SubdivInfo(info, rgn.TREFile, idx);
                    info.AppendLine();

                    info.AppendLine("Info from RGN:");
                    GarminCore.DataBlock block = SampleInfo4SubdivData(info, rgn, asi);
                    firsthexadr += block.Offset;
                    hexlen       = (int)block.Length;
                }
                break;

            case NodeContent.NodeType.RGN_ExtAreasBlock:
                firsthexadr = rgn.ExtAreasBlock.Offset;
                if (idx < 0)
                {
                    info.AppendLine("ExtAreas");
                    info.AppendLine("  Block:  " + rgn.ExtAreasBlock.ToString());
                    hexlen = (int)rgn.ExtAreasBlock.Length;
                }
                else
                {
                    int subdividx = -1;
                    int count     = 0;
                    idx &= RGN_IDX_MASK; // Gesamt-Index des ExtArea
                    for (subdividx = 0; subdividx < rgn.SubdivList.Count; subdividx++)
                    {
                        count += rgn.SubdivList[subdividx].ExtAreaList.Count;
                        if (idx < count)
                        {
                            break;
                        }
                    }
                    if (subdividx < rgn.SubdivList.Count)
                    {
                        asi = new AllSubdivInfo(rgn, filedata.BinaryReader, subdividx);
                        int idx2 = asi.SubdivData.ExtAreaList.Count - (count - idx);
                        info.AppendLine("ExtArea " + idx2.ToString() + " from Subdiv " + subdividx.ToString());
                        ShowExtAreaInfo(info, asi, rgn, tvd, filedata, idx2, 40, out hexlen, out firsthexadr);
                    }
                }
                break;

            case NodeContent.NodeType.RGN_ExtLinesBlock:
                firsthexadr = rgn.ExtLinesBlock.Offset;
                if (idx < 0)
                {
                    info.AppendLine("ExtLines");
                    info.AppendLine("  Block:  " + rgn.ExtLinesBlock.ToString());
                    hexlen = (int)rgn.ExtLinesBlock.Length;
                }
                else
                {
                    int subdividx = -1;
                    int count     = 0;
                    idx &= RGN_IDX_MASK; // Gesamt-Index des ExtArea
                    for (subdividx = 0; subdividx < rgn.SubdivList.Count; subdividx++)
                    {
                        count += rgn.SubdivList[subdividx].ExtLineList.Count;
                        if (idx < count)
                        {
                            break;
                        }
                    }
                    if (subdividx < rgn.SubdivList.Count)
                    {
                        asi = new AllSubdivInfo(rgn, filedata.BinaryReader, subdividx);
                        int idx2 = asi.SubdivData.ExtLineList.Count - (count - idx);
                        info.AppendLine("ExtLine " + idx2.ToString() + " from Subdiv " + subdividx.ToString());
                        ShowExtLineInfo(info, asi, rgn, tvd, filedata, idx2, 40, out hexlen, out firsthexadr);
                    }
                }
                break;

            case NodeContent.NodeType.RGN_ExtPointsBlock:
                firsthexadr = rgn.ExtPointsBlock.Offset;
                if (idx < 0)
                {
                    info.AppendLine("ExtPoints");
                    info.AppendLine("  Block:  " + rgn.ExtPointsBlock.ToString());
                    hexlen = (int)rgn.ExtPointsBlock.Length;
                }
                else
                {
                    int subdividx = -1;
                    int count     = 0;
                    idx &= RGN_IDX_MASK; // Gesamt-Index des ExtArea
                    for (subdividx = 0; subdividx < rgn.SubdivList.Count; subdividx++)
                    {
                        count += rgn.SubdivList[subdividx].ExtPointList.Count;
                        if (idx < count)
                        {
                            break;
                        }
                    }
                    if (subdividx < rgn.SubdivList.Count)
                    {
                        asi = new AllSubdivInfo(rgn, filedata.BinaryReader, subdividx);
                        int idx2 = asi.SubdivData.ExtPointList.Count - (count - idx);
                        info.AppendLine("ExtPoint " + idx2.ToString() + " from Subdiv " + subdividx.ToString());
                        ShowExtPointInfo(info, asi, rgn, tvd, filedata, idx2, 40, out hexlen, out firsthexadr);
                    }
                }
                break;

            case NodeContent.NodeType.RGN_UnknownBlock_0x71:
                firsthexadr = rgn.UnknownBlock_0x71.Offset;
                if (idx < 0)
                {
                    info.AppendLine("UnknownBlock 0x71");
                    info.AppendLine("  Block:  " + rgn.UnknownBlock_0x71.ToString());
                    hexlen = (int)rgn.UnknownBlock_0x71.Length;
                }
                break;

            case NodeContent.NodeType.Index:
                if (tvd.TreeView.SelectedNode != null)
                {
                    int subdividx = -1;

                    // etwas tricky ...
                    NodeContent nc = NodeContent4TreeNode(tvd.TreeView.SelectedNode.Parent);
                    switch (nc.Type)
                    {
                    case NodeContent.NodeType.Index:  // wenn der übergeordnete Knoten ein Index ist, dann ist es ein Subdiv-Index
                        subdividx = (int)nc.Data;
                        if (subdividx >= 0)
                        {
                            asi = new AllSubdivInfo(rgn, filedata.BinaryReader, subdividx);
                        }
                        break;
                    }
                }

                if (asi != null)
                {
                    if ((idx & RGN_IDX_POINT1) != 0)
                    {
                        idx &= RGN_IDX_MASK;
                        int tab = 40;

                        GarminCore.Files.StdFile_RGN.RawPointData point = asi.GetPoint(idx);
                        GarminCore.Files.StdFile_LBL lbl = tvd.GetLBL(filedata.Basename);

                        info.AppendLine(FillWithSpace("Type             (1 Byte)", tab, false, DecimalAndHexAndBinary(point.Type)));
                        info.AppendLine(FillWithSpace("LabelOffsetInLBL (3 Byte) (Bit 0..21)", tab, false, DecimalAndHexAndBinary(point.LabelOffsetInLBL)));
                        if (lbl != null)
                        {
                            info.AppendLine(FillWithSpace("   Text (from LBL)", tab, true, point.GetText(lbl, true)));
                        }
                        info.AppendLine(FillWithSpace("HasSubtype                (Bit 23)", tab, false, point.HasSubtype.ToString()));
                        info.AppendLine(FillWithSpace("IsPoiOffset               (Bit 22)", tab, false, point.IsPoiOffset.ToString()));
                        info.AppendLine(FillWithSpace("DeltaLongitude   (2 Byte)", tab, false, DecimalAndHexAndBinary((short)point.RawDeltaLongitude.Value) + ", " + point.RawDeltaLongitude.ValueDegree.ToString() + "°"));
                        info.AppendLine(FillWithSpace("DeltaLatitude    (2 Byte)", tab, false, DecimalAndHexAndBinary((short)point.RawDeltaLatitude.Value) + ", " + point.RawDeltaLatitude.ValueDegree.ToString() + "°"));
                        if (point.HasSubtype)
                        {
                            info.AppendLine(FillWithSpace("Subtype        (1 Byte)", tab, false, DecimalAndHexAndBinary(point.Subtype)));
                        }

                        GarminCore.DataBlock block = asi.GetDataBlock4Object(GarminCore.Files.StdFile_TRE.SubdivInfoBasic.SubdivContent.poi, idx);
                        firsthexadr  = rgn.SubdivContentBlock.Offset;
                        firsthexadr += block.Offset;
                        hexlen       = (int)block.Length;
                    }
                    else if ((idx & RGN_IDX_POINT2) != 0)
                    {
                        idx &= RGN_IDX_MASK;
                        int tab = 40;

                        GarminCore.Files.StdFile_RGN.RawPointData point = asi.GetIdxPoint(idx);
                        GarminCore.Files.StdFile_LBL lbl = tvd.GetLBL(filedata.Basename);

                        info.AppendLine(FillWithSpace("Type             (1 Byte)", tab, false, DecimalAndHexAndBinary(point.Type)));
                        info.AppendLine(FillWithSpace("LabelOffsetInLBL (3 Byte) (Bit 0..21)", tab, false, DecimalAndHexAndBinary(point.LabelOffsetInLBL)));
                        if (lbl != null)
                        {
                            info.AppendLine(FillWithSpace("   Text (from LBL)", tab, true, point.GetText(lbl, true)));
                        }
                        info.AppendLine(FillWithSpace("HasSubtype                (Bit 23)", tab, false, point.HasSubtype.ToString()));
                        info.AppendLine(FillWithSpace("IsPoiOffset               (Bit 22)", tab, false, point.IsPoiOffset.ToString()));
                        info.AppendLine(FillWithSpace("DeltaLongitude   (2 Byte)", tab, false, DecimalAndHexAndBinary((short)point.RawDeltaLongitude.Value) + ", " + point.RawDeltaLongitude.ValueDegree.ToString() + "°"));
                        info.AppendLine(FillWithSpace("DeltaLatitude    (2 Byte)", tab, false, DecimalAndHexAndBinary((short)point.RawDeltaLatitude.Value) + ", " + point.RawDeltaLatitude.ValueDegree.ToString() + "°"));
                        if (point.HasSubtype)
                        {
                            info.AppendLine(FillWithSpace("Subtype          (1 Byte)", tab, false, DecimalAndHexAndBinary(point.Subtype)));
                        }

                        GarminCore.DataBlock block = asi.GetDataBlock4Object(GarminCore.Files.StdFile_TRE.SubdivInfoBasic.SubdivContent.idxpoi, idx);
                        firsthexadr  = rgn.SubdivContentBlock.Offset;
                        firsthexadr += block.Offset;
                        hexlen       = (int)block.Length;
                    }
                    else if ((idx & RGN_IDX_LINE) != 0)
                    {
                        idx &= RGN_IDX_MASK;
                        int tab = 40;

                        GarminCore.Files.StdFile_RGN.RawPolyData poly = asi.GetLine(idx);
                        GarminCore.Files.StdFile_LBL             lbl  = tvd.GetLBL(filedata.Basename);
                        GarminCore.Files.StdFile_NET             net  = tvd.GetNET(filedata.Basename);

                        info.AppendLine(FillWithSpace("Type             (1 Byte) (Bit 0..5)", tab, false, DecimalAndHexAndBinary(poly.Type)));
                        info.AppendLine(FillWithSpace("TwoByteLength             (Bit 7)", tab, false, poly.TwoByteLength.ToString()));
                        if (!poly.IsPolygon)
                        {
                            info.AppendLine(FillWithSpace("Direction                 (Bit 6)", tab, false, poly.DirectionIndicator.ToString()));
                        }
                        info.AppendLine(FillWithSpace("LabelOffsetInLBL (3 Byte) (Bit 0..21)", tab, false, DecimalAndHexAndBinary(poly.LabelOffsetInLBL)));

                        if (!poly.LabelInNET)
                        {
                            if (lbl != null)
                            {
                                info.AppendLine(FillWithSpace("Text (from LBL)", tab, true, poly.GetText(lbl, true)));
                            }
                        }
                        else
                        {
                            if (net != null)
                            {
                                GarminCore.Files.StdFile_NET.RoadData rd = net.GetRoadData(poly.LabelOffsetInLBL);
                                if (rd != null)
                                {
                                    info.AppendLine(FillWithSpace("Text (from NET, LBL)", tab, true, rd.GetText(lbl, true)));
                                }
                            }
                        }

                        info.AppendLine(FillWithSpace("WithExtraBit              (Bit 22)", tab, false, poly.WithExtraBit.ToString()));
                        info.AppendLine(FillWithSpace("LabelInNET                (Bit 23)", tab, false, poly.LabelInNET.ToString()));
                        info.AppendLine(FillWithSpace("DeltaLongitude   (2 Byte)", tab, false, DecimalAndHexAndBinary((short)poly.RawDeltaLongitude.Value) + ", " + poly.RawDeltaLongitude.ValueDegree.ToString() + "°"));
                        info.AppendLine(FillWithSpace("DeltaLatitude    (2 Byte)", tab, false, DecimalAndHexAndBinary((short)poly.RawDeltaLatitude.Value) + ", " + poly.RawDeltaLatitude.ValueDegree.ToString() + "°"));
                        info.AppendLine(FillWithSpace("BitstreamInfo    (1 Byte)", tab, false, DecimalAndHexAndBinary(poly.bitstreamInfo)));
                        info.AppendLine(FillWithSpace("   basebits4lat", tab, false, DecimalAndHexAndBinary(poly.bitstreamInfo >> 4)));
                        info.AppendLine(FillWithSpace("   basebits4lon", tab, false, DecimalAndHexAndBinary(poly.bitstreamInfo & 0xF)));
                        info.AppendLine(FillWithSpace("BitstreamLength (" + (poly.TwoByteLength ? "2" : "1") + " Byte)", tab, false, DecimalAndHexAndBinary(poly.bitstream.Length)));
                        if (poly.WithExtraBit)
                        {
                            info.AppendLine(FillWithSpace("ExtraBitList", tab, false, AllSubdivInfo.ExtraBits(poly)));
                        }
                        info.AppendLine("Deltas:");
                        List <GarminCore.Files.StdFile_RGN.GeoDataBitstream.RawPoint> points = poly.GetRawPoints();
                        for (int i = 0; i < points.Count; i++)
                        {
                            info.AppendLine("   " + points[i].ToString() + " / " + points[0].GetMapUnitPoint(rgn.TREFile.MaplevelList[asi.MaplevelNo].CoordBits, asi.SubdivfInfo.Center).ToString());
                        }

                        GarminCore.DataBlock block = asi.GetDataBlock4Object(GarminCore.Files.StdFile_TRE.SubdivInfoBasic.SubdivContent.line, idx);
                        firsthexadr  = rgn.SubdivContentBlock.Offset;
                        firsthexadr += block.Offset;
                        hexlen       = (int)block.Length;
                    }
                    else if ((idx & RGN_IDX_AREA) != 0)
                    {
                        idx &= RGN_IDX_MASK;
                        int tab = 40;

                        GarminCore.Files.StdFile_RGN.RawPolyData poly = asi.GetArea(idx);
                        GarminCore.Files.StdFile_LBL             lbl  = tvd.GetLBL(filedata.Basename);
                        GarminCore.Files.StdFile_NET             net  = tvd.GetNET(filedata.Basename);

                        info.AppendLine(FillWithSpace("Type             (1 Byte) (Bit 0..6) ", tab, false, DecimalAndHexAndBinary(poly.Type)));
                        info.AppendLine(FillWithSpace("TwoByteLength             (Bit 7)", tab, false, poly.TwoByteLength.ToString()));
                        info.AppendLine(FillWithSpace("LabelOffsetInLBL (3 Byte) (Bit 0..21)", tab, false, DecimalAndHexAndBinary(poly.LabelOffsetInLBL)));

                        if (!poly.LabelInNET)
                        {
                            if (lbl != null)
                            {
                                info.AppendLine(FillWithSpace("Text (from LBL)", tab, true, poly.GetText(lbl, true)));
                            }
                        }
                        else
                        {
                            if (net != null)
                            {
                                GarminCore.Files.StdFile_NET.RoadData rd = net.GetRoadData(poly.LabelOffsetInLBL);
                                if (rd != null)
                                {
                                    info.AppendLine(FillWithSpace("Text (from NET, LBL)", tab, true, rd.GetText(lbl, true)));
                                }
                            }
                        }

                        info.AppendLine(FillWithSpace("WithExtraBit              (Bit 22)", tab, false, poly.WithExtraBit.ToString()));
                        info.AppendLine(FillWithSpace("LabelInNET                (Bit 23)", tab, false, poly.LabelInNET.ToString()));
                        info.AppendLine(FillWithSpace("DeltaLongitude   (2 Byte)", tab, false, DecimalAndHexAndBinary((short)poly.RawDeltaLongitude.Value) + ", " + poly.RawDeltaLongitude.ValueDegree.ToString() + "°"));
                        info.AppendLine(FillWithSpace("DeltaLatitude    (2 Byte)", tab, false, DecimalAndHexAndBinary((short)poly.RawDeltaLatitude.Value) + ", " + poly.RawDeltaLatitude.ValueDegree.ToString() + "°"));
                        info.AppendLine(FillWithSpace("BitstreamInfo    (1 Byte)", tab, false, DecimalAndHexAndBinary(poly.bitstreamInfo)));
                        info.AppendLine(FillWithSpace("   basebits4lat", tab, false, DecimalAndHexAndBinary(poly.bitstreamInfo >> 4)));
                        info.AppendLine(FillWithSpace("   basebits4lon", tab, false, DecimalAndHexAndBinary(poly.bitstreamInfo & 0xF)));
                        info.AppendLine(FillWithSpace("BitstreamLength (" + (poly.TwoByteLength ? "2" : "1") + " Byte)", tab, false, DecimalAndHexAndBinary(poly.bitstream.Length)));
                        if (poly.WithExtraBit)
                        {
                            info.AppendLine(FillWithSpace("ExtraBitList", tab, false, AllSubdivInfo.ExtraBits(poly)));
                        }
                        info.AppendLine("Deltas:");
                        List <GarminCore.Files.StdFile_RGN.GeoDataBitstream.RawPoint> points = poly.GetRawPoints();
                        for (int i = 0; i < points.Count; i++)
                        {
                            info.AppendLine("   " + points[i].ToString() + " / " + points[0].GetMapUnitPoint(rgn.TREFile.MaplevelList[asi.MaplevelNo].CoordBits, asi.SubdivfInfo.Center).ToString());
                        }

                        GarminCore.DataBlock block = asi.GetDataBlock4Object(GarminCore.Files.StdFile_TRE.SubdivInfoBasic.SubdivContent.area, idx);
                        firsthexadr  = rgn.SubdivContentBlock.Offset;
                        firsthexadr += block.Offset;
                        hexlen       = (int)block.Length;
                    }
                    else if ((idx & RGN_IDX_EXTPOINT) != 0)
                    {
                        ShowExtPointInfo(info, asi, rgn, tvd, filedata, idx & RGN_IDX_MASK, 40, out hexlen, out firsthexadr);
                    }
                    else if ((idx & RGN_IDX_EXTLINE) != 0)
                    {
                        ShowExtLineInfo(info, asi, rgn, tvd, filedata, idx & RGN_IDX_MASK, 40, out hexlen, out firsthexadr);
                    }
                    else if ((idx & RGN_IDX_EXTAREA) != 0)
                    {
                        ShowExtAreaInfo(info, asi, rgn, tvd, filedata, idx & RGN_IDX_MASK, 40, out hexlen, out firsthexadr);
                    }
                }


                break;

            default:
                info.AppendLine("internal error: no info for nodetype '" + nodetype.ToString() + "'");
                break;
            }

            if (hexlen > 0)
            {
                hex = HexRange(firsthexadr, filedata.BinaryReader, hexlen);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Daten für den akt. Node anzeigen
        /// <para>aus dem akt. und ev. den darüber liegenden Nodes wird bestimmt, welche Daten anzuzeigen sind</para>
        /// </summary>
        /// <param name="tn"></param>
        /// <param name="tpd"></param>
        void ShowData4Node(TreeNode tn, TabPageData tpd)
        {
            byte[] hex         = null;
            long   firsthexadr = 0;

            tpd.Hexwin.ClearContent();
            tpd.Info.Clear();
            StringBuilder info = new StringBuilder();

            NodeContent  nc  = Data.NodeContent4TreeNode(tn);
            TreeViewData tvd = TreeViewData.GetTreeViewData(tn);

            switch (nc.Type)
            {
            case NodeContent.NodeType.PhysicalFile:
                if (nc.Data is NodeContent.Content4PhysicalFile)
                {
                    Data.RegisterCoreFiles(tvd, (nc.Data as NodeContent.Content4PhysicalFile).Filename);
                    Data.ShowData4Node_PhysicalFile(info, out hex, out firsthexadr, nc.Data as NodeContent.Content4PhysicalFile, tvd);
                }
                break;

            case NodeContent.NodeType.SimpleFilesystem:
                nc = Data.NodeContent4TreeNode(tn.Parent); // es muss eine physische Datei übergeordnet sein
                if (nc.Data is NodeContent.Content4PhysicalFile)
                {
                    DataSimpleFilesystem.ShowData(info, out hex, out firsthexadr, nc.Data as NodeContent.Content4PhysicalFile, tvd);
                }
                break;

            case NodeContent.NodeType.LogicalFile:
                if (nc.Data is NodeContent.Content4LogicalFile)
                {
                    Data.RegisterCoreFiles(tvd, (nc.Data as NodeContent.Content4LogicalFile).Filename);
                    Data.ShowData4Node_LogicalFile(info, out hex, out firsthexadr, nc.Data as NodeContent.Content4LogicalFile, tvd);
                }
                break;

            case NodeContent.NodeType.GarminCommonHeader:
                nc = Data.NodeContent4TreeNode(tn.Parent); // es muss eine physische oder logische Datei übergeordnet sein
                if (nc.Data is NodeContent.Content4File)
                {
                    Data.ShowData4Node_GarminCommonHeader(info, out hex, out firsthexadr, nc.Data as NodeContent.Content4File, tvd);
                }
                break;

            case NodeContent.NodeType.GarminSpecialHeader:
                nc = Data.NodeContent4TreeNode(tn.Parent); // es muss eine physische oder logische Datei übergeordnet sein
                if (nc.Data is NodeContent.Content4File)
                {
                    Data.ShowData4Node_GarminSpecialHeader(info, out hex, out firsthexadr, nc.Data as NodeContent.Content4File, tvd);
                }
                break;

            case NodeContent.NodeType.Index:
                if (tn.Parent != null)
                {
                    Data.ShowData4Node_GarminStdFile(info, out hex, out firsthexadr, Data.GetNextContent4File(tn), Data.NodeContent4TreeNode(tn.Parent).Type, (int)nc.Data, tvd);
                }
                break;

            case NodeContent.NodeType.DataRange:
                NodeContent.Content4DataRange c4dr = nc.Data as NodeContent.Content4DataRange;
                info.AppendLine(c4dr.Info);
                hex         = c4dr.Bytes;
                firsthexadr = c4dr.FirstAdr;
                break;

            default:
                NodeContent.Content4File c4f = Data.GetNextContent4File(tn);
                Data.RegisterCoreFiles(tvd, c4f.Filename);
                Data.ShowData4Node_GarminStdFile(info, out hex, out firsthexadr, c4f, nc.Type, -1, tvd);
                break;
            }

            tpd.Info.AppendText(info.ToString());
            tpd.Info.Select(0, 0);
            tpd.Info.ScrollToCaret();

            if (hex != null)
            {
                tpd.Hexwin.SetContent(hex, (ulong)firsthexadr);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Funktion für alle Datei-Infos
        /// </summary>
        /// <param name="info"></param>
        /// <param name="hex"></param>
        /// <param name="firsthexadr"></param>
        /// <param name="filedata"></param>
        /// <param name="nodetype">"Thema" der Info</param>
        /// <param name="idx">wenn größer oder gleich 0, dann der Index auf ein Objekt einer Tabelle</param>
        /// <param name="tn"></param>
        public static void SectionAndIndex(StringBuilder info, out byte[] hex, out long firsthexadr, NodeContent.Content4File filedata, NodeContent.NodeType nodetype, int idx, TreeViewData tvd)
        {
            GarminCore.Files.StdFile_DEM dem = filedata.GetGarminFileAsDEM();
            int hexlen = 0;

            firsthexadr = 0;
            hex         = null;

            switch (nodetype)
            {
            case NodeContent.NodeType.DEM_Zoomlevel:
                firsthexadr = dem.PtrZoomlevel;
                if (idx < 0)
                {
                    info.AppendLine("ZoomlevelCount:       " + DecimalAndHexAndBinary(dem.ZoomlevelCount));
                    info.AppendLine("ZoomlevelRecordSize:  " + DecimalAndHexAndBinary(dem.ZoomlevelRecordSize));
                    hexlen = dem.ZoomlevelRecordSize * dem.ZoomlevelCount;
                }
                else
                {
                    GarminCore.Files.DEM.ZoomlevelTableitem record = dem.ZoomLevel[idx].ZoomlevelItem;

                    info.AppendLine("SpecType                (1 Byte): " + DecimalAndHexAndBinary(record.SpecType));
                    info.AppendLine("Number                  (1 Byte): " + DecimalAndHexAndBinary(record.No));
                    info.AppendLine("Tilesize horizontal     (4 Byte): " + DecimalAndHexAndBinary(record.PointsHoriz));
                    info.AppendLine("Tilesize vertical       (4 Byte): " + DecimalAndHexAndBinary(record.PointsVert));
                    info.AppendLine("LastRowHeight           (4 Byte): " + DecimalAndHexAndBinary(record.LastRowHeight));
                    info.AppendLine("LastColWidth            (4 Byte): " + DecimalAndHexAndBinary(record.LastColWidth));
                    info.AppendLine("Unknown12               (2 Byte): " + DecimalAndHexAndBinary(record.Unknown12));
                    info.AppendLine("MaxIdxHoriz             (4 Byte): " + DecimalAndHexAndBinary(record.MaxIdxHoriz));
                    info.AppendLine("MaxIdxVert              (4 Byte): " + DecimalAndHexAndBinary(record.MaxIdxVert));
                    info.AppendLine("Structure               (2 Byte): " + DecimalAndHexAndBinary(record.Structure, 16));
                    info.AppendLine("   OffsetSize              (Bit 0,1) +1: " + record.Structure_OffsetSize + " Byte");
                    info.AppendLine("   BaseheightSize          (Bit 2) +1:   " + record.Structure_BaseheightSize + " Byte");
                    info.AppendLine("   DiffSize                (Bit 3) +1:   " + record.Structure_DiffSize + " Byte");
                    info.AppendLine("   CodingtypeSize          (Bit 4):      " + record.Structure_CodingtypeSize + " Byte");
                    info.AppendLine("SubtileTableitemSize    (2 Byte): " + DecimalAndHexAndBinary(record.SubtileTableitemSize));
                    info.AppendLine("SubtileTableOffset      (4 Byte): " + DecimalAndHexAndBinary(record.PtrSubtileTable));
                    info.AppendLine("HeightdataOffset        (4 Byte): " + DecimalAndHexAndBinary(record.PtrHeightdata));
                    info.AppendLine("Left                    (4 Byte): " + DecimalAndHexAndBinary(record.west) + "; " + record.West.ToString() + "°");
                    info.AppendLine("Top                     (4 Byte): " + DecimalAndHexAndBinary(record.north) + "; " + record.North.ToString() + "°");
                    info.AppendLine("PointDistanceVertical   (4 Byte): " + DecimalAndHexAndBinary(record.pointDistanceVert) + "; " + record.PointDistanceVert.ToString() + "°");
                    info.AppendLine("PointDistanceHorizontal (4 Byte): " + DecimalAndHexAndBinary(record.pointDistanceHoriz) + "; " + record.PointDistanceHoriz.ToString() + "°");
                    info.AppendLine("MinHeight               (2 Byte): " + DecimalAndHexAndBinary(record.MinHeight));
                    info.AppendLine("MaxHeight               (2 Byte): " + DecimalAndHexAndBinary(record.MaxHeight));

                    firsthexadr += idx * dem.ZoomlevelRecordSize;
                    hexlen       = dem.ZoomlevelRecordSize;
                }
                break;

            case NodeContent.NodeType.Index:
                // etwas tricky, aber nc.Data des übergeordneten Knotens ist der ZoomLevel-Index
                if (tvd.TreeView.SelectedNode != null)
                {
                    int         zoomlevelidxidx = -1;
                    NodeContent nc = NodeContent4TreeNode(tvd.TreeView.SelectedNode.Parent);
                    if (nc.Type == NodeContent.NodeType.Index)
                    {
                        zoomlevelidxidx = (int)nc.Data;
                    }
                    if (zoomlevelidxidx >= 0)
                    {
                        GarminCore.Files.DEM.ZoomlevelTableitem zoomlevel = dem.ZoomLevel[zoomlevelidxidx].ZoomlevelItem;
                        GarminCore.Files.DEM.SubtileTableitem   subtile   = dem.ZoomLevel[zoomlevelidxidx].Subtiles[idx].Tableitem;
                        info.AppendLine("Offset     (" + zoomlevel.Structure_OffsetSize + " Byte): " + DecimalAndHexAndBinary(subtile.Offset));
                        info.AppendLine("Baseheight (" + zoomlevel.Structure_BaseheightSize + " Byte): " + DecimalAndHexAndBinary(subtile.Baseheight));
                        info.AppendLine("Diff       (" + zoomlevel.Structure_DiffSize + " Byte): " + DecimalAndHexAndBinary(subtile.Diff));
                        if (zoomlevel.Structure_CodingtypeSize > 0)
                        {
                            info.AppendLine("Type       (" + zoomlevel.Structure_CodingtypeSize + " Byte): " + DecimalAndHexAndBinary(subtile.Type));
                        }
                        info.AppendLine();
                        info.AppendLine("coded data (" + DecimalAndHexAndBinary(dem.ZoomLevel[zoomlevelidxidx].Subtiles[idx].DataLength) + " Bytes):");

                        firsthexadr = zoomlevel.PtrHeightdata + subtile.Offset;
                        hexlen      = dem.ZoomLevel[zoomlevelidxidx].Subtiles[idx].DataLength;
                    }
                }
                break;

            default:
                info.AppendLine("internal error: no info for nodetype '" + nodetype.ToString() + "'");
                break;
            }

            if (hexlen > 0)
            {
                hex = HexRange(firsthexadr, filedata.BinaryReader, hexlen);
            }
        }