private void EnsureHeadTable()
 {
     if (head == null)
     {
         head = (HeaderTable)GetTable(TableNames.Head);
     }
 }
Exemple #2
0
        private static TrueTypeFont ParseTables(decimal version, IReadOnlyDictionary <string, TrueTypeHeaderTable> tables, TrueTypeDataBytes data)
        {
            var isPostScript = tables.ContainsKey(TrueTypeHeaderTable.Cff);

            var tableRegister = new TableRegister();

            if (!tables.TryGetValue(TrueTypeHeaderTable.Head, out var table))
            {
                throw new InvalidOperationException($"The {TrueTypeHeaderTable.Head} table is required.");
            }

            // head
            tableRegister.HeaderTable = HeaderTable.Load(data, table);

            if (!tables.TryGetValue(TrueTypeHeaderTable.Hhea, out var hHead))
            {
                throw new InvalidOperationException("The horizontal header table is required.");
            }

            // hhea
            tableRegister.HorizontalHeaderTable = HorizontalHeaderTable.Load(data, hHead);

            if (!tables.TryGetValue(TrueTypeHeaderTable.Maxp, out var maxHeaderTable))
            {
                throw new InvalidOperationException("The maximum profile table is required.");
            }

            // maxp
            tableRegister.MaximumProfileTable = BasicMaximumProfileTable.Load(data, maxHeaderTable);

            // post
            if (tables.TryGetValue(TrueTypeHeaderTable.Post, out var postscriptHeaderTable))
            {
                tableRegister.PostScriptTable = PostScriptTable.Load(data, table, tableRegister.MaximumProfileTable);
            }

            if (!isPostScript)
            {
                if (!tables.TryGetValue(TrueTypeHeaderTable.Loca, out var indexToLocationHeaderTable))
                {
                    throw new InvalidOperationException("The location to index table is required for non-PostScript fonts.");
                }

                // loca
                tableRegister.IndexToLocationTable =
                    IndexToLocationTable.Load(data, indexToLocationHeaderTable, tableRegister);

                if (!tables.TryGetValue(TrueTypeHeaderTable.Glyf, out var glyphHeaderTable))
                {
                    throw new InvalidOperationException("The glpyh table is required for non-PostScript fonts.");
                }

                // glyf
                tableRegister.GlyphDataTable = GlyphDataTable.Load(data, glyphHeaderTable, tableRegister);

                OptionallyParseTables(tables, data, tableRegister);
            }

            return(new TrueTypeFont(version, tables, tableRegister));
        }
Exemple #3
0
        public void ShouldBeAbleToSetDynamicTableSize()
        {
            var t = new HeaderTable(2001);

            Assert.Equal(2001, t.MaxDynamicTableSize);
            t.MaxDynamicTableSize = 300;
            Assert.Equal(300, t.MaxDynamicTableSize);
        }
Exemple #4
0
        /// <summary>
        /// Method invoked for building the first FPTree representation of the
        /// original database
        /// </summary>
        /// <param name="startdb">The list of database transactions</param>
        public void BuildFirstTree(List <ItemSet> startdb)
        {
            // Counting the frequency of single items
            FrequencyItemCounter = new Dictionary <int, int>();
            FrequencyItemCounter = CountFrequencyItem(startdb);

            // Evaluate header table dimension
            int HTsize = 0;

            foreach (int item in FrequencyItemCounter.Keys)
            {
                if (FrequencyItemCounter[item] >= _minSup)
                {
                    HTsize++;
                }
            }

            ht = new HeaderTable(HTsize);

            // Add every frequent single itemset to header table
            foreach (KeyValuePair <int, int> coppia in FrequencyItemCounter)
            {
                if (coppia.Value >= _minSup)
                {
                    ht.addRecord(coppia.Key, coppia.Value);
                }
            }
            // Removal of non frequent items, sorting and final insertion in the FPTreee
            ItemSet SortedList = new ItemSet();

            foreach (ItemSet itemset in startdb)
            {
                SortedList.Items.Clear();
                for (int i = 0; i < itemset.ItemsNumber; i++)
                {
                    if (FrequencyItemCounter[itemset.Items[i]] >= _minSup)
                    {
                        SortedList.Add(itemset.Items[i]);
                    }
                }
                if (SortedList.ItemsNumber > 0)
                {
                    SortedList.Items.Sort(new ItemSortingStrategy(FrequencyItemCounter));
                    if (_depth < SortedList.ItemsNumber)
                    {
                        _depth = SortedList.ItemsNumber;
                    }
                    AddItemSetTree(SortedList, Root);
                }
            }
            startdb = null;
        }
Exemple #5
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();

            AsyncTaskRunnerController.Instance.OperationStartedEvent += (sender, e) => {
                DataSource.Clear();
                HeaderTable.ReloadData();
            };
            AsyncTaskRunnerController.Instance.ResponseEvent += (sender, e) => {
                DataSource.SetHeaders(e.Response);
                HeaderTable.ReloadData();
            };
        }
Exemple #6
0
        public void ShouldThrowWhenIncorrectlyIndexed()
        {
            var t = new HeaderTable(400);

            Assert.Throws <IndexOutOfRangeException>(() => t.GetAt(-1));
            Assert.Throws <IndexOutOfRangeException>(() => t.GetAt(0));
            t.GetAt(1);  // Valid
            t.GetAt(61); // Last valid
            Assert.Throws <IndexOutOfRangeException>(() => t.GetAt(62));

            // Put something into the dynamic table and test again
            t.Insert("a", 1, "b", 1);
            t.Insert("a", 1, "b", 1);
            t.GetAt(62);
            t.GetAt(63);
            Assert.Throws <IndexOutOfRangeException>(() => t.GetAt(64));
        }
Exemple #7
0
        /// <summary>
        /// Creates a new HPACK decoder
        /// </summary>
        /// <param name="options">Decoder options</param>
        public Decoder(Options?options)
        {
            var dynamicTableSize = Defaults.DynamicTableSize;

            this._dynamicTableSizeLimit = Defaults.DynamicTableSizeLimit;
            var maxStringLength         = Defaults.MaxStringLength;
            ArrayPool <byte> bufferPool = null;

            if (options.HasValue)
            {
                var opts = options.Value;
                if (opts.DynamicTableSize.HasValue)
                {
                    dynamicTableSize = opts.DynamicTableSize.Value;
                }
                if (opts.DynamicTableSizeLimit.HasValue)
                {
                    this._dynamicTableSizeLimit = opts.DynamicTableSizeLimit.Value;
                }
                if (opts.MaxStringLength.HasValue)
                {
                    maxStringLength = opts.MaxStringLength.Value;
                }
                if (opts.BufferPool != null)
                {
                    bufferPool = opts.BufferPool;
                }
            }

            if (bufferPool == null)
            {
                bufferPool = ArrayPool <byte> .Shared;
            }

            this._stringDecoder = new StringDecoder(maxStringLength, bufferPool);

            if (dynamicTableSize > this._dynamicTableSizeLimit)
            {
                throw new ArgumentException("Dynamic table size must not exceeded limit");
            }

            this._headerTable = new HeaderTable(dynamicTableSize);
        }
Exemple #8
0
        public void ShouldReturnItemsFromDynamicTable()
        {
            var t = new HeaderTable(400);

            t.Insert("a", 1, "b", 2);
            t.Insert("c", 3, "d", 4);
            var item = t.GetAt(62);

            Assert.Equal(
                new TableEntry {
                Name = "c", NameLen = 3, Value = "d", ValueLen = 4
            },
                item, ec);
            item = t.GetAt(63);
            Assert.Equal(
                new TableEntry {
                Name = "a", NameLen = 1, Value = "b", ValueLen = 2
            },
                item, ec);
        }
Exemple #9
0
        public Encoder(Options?options)
        {
            var dynamicTableSize = Defaults.DynamicTableSize;

            this._huffmanStrategy = HuffmanStrategy.IfSmaller;

            if (options.HasValue)
            {
                var opts = options.Value;
                if (opts.DynamicTableSize.HasValue)
                {
                    dynamicTableSize = opts.DynamicTableSize.Value;
                }
                if (opts.HuffmanStrategy.HasValue)
                {
                    this._huffmanStrategy = opts.HuffmanStrategy.Value;
                }
            }
            this._headerTable = new HeaderTable(dynamicTableSize);
        }
Exemple #10
0
        public void ShouldReturnItemsFromStaticTable()
        {
            var t    = new HeaderTable(400);
            var item = t.GetAt(1);

            Assert.Equal(
                new TableEntry {
                Name = ":authority", NameLen = 10, Value = "", ValueLen = 0
            },
                item, ec);
            item = t.GetAt(2);
            Assert.Equal(
                new TableEntry {
                Name = ":method", NameLen = 7, Value = "GET", ValueLen = 3
            },
                item, ec);
            item = t.GetAt(61);
            Assert.Equal(
                new TableEntry {
                Name = "www-authenticate", NameLen = 16, Value = "", ValueLen = 0
            },
                item, ec);
        }
Exemple #11
0
        private void BuildHeader()
        {
            var max = Original.Episodes == 0 ? double.MaxValue : Original.Episodes;
            var adj = new Adjustment(Original.CurrentEpisode, 0, max, 1, 10, 0);

            _episodeSpin = new SpinButton(adj, 1, 0);

            // Pack Episode Spinner
            EpisodeCounter.PackStart(new Label("Episode"), false, false, 20);
            EpisodeCounter.Add(_episodeSpin);
            _episodeSpin.SetSizeRequest(50, 22);
            _episodeSpin.ValueChanged += OnEpisodeChanged;
            EpisodeCounter.PackEnd(new VBox(), true, true, 100);             // push everything left

            // Pack header table
            HeaderTable.NRows    = 3;
            HeaderTable.NColumns = 2;
            HeaderTable.Attach(new Label("Type: \t"), 0, 1, 0, 1, AttachOptions.Shrink, AttachOptions.Expand, 0, 0);
            HeaderTable.Attach(new Label(Enum.GetName(typeof(Anime.ShowTypes), Original.Type)), 1, 2, 0, 1, AttachOptions.Shrink, AttachOptions.Expand, 0, 0);
            HeaderTable.Attach(new Label("Season: \t\t"), 0, 1, 1, 2, AttachOptions.Shrink, AttachOptions.Expand, 0, 0);
            HeaderTable.Attach(new Label(Original.Season.ToString()), 1, 2, 1, 2, AttachOptions.Shrink, AttachOptions.Expand, 0, 0);
            HeaderTable.Attach(new Label("Score: \t"), 0, 1, 2, 3, AttachOptions.Shrink, AttachOptions.Expand, 0, 0);
            HeaderTable.Attach(new Label(Original.Score.ToString(CultureInfo.InvariantCulture)), 1, 2, 2, 3, AttachOptions.Shrink, AttachOptions.Expand, 0, 0);
        }
Exemple #12
0
        /// <summary>
        /// Writes the <see cref="CPK"/> data to the output stream.
        /// </summary>
        /// <param name="output"></param>
        /// <returns></returns>
        public bool Save(Stream output)
        {
            using (var bw = new BinaryWriterX(output, true))
            {
                // TOC
                if (TocTable != null)
                {
                    // Files
                    var contentOffset = Convert.ToInt64(HeaderTable.Rows.First()["ContentOffset"].Value);
                    bw.BaseStream.Position = contentOffset;
                    foreach (var afi in Files)
                    {
                        var cfi = (CpkFileInfo)afi;

                        // Update the file offset.
                        cfi.Row["FileOffset"].Value = (ulong)(bw.BaseStream.Position - FileOffsetBase);

                        // Save the file.
                        cfi.SaveFile(bw.BaseStream);

                        // Update the sizes.
                        cfi.Row["FileSize"].Value    = (uint)cfi.CompressedLength;
                        cfi.Row["ExtractSize"].Value = (uint)cfi.FileLength;

                        // Align for the next file (except on the last file).
                        if (afi != Files.Last())
                        {
                            bw.WriteAlignment(Alignment);
                        }
                    }

                    // Update content size
                    var remainder = Alignment - bw.BaseStream.Position % Alignment;
                    HeaderTable.Rows.First()["ContentSize"].Value = (ulong)(bw.BaseStream.Position + remainder - contentOffset);

                    // TOC
                    bw.BaseStream.Position  = (long)(ulong)HeaderTable.Rows.First().Values["TocOffset"].Value;
                    TocTable.UtfObfuscation = false;
                    TocTable.Save(bw.BaseStream);

                    if (ETocTable != null)
                    {
                        // TODO: Support for ETOC saving.
                    }
                }
                else if (ITocTable != null)
                {
                    bw.Write(_unknownPostHeaderData);

                    ITocTable.UtfObfuscation = false;
                    ITocTable.Save(bw.BaseStream);
                }

                // Header
                bw.BaseStream.Position     = 0;
                HeaderTable.UtfObfuscation = false;
                HeaderTable.Save(bw.BaseStream);

                // Unknown block
                // TODO: Figure out how to handle this block as some files obfuscate almost the whole thing
                bw.Write(_unknownPostHeaderData);
            }

            return(true);
        }
        /**
         * Creates a new font descriptor dictionary for the given TTF.
         */
        private FontDescriptor CreateFontDescriptor(TrueTypeFont ttf)
        {
            FontDescriptor fd = new FontDescriptor(document, new PdfDictionary());

            fd.FontName = ttf.Name;

            OS2WindowsMetricsTable os2  = ttf.OS2Windows;
            PostScriptTable        post = ttf.PostScript;

            // Flags
            var flags = (FlagsEnum)0;

            flags |= (post.IsFixedPitch > 0 || ttf.HorizontalHeader.NumberOfHMetrics == 1) ? FlagsEnum.FixedPitch : 0;

            int fsSelection = os2.FsSelection;

            flags |= ((fsSelection & (ITALIC | OBLIQUE)) != 0) ? FlagsEnum.Italic : 0;

            switch (os2.FamilyClass)
            {
            case OS2WindowsMetricsTable.FAMILY_CLASS_CLAREDON_SERIFS:
            case OS2WindowsMetricsTable.FAMILY_CLASS_FREEFORM_SERIFS:
            case OS2WindowsMetricsTable.FAMILY_CLASS_MODERN_SERIFS:
            case OS2WindowsMetricsTable.FAMILY_CLASS_OLDSTYLE_SERIFS:
            case OS2WindowsMetricsTable.FAMILY_CLASS_SLAB_SERIFS:
                flags |= FlagsEnum.Serif;
                break;

            case OS2WindowsMetricsTable.FAMILY_CLASS_SCRIPTS:
                flags |= FlagsEnum.Script;
                break;

            default:
                break;
            }

            fd.FontWeight = os2.WeightClass;

            flags |= FlagsEnum.Symbolic;
            flags &= ~FlagsEnum.Nonsymbolic;

            fd.Flags = flags;
            // ItalicAngle
            fd.ItalicAngle = post.ItalicAngle;

            // FontBBox
            HeaderTable header  = ttf.Header;
            float       scaling = 1000f / header.UnitsPerEm;
            var         skRect  = new SKRect(
                header.XMin * scaling,
                header.YMin * scaling,
                header.XMax * scaling,
                header.YMax * scaling
                );


            Rectangle rect = new Rectangle(skRect);

            fd.FontBBox = rect;

            // Ascent, Descent
            HorizontalHeaderTable hHeader = ttf.HorizontalHeader;

            fd.Ascent  = hHeader.Ascender * scaling;
            fd.Descent = hHeader.Descender * scaling;

            // CapHeight, XHeight
            if (os2.Version >= 1.2)
            {
                fd.CapHeight = os2.CapHeight * scaling;
                fd.XHeight   = os2.Height * scaling;
            }
            else
            {
                var capHPath = ttf.GetPath("H");
                if (capHPath != null)
                {
                    fd.CapHeight = (float)Math.Round(capHPath.Bounds.Bottom * scaling);
                }
                else
                {
                    // estimate by summing the typographical +ve ascender and -ve descender
                    fd.CapHeight = os2.TypoAscender + (os2.TypoDescender * scaling);
                }
                var xPath = ttf.GetPath("x");
                if (xPath != null)
                {
                    fd.XHeight = (float)Math.Round(xPath.Bounds.Bottom * scaling);
                }
                else
                {
                    // estimate by halving the typographical ascender
                    fd.XHeight = os2.TypoAscender / (2.0f * scaling);
                }
            }

            // StemV - there's no true TTF equivalent of this, so we estimate it
            fd.StemV = skRect.Width * .13f;

            return(fd);
        }
Exemple #14
0
        private static TrueTypeFont ParseTables(float version, IReadOnlyDictionary <string, TrueTypeHeaderTable> tables, TrueTypeDataBytes data)
        {
            var isPostScript = tables.ContainsKey(TrueTypeHeaderTable.Cff);

            var builder = new TableRegister.Builder();

            if (!tables.TryGetValue(TrueTypeHeaderTable.Head, out var table))
            {
                throw new InvalidFontFormatException($"The {TrueTypeHeaderTable.Head} table is required.");
            }

            // head
            builder.HeaderTable = HeaderTable.Load(data, table);

            if (!tables.TryGetValue(TrueTypeHeaderTable.Hhea, out var hHead))
            {
                throw new InvalidFontFormatException("The horizontal header table is required.");
            }

            // hhea
            builder.HorizontalHeaderTable = TableParser.Parse <HorizontalHeaderTable>(hHead, data, builder);

            if (!tables.TryGetValue(TrueTypeHeaderTable.Maxp, out var maxHeaderTable))
            {
                throw new InvalidFontFormatException("The maximum profile table is required.");
            }

            // maxp
            builder.MaximumProfileTable = BasicMaximumProfileTable.Load(data, maxHeaderTable);

            // post
            if (tables.TryGetValue(TrueTypeHeaderTable.Post, out var postscriptHeaderTable))
            {
                builder.PostScriptTable = PostScriptTable.Load(data, postscriptHeaderTable, builder.MaximumProfileTable);
            }

            if (tables.TryGetValue(TrueTypeHeaderTable.Name, out var nameTable))
            {
                builder.NameTable = TableParser.Parse <NameTable>(nameTable, data, builder);
            }

            if (tables.TryGetValue(TrueTypeHeaderTable.Os2, out var os2Table))
            {
                builder.Os2Table = TableParser.Parse <Os2Table>(os2Table, data, builder);
            }

            if (!isPostScript)
            {
                if (!tables.TryGetValue(TrueTypeHeaderTable.Loca, out var indexToLocationHeaderTable))
                {
                    throw new InvalidFontFormatException("The location to index table is required for non-PostScript fonts.");
                }

                // loca
                builder.IndexToLocationTable =
                    IndexToLocationTable.Load(data, indexToLocationHeaderTable, builder);

                if (!tables.TryGetValue(TrueTypeHeaderTable.Glyf, out var glyphHeaderTable))
                {
                    throw new InvalidFontFormatException("The glyph table is required for non-PostScript fonts.");
                }

                // glyf
                builder.GlyphDataTable = GlyphDataTable.Load(data, glyphHeaderTable, builder);

                OptionallyParseTables(tables, data, builder);
            }

            return(new TrueTypeFont(version, tables, builder.Build()));
        }
Exemple #15
0
        public async Task C61_C62_C63()
        {
            using (var memoryPool = new MemoryPool())
                using (var channelFactory = new ChannelFactory(memoryPool))
                {
                    var channel     = channelFactory.CreateChannel();
                    var readerTable = new HeaderTable(256);
                    var writerTable = new HeaderTable(256);
                    try
                    {
                        var hex        = @"
4882 6402 5885 aec3 771a 4b61 96d0 7abe
9410 54d4 44a8 2005 9504 0b81 66e0 82a6
2d1b ff6e 919d 29ad 1718 63c7 8f0b 97c8
e9ae 82ae 43d3";
                        var readable   = HexToBuffer(ref hex);
                        var httpHeader = Hpack.ParseHttpHeader(ref readable, ref readerTable, memoryPool);
                        Assert.Equal(
                            @":status: 302
cache-control: private
date: Mon, 21 Oct 2013 20:13:21 GMT
location: https://www.example.com
", httpHeader.ToString());
                        Assert.Equal(
                            @"[1] (s = 63) location: https://www.example.com
[2] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT
[3] (s = 52) cache-control: private
[4] (s = 42) :status: 302
Table size: 222
", readerTable.ToString());

                        var wb = channel.Alloc();
                        Hpack.WriteHttpHeader(wb, httpHeader, ref writerTable, memoryPool);
                        Assert.Equal(hex, ToHex(wb));
                        await wb.FlushAsync();

                        Assert.Equal(
                            @"[1] (s = 63) location: https://www.example.com
[2] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT
[3] (s = 52) cache-control: private
[4] (s = 42) :status: 302
Table size: 222
", writerTable.ToString());

                        hex        = "4883 640e ffc1 c0bf";
                        readable   = HexToBuffer(ref hex);
                        httpHeader = Hpack.ParseHttpHeader(ref readable, ref readerTable, memoryPool);
                        Assert.Equal(
                            @":status: 307
cache-control: private
date: Mon, 21 Oct 2013 20:13:21 GMT
location: https://www.example.com
", httpHeader.ToString());
                        Assert.Equal(
                            @"[1] (s = 42) :status: 307
[2] (s = 63) location: https://www.example.com
[3] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT
[4] (s = 52) cache-control: private
Table size: 222
", readerTable.ToString());

                        wb = channel.Alloc();
                        Hpack.WriteHttpHeader(wb, httpHeader, ref writerTable, memoryPool);
                        Assert.Equal(hex, ToHex(wb));
                        await wb.FlushAsync();

                        Assert.Equal(
                            @"[1] (s = 42) :status: 307
[2] (s = 63) location: https://www.example.com
[3] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT
[4] (s = 52) cache-control: private
Table size: 222
", writerTable.ToString());

                        hex        = @"
88c1 6196 d07a be94 1054 d444 a820 0595
040b 8166 e084 a62d 1bff c05a 839b d9ab
77ad 94e7 821d d7f2 e6c7 b335 dfdf cd5b
3960 d5af 2708 7f36 72c1 ab27 0fb5 291f
9587 3160 65c0 03ed 4ee5 b106 3d50 07";
                        readable   = HexToBuffer(ref hex);
                        httpHeader = Hpack.ParseHttpHeader(ref readable, ref readerTable, memoryPool);
                        Assert.Equal(
                            @":status: 200
cache-control: private
date: Mon, 21 Oct 2013 20:13:22 GMT
location: https://www.example.com
content-encoding: gzip
set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
", httpHeader.ToString());
                        Assert.Equal(
                            @"[1] (s = 98) set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
[2] (s = 52) content-encoding: gzip
[3] (s = 65) date: Mon, 21 Oct 2013 20:13:22 GMT
Table size: 215
", readerTable.ToString());

                        wb = channel.Alloc();
                        Hpack.WriteHttpHeader(wb, httpHeader, ref writerTable, memoryPool);
                        Assert.Equal(hex, ToHex(wb));
                        await wb.FlushAsync();

                        Assert.Equal(
                            @"[1] (s = 98) set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
[2] (s = 52) content-encoding: gzip
[3] (s = 65) date: Mon, 21 Oct 2013 20:13:22 GMT
Table size: 215
", writerTable.ToString());
                    }
                    finally
                    {
                        readerTable.Dispose();
                        writerTable.Dispose();
                    }
                }
        }
Exemple #16
0
        /// <summary>
        /// Method that build a new FPTree starting from i-th header table entry
        /// </summary>
        /// <param name="i">index of header table entry (head of Conditional Pattern Base)</param>
        /// <returns>the created FPTree</returns>
        public FPTree CreateFPtree(int i)
        {
            FPNode ResultRootNode = new FPNode();
            FPTree Result         = new FPTree();

            Result.Root   = ResultRootNode;
            Result.MinSup = _minSup;

            // Counting the frequency of single items
            Dictionary <int, int> FrequencyItemCounter2 = new Dictionary <int, int>();

            Result.FrequencyItemCounter = FrequencyItemCounter2;


            FPNode node;

            //Obtain a reference to head of the list of the i.th htrecord
            node = ht.GetHead(i);

            while (node != default(FPNode))
            {
                int support;
                _travel = node;
                support = _travel.Count;
                _travel = _travel.Parent;
                if (_travel.Parent != default(FPNode))
                {
                    while (_travel.Parent != default(FPNode))
                    {
                        if (FrequencyItemCounter2.ContainsKey(_travel.Item))
                        {
                            FrequencyItemCounter2[_travel.Item] += support;
                        }
                        else
                        {
                            FrequencyItemCounter2.Add(_travel.Item, support);
                        }
                        _travel = _travel.Parent;
                    }
                }
                node = node.Next;
            }


            //Evaluate header table dimension
            int HTsize = 0;

            foreach (int item in FrequencyItemCounter2.Keys)
            {
                if (FrequencyItemCounter2[item] >= _minSup)
                {
                    HTsize++;
                }
            }

            HeaderTable newht = new HeaderTable(HTsize);

            Result.ht = newht;

            //Insertion of frequent items in header table
            foreach (KeyValuePair <int, int> coppia in FrequencyItemCounter2)
            {
                if (coppia.Value >= _minSup)
                {
                    newht.addRecord(coppia.Key, coppia.Value);
                }
            }

            // Removal of non frequent items, sorting and final insertion in the FPTreee
            node = ht.GetHead(i);
            while (node != default(FPNode))
            {
                _travel = node;
                ItemSet path = new ItemSet();
                path.ItemsSupport = _travel.Count;
                _travel           = _travel.Parent;
                if (_travel.Parent != default(FPNode))
                {
                    while (_travel.Parent != default(FPNode))
                    {
                        path.Add(_travel.Item);
                        _travel = _travel.Parent;
                    }
                    ItemSet SortedList = new ItemSet();
                    SortedList.ItemsSupport = path.ItemsSupport;
                    foreach (int item in path.Items)
                    {
                        if (FrequencyItemCounter2[item] >= _minSup)
                        {
                            SortedList.Add(item);
                        }
                    }
                    if (SortedList.Items.Count > 0)
                    {
                        SortedList.Items.Sort(new ItemSortingStrategy(FrequencyItemCounter2));
                        if (Result._depth < SortedList.ItemsNumber)
                        {
                            Result._depth = SortedList.ItemsNumber;
                        }
                        Result.AddItemSetTree(SortedList, ResultRootNode);
                    }
                }
                node = node.Next;
            }
            return(Result);
        }
        public void AddItem(HeaderItem itemType)
        {
            try
            {
                Label title = new Label
                {
                    Text      = itemType.Title,
                    Anchor    = AnchorStyles.Left,
                    TextAlign = ContentAlignment.MiddleLeft,
                    AutoSize  = true,
                };

                title.Font = new Font(title.Font, FontStyle.Bold);

                HeaderTable.Controls.Add(title, _column[_counter], _row);

                switch (itemType.InputType)
                {
                case "Text":
                    TextBox text = new TextBox
                    {
                        Anchor   = AnchorStyles.Left | AnchorStyles.Right,
                        AutoSize = true,
                        Text     = object.ReferenceEquals(itemType.ValueChosen, null) ? itemType.ValueItem[0] : itemType.ValueChosen,
                        Name     = "header" + itemType.Id,
                        Enabled  = enable
                    };
                    HeaderTable.Controls.Add(text, _column[_counter] + 1, _row);
                    HeaderTable.SetColumnSpan(text, 3);
                    break;

                case "List":
                    ComboBox list = new ComboBox
                    {
                        DropDownStyle = ComboBoxStyle.DropDownList,
                        Anchor        = AnchorStyles.Left | AnchorStyles.Right,
                        AutoSize      = true,
                        Name          = "header" + itemType.Id,
                        Enabled       = enable
                    };

                    foreach (string s in itemType.ValueItem)
                    {
                        list.Items.Add(s);
                    }

                    list.SelectedItem = object.ReferenceEquals(itemType.ValueChosen, null) ? null : itemType.ValueChosen;

                    HeaderTable.Controls.Add(list, _column[_counter] + 1, _row);
                    HeaderTable.SetColumnSpan(list, 3);
                    break;

                case "Date":
                    switch (itemType.ValueItem[0])
                    {
                    case "Manual":
                        DateTime time = string.IsNullOrEmpty(itemType.ValueChosen) ? DateTime.Now : DateTime.ParseExact(itemType.ValueChosen, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture);
                        //DateTime time = DateTime.Now;

                        DateTimePicker date = new DateTimePicker
                        {
                            Value        = time,
                            Format       = DateTimePickerFormat.Custom,
                            CustomFormat = @"dd/MM/yyyy",
                            Anchor       = AnchorStyles.Left | AnchorStyles.Right,
                            AutoSize     = true,
                            Name         = "header" + itemType.Id,
                            Enabled      = enable
                        };

                        HeaderTable.Controls.Add(date, _column[_counter] + 1, _row);
                        HeaderTable.SetColumnSpan(date, 3);
                        break;

                    case "Today":
                        //Label today = new Label { Text = object.ReferenceEquals(itemType.ValueChosen, null) ? DateTime.Today.ToShortDateString() : itemType.ValueChosen, TextAlign = ContentAlignment.BottomLeft, Anchor = AnchorStyles.Left, AutoSize = true, Name = "header" + itemType.Id };
                        TextBox today = new TextBox
                        {
                            Text     = string.IsNullOrEmpty(itemType.ValueChosen) ? DateTime.Today.ToShortDateString() : itemType.ValueChosen,
                            ReadOnly = true,
                            Anchor   = AnchorStyles.Left | AnchorStyles.Right,
                            AutoSize = true,
                            Name     = "header" + itemType.Id,
                            Enabled  = enable
                        };
                        HeaderTable.Controls.Add(today, _column[_counter] + 1, _row);
                        HeaderTable.SetColumnSpan(today, 3);
                        break;
                    }
                    break;

                case "Label":
                case "Query":
                    //Label label = new Label
                    //{
                    //    Text = object.ReferenceEquals(itemType.ValueChosen, null) ? itemType.ValueItem[0] : itemType.ValueChosen,
                    //    TextAlign = ContentAlignment.BottomLeft,
                    //    Anchor = AnchorStyles.Left,
                    //    AutoSize = true,
                    //    Name = "header" + itemType.Id
                    //};
                    TextBox label = new TextBox {
                        Text       = string.IsNullOrEmpty(itemType.ValueChosen) ? itemType.ValueItem[0] : itemType.ValueChosen
                        , ReadOnly = true, Anchor = AnchorStyles.Left | AnchorStyles.Right, AutoSize = true, Name = "header" + itemType.Id, Enabled = enable
                    };
                    HeaderTable.Controls.Add(label, _column[_counter] + 1, _row);
                    HeaderTable.SetColumnSpan(label, 3);
                    break;
                }

                _headeritems.Add(itemType);

                if (_counter >= 2)
                {
                    this.HeaderTable.RowStyles.Add(new RowStyle(SizeType.Absolute, 30));
                    _counter = 0;
                    _row++;
                }
                else
                {
                    _counter++;
                }
            }
            catch (Exception Ex)
            {
                MessageBox.Show(Ex.Message);
            }
        }
Exemple #18
0
        private static HeaderTable GetFullTable(string hcaFileName, string songName)
        {
            HcaInfo info;
            uint    lengthInSamples;
            float   lengthInSeconds;

            using (var fileStream = File.Open(hcaFileName, FileMode.Open, FileAccess.Read)) {
                var decoder = new OneWayHcaDecoder(fileStream);
                info            = decoder.HcaInfo;
                lengthInSamples = decoder.LengthInSamples;
                lengthInSeconds = decoder.LengthInSeconds;
            }
            var cue = new[] {
                new CueTable {
                    CueId               = 0,
                    ReferenceType       = 3,
                    ReferenceIndex      = 0,
                    UserData            = string.Empty,
                    WorkSize            = 0,
                    AisacControlMap     = null,
                    Length              = (uint)(lengthInSeconds * 1000),
                    NumAisacControlMaps = 0,
                    HeaderVisibility    = 1
                }
            };
            var cueName = new[] {
                new CueNameTable {
                    CueIndex = 0,
                    CueName  = songName
                }
            };
            var waveform = new[] {
                new WaveformTable {
                    Id            = 0,
                    EncodeType    = 2, // HCA
                    Streaming     = 0,
                    NumChannels   = (byte)info.ChannelCount,
                    LoopFlag      = 1,
                    SamplingRate  = (ushort)info.SamplingRate,
                    NumSamples    = lengthInSamples,
                    ExtensionData = ushort.MaxValue
                }
            };
            var synth = new[] {
                new SynthTable {
                    Type = 0,
                    VoiceLimitGroupName   = string.Empty,
                    CommandIndex          = ushort.MaxValue,
                    ReferenceItems        = new byte[] { 0x00, 0x01, 0x00, 0x00 },
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ControlWorkArea1      = 0,
                    ControlWorkArea2      = 0,
                    TrackValues           = null,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0
                }
            };
            var command = new[] {
                new CommandTable {
                    Command = new byte[0x0a] {
                        0x07, 0xd0, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00
                    }
                },
                new CommandTable {
                    Command = new byte[0x10] {
                        0x00, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x57, 0x02, 0x00, 0x32
                    }
                }
            };
            var track = new[] {
                new TrackTable {
                    EventIndex            = 0,
                    CommandIndex          = ushort.MaxValue,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    TargetType            = 0,
                    TargetName            = string.Empty,
                    TargetId      = uint.MaxValue,
                    TargetAcbName = string.Empty,
                    Scope         = 0,
                    TargetTrackNo = ushort.MaxValue
                }
            };
            var sequence = new[] {
                new SequenceTable {
                    PlaybackRatio         = 100,
                    NumTracks             = 1,
                    TrackIndex            = new byte[] { 0x00, 0x00 }, // {0x01, 0x00}
                    CommandIndex          = 1,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    TrackValues           = null,
                    Type             = 0,
                    ControlWorkArea1 = 0,
                    ControlWorkArea2 = 0
                }
            };
            var acfReference = new[] {
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "system",
                    Name2 = null,
                    Id    = 0
                },
                new AcfReferenceTable {
                    Name = "bgm",
                    Id   = 3
                }
            };
            var acbGuid = Guid.NewGuid();
            var hcaData = File.ReadAllBytes(hcaFileName);
            var header  = new HeaderTable {
                FileIdentifier = 0,
                Size           = 0,
                Version        = 0x01230100,
                Type           = 0,
                Target         = 0,
                AcfMd5Hash     = new byte[0x10] {
                    0x0e, 0xf7, 0x50, 0x41, 0x55, 0x0d, 0xda, 0xda, 0x89, 0xd0, 0x4e, 0x74, 0xbc, 0x91, 0x32, 0x2c
                },
                CategoryExtension         = 0,
                CueTable                  = cue,
                CueNameTable              = cueName,
                WaveformTable             = waveform,
                AisacTable                = null,
                GraphTable                = null,
                AisacNameTable            = null,
                GlobalAisacReferenceTable = null,
                SynthTable                = synth,
                CommandTable              = command,
                TrackTable                = track,
                SequenceTable             = sequence,
                AisacControlNameTable     = null,
                AutoModulationTable       = null,
                StreamAwbTocWorkOld       = null,
                AwbFile              = hcaData,
                VersionString        = StandardAcbVersionString,
                CueLimitWorkTable    = null,
                NumCueLimitListWorks = 0,
                NumCueLimitNodeWorks = 0,
                AcbGuid              = acbGuid.ToByteArray(),
                StreamAwbHash        = new byte[0x10],
                StreamAwbTocWork_Old = null,
                AcbVolume            = 1f,
                StringValueTable     = null,
                OutsideLinkTable     = null,
                BlockSequenceTable   = null,
                BlockTable           = null,
                Name = songName,
                CharacterEncodingType      = 0,
                EventTable                 = null,
                ActionTrackTable           = null,
                AcfReferenceTable          = acfReference,
                WaveformExtensionDataTable = null,
                BeatSyncInfoTable          = null,
                CuePriorityType            = byte.MaxValue,
                NumCueLimit                = 0,
                PaddingArea                = null,
                StreamAwbTocWork           = null,
                StreamAwbAfs2Header        = null
            };

            return(header);
        }
Exemple #19
0
        private static HeaderTable GetFullTable(string hcaFileName, string songName)
        {
            HcaInfo info;
            uint    lengthInSamples;
            float   lengthInSeconds;

            using (var fileStream = File.Open(hcaFileName, FileMode.Open, FileAccess.Read)) {
                var decoder = new OneWayHcaDecoder(fileStream);
                info            = decoder.HcaInfo;
                lengthInSamples = decoder.LengthInSamples;
                lengthInSeconds = decoder.LengthInSeconds;
            }
            var cue = new[] {
                new CueTable {
                    AisacControlMap     = null,
                    CueId               = 0,
                    HeaderVisibility    = 1,
                    NumAisacControlMaps = 0,
                    ReferenceType       = 3,
                    UserData            = string.Empty,
                    ReferenceIndex      = 0,
                    Worksize            = 0,
                    Length              = (uint)Math.Round(lengthInSeconds * 1000)
                },
                new CueTable {
                    AisacControlMap     = null,
                    CueId               = 1,
                    HeaderVisibility    = 1,
                    NumAisacControlMaps = 0,
                    ReferenceType       = 3,
                    UserData            = string.Empty,
                    ReferenceIndex      = 1,
                    Worksize            = 0,
                    Length              = 0xffffffff
                },
                new CueTable {
                    AisacControlMap     = null,
                    CueId               = 2,
                    HeaderVisibility    = 1,
                    NumAisacControlMaps = 0,
                    ReferenceType       = 3,
                    UserData            = string.Empty,
                    ReferenceIndex      = 2,
                    Worksize            = 0,
                    Length              = 0xffffffff
                }
            };
            var cueName = new[] {
                new CueNameTable {
                    CueName  = songName + "_bgm",
                    CueIndex = 0
                },
                new CueNameTable {
                    CueName  = songName + "_bgm_preview",
                    CueIndex = 1
                },
                new CueNameTable {
                    CueName  = songName + "_bgm_soundcheck",
                    CueIndex = 2
                }
            };
            var waveform = new[] {
                new WaveformTable {
                    MemoryAwbId     = 0,
                    EncodeType      = 2, // HCA
                    Streaming       = 0,
                    NumChannels     = (byte)info.ChannelCount,
                    LoopFlag        = 1,
                    SamplingRate    = (ushort)info.SamplingRate,
                    NumSamples      = lengthInSamples,
                    ExtensionData   = ushort.MaxValue,
                    StreamAwbPortNo = ushort.MaxValue,
                    StreamAwbId     = ushort.MaxValue
                }
            };
            var synth = new[] {
                new SynthTable {
                    VoiceLimitGroupName = string.Empty,
                    Type = 0,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    CommandIndex          = 65535,
                    ControlWorkArea1      = 0,
                    ControlWorkArea2      = 0,
                    LocalAisacs           = null,
                    TrackValues           = null,
                    ReferenceItems        = new byte[] { 0x00, 0x01, 0x00, 0x00 }
                },
                new SynthTable {
                    VoiceLimitGroupName = string.Empty,
                    Type = 0,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    CommandIndex          = 0,
                    ControlWorkArea1      = 1,
                    ControlWorkArea2      = 1,
                    LocalAisacs           = null,
                    TrackValues           = null,
                    ReferenceItems        = new byte[] { 0x00, 0x01, 0x00, 0x00 }
                },
                new SynthTable {
                    VoiceLimitGroupName = string.Empty,
                    Type = 0,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    CommandIndex          = 1,
                    ControlWorkArea1      = 2,
                    ControlWorkArea2      = 2,
                    LocalAisacs           = null,
                    TrackValues           = null,
                    ReferenceItems        = new byte[] { 0x00, 0x01, 0x00, 0x00 }
                }
            };
            var seqCommand = new[] {
                new SeqCommandTable {
                    Command = new byte[29] {
                        0x00, 0x41, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0a, 0x00,
                        0x6f, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0x04, 0x00, 0x03, 0x27, 0x10
                    }
                },
                new SeqCommandTable {
                    Command = new byte[31] {
                        0x00, 0x41, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x00,
                        0x6e, 0x01, 0x01, 0x00, 0x57, 0x02, 0x00, 0x23, 0x00, 0x6f, 0x04, 0x00, 0x00, 0x27, 0x10
                    }
                }
            };
            var track = new[] {
                new TrackTable {
                    CommandIndex          = ushort.MaxValue,
                    EventIndex            = 0,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    TargetType            = 0,
                    TargetName            = string.Empty,
                    TargetId      = uint.MaxValue,
                    TargetAcbName = string.Empty,
                    Scope         = 0,
                    TargetTrackNo = ushort.MaxValue
                },
                new TrackTable {
                    CommandIndex          = ushort.MaxValue,
                    EventIndex            = 1,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    TargetType            = 0,
                    TargetName            = string.Empty,
                    TargetId      = uint.MaxValue,
                    TargetAcbName = string.Empty,
                    Scope         = 0,
                    TargetTrackNo = ushort.MaxValue
                },
                new TrackTable {
                    CommandIndex          = ushort.MaxValue,
                    EventIndex            = 2,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    TargetType            = 0,
                    TargetName            = string.Empty,
                    TargetId      = uint.MaxValue,
                    TargetAcbName = string.Empty,
                    Scope         = 0,
                    TargetTrackNo = ushort.MaxValue
                }
            };
            var sequence = new[] {
                new SequenceTable {
                    PlaybackRatio         = 100,
                    NumTracks             = 1,
                    TrackIndex            = new byte[] { 0x00, 0x00 },
                    CommandIndex          = 0,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    TrackValues           = null,
                    Type             = 0,
                    ControlWorkArea1 = 0,
                    ControlWorkArea2 = 0
                },
                new SequenceTable {
                    PlaybackRatio         = 100,
                    NumTracks             = 1,
                    TrackIndex            = new byte[] { 0x00, 0x01 },
                    CommandIndex          = 1,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    TrackValues           = null,
                    Type             = 0,
                    ControlWorkArea1 = 1,
                    ControlWorkArea2 = 1
                },
                new SequenceTable {
                    PlaybackRatio         = 100,
                    NumTracks             = 1,
                    TrackIndex            = new byte[] { 0x00, 0x02 },
                    CommandIndex          = 1,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    TrackValues           = null,
                    Type             = 0,
                    ControlWorkArea1 = 2,
                    ControlWorkArea2 = 2
                }
            };
            var stringValue = new[] {
                new StringValueTable {
                    StringValue = "MasterOut"
                },
                new StringValueTable {
                    StringValue = "bus_reverb"
                },
                new StringValueTable {
                    StringValue = "bus_voice_rip"
                },
                new StringValueTable {
                    StringValue = "stage_master"
                },
                new StringValueTable {
                    StringValue = string.Empty
                }
            };
            var acfReference = new[] {
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "master",
                    Name2 = string.Empty,
                    Id    = 1
                },
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "song_option",
                    Name2 = string.Empty,
                    Id    = 4,
                },
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "song_submix",
                    Name2 = string.Empty,
                    Id    = 10
                },
                new AcfReferenceTable {
                    Type  = 9,
                    Name  = "MasterOut",
                    Name2 = string.Empty,
                    Id    = uint.MaxValue
                },
                new AcfReferenceTable {
                    Type  = 9,
                    Name  = "bus_reverb",
                    Name2 = string.Empty,
                    Id    = uint.MaxValue
                },
                new AcfReferenceTable {
                    Type  = 9,
                    Name  = "bus_voice_rip",
                    Name2 = string.Empty,
                    Id    = uint.MaxValue
                },
                new AcfReferenceTable {
                    Type  = 9,
                    Name  = "stage_master",
                    Name2 = string.Empty,
                    Id    = uint.MaxValue
                },
                new AcfReferenceTable {
                    Type  = 9,
                    Name  = string.Empty,
                    Name2 = string.Empty,
                    Id    = uint.MaxValue
                },
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "bgm_option",
                    Name2 = string.Empty,
                    Id    = 3
                },
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "bgm_submix",
                    Name2 = string.Empty,
                    Id    = 9
                }
            };
            var synthCommand = new[] {
                new SynthCommandTable {
                    Command = new byte[14] {
                        0x00, 0x24, 0x04, 0x05, 0xdc, 0x01, 0xc8, 0x00, 0x28, 0x04, 0x05, 0xeb, 0x02, 0xc8
                    }
                },
                new SynthCommandTable {
                    Command = new byte[7] {
                        0x00, 0x28, 0x04, 0x05, 0xeb, 0x02, 0xc8
                    }
                }
            };
            var trackEvent = new[] {
                new TrackEventTable {
                    Command = new byte[10] {
                        0x07, 0xd0, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00
                    }
                },
                new TrackEventTable {
                    Command = new byte[27] {
                        0x03, 0xe7, 0x04, 0x00, 0x01, 0x28, 0xe0, 0x07, 0xd0, 0x04, 0x00, 0x02, 0x00, 0x01, 0x07, 0xd1,
                        0x04, 0x00, 0x01, 0x77, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x00, 0x00
                    }
                },
                new TrackEventTable {
                    Command = new byte[10] {
                        0x07, 0xd0, 0x04, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00
                    }
                }
            };
            var hcaData = File.ReadAllBytes(hcaFileName);
            var header  = new HeaderTable {
                FileIdentifier             = 0,
                Size                       = 0,
                Version                    = 0x01290000,
                Type                       = 0,
                Target                     = 0,
                CategoryExtension          = 0,
                NumCueLimitListWorks       = 0,
                NumCueLimitNodeWorks       = 0,
                AcbVolume                  = 1,
                CharacterEncodingType      = 0,
                CuePriorityType            = byte.MaxValue,
                NumCueLimit                = 0,
                VersionString              = StandardAcbVersionString,
                Name                       = songName,
                AcfMd5Hash                 = Guid.NewGuid().ToByteArray(),
                AisacTable                 = null,
                GraphTable                 = null,
                GlobalAisacReferenceTable  = null,
                AisacNameTable             = null,
                AisacControlNameTable      = null,
                AutoModulationTable        = null,
                StreamAwbTocWorkOld        = null,
                CueLimitWorkTable          = null,
                StreamAwbTocWork_Old       = null,
                OutsideLinkTable           = null,
                BlockSequenceTable         = null,
                BlockTable                 = null,
                EventTable                 = null,
                ActionTrackTable           = null,
                WaveformExtensionDataTable = null,
                BeatSyncInfoTable          = null,
                TrackCommandTable          = null,
                SeqParameterPalletTable    = null,
                TrackParameterPalletTable  = null,
                SynthParameterPalletTable  = null,
                PaddingArea                = null,
                StreamAwbTocWork           = null,
                StreamAwbAfs2Header        = null,
                CueTable                   = cue,
                CueNameTable               = cueName,
                WaveformTable              = waveform,
                SynthTable                 = synth,
                SeqCommandTable            = seqCommand,
                TrackTable                 = track,
                SequenceTable              = sequence,
                AwbFile                    = hcaData,
                AcbGuid                    = Guid.NewGuid().ToByteArray(),
                StreamAwbHash              = Guid.Empty.ToByteArray(),
                StringValueTable           = stringValue,
                AcfReferenceTable          = acfReference,
                SynthCommandTable          = synthCommand,
                TrackEventTable            = trackEvent
            };

            return(header);
        }
Exemple #20
0
        public async Task C51_C52_C53()
        {
            using (var memoryPool = new MemoryPool())
                using (var channelFactory = new ChannelFactory(memoryPool))
                {
                    var channel     = channelFactory.CreateChannel();
                    var readerTable = new HeaderTable(256);
                    var writerTable = new HeaderTable(256);
                    try
                    {
                        var hex        = @"
4803 3330 3258 0770 7269 7661 7465 611d
4d6f 6e2c 2032 3120 4f63 7420 3230 3133
2032 303a 3133 3a32 3120 474d 546e 1768
7474 7073 3a2f 2f77 7777 2e65 7861 6d70
6c65 2e63 6f6d";
                        var readable   = HexToBuffer(ref hex);
                        var httpHeader = Hpack.ParseHttpHeader(ref readable, ref readerTable, memoryPool);
                        Assert.Equal(
                            @":status: 302
cache-control: private
date: Mon, 21 Oct 2013 20:13:21 GMT
location: https://www.example.com
", httpHeader.ToString());
                        Assert.Equal(
                            @"[1] (s = 63) location: https://www.example.com
[2] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT
[3] (s = 52) cache-control: private
[4] (s = 42) :status: 302
Table size: 222
", readerTable.ToString());

                        var wb = channel.Alloc();
                        Hpack.WriteHttpHeader(wb, httpHeader, ref writerTable, memoryPool);
                        Assert.Equal(hex, ToHex(wb));
                        await wb.FlushAsync();

                        Assert.Equal(
                            @"[1] (s = 63) location: https://www.example.com
[2] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT
[3] (s = 52) cache-control: private
[4] (s = 42) :status: 302
Table size: 222
", writerTable.ToString());

                        hex        = "4803 3330 37c1 c0bf";
                        readable   = HexToBuffer(ref hex);
                        httpHeader = Hpack.ParseHttpHeader(ref readable, ref readerTable, memoryPool);
                        Assert.Equal(
                            @":status: 307
cache-control: private
date: Mon, 21 Oct 2013 20:13:21 GMT
location: https://www.example.com
", httpHeader.ToString());
                        Assert.Equal(
                            @"[1] (s = 42) :status: 307
[2] (s = 63) location: https://www.example.com
[3] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT
[4] (s = 52) cache-control: private
Table size: 222
", readerTable.ToString());

                        wb = channel.Alloc();
                        Hpack.WriteHttpHeader(wb, httpHeader, ref writerTable, memoryPool);
                        Assert.Equal(hex, ToHex(wb));
                        await wb.FlushAsync();

                        Assert.Equal(
                            @"[1] (s = 42) :status: 307
[2] (s = 63) location: https://www.example.com
[3] (s = 65) date: Mon, 21 Oct 2013 20:13:21 GMT
[4] (s = 52) cache-control: private
Table size: 222
", writerTable.ToString());

                        hex        = @"
88c1 611d 4d6f 6e2c 2032 3120 4f63 7420
3230 3133 2032 303a 3133 3a32 3220 474d
54c0 5a04 677a 6970 7738 666f 6f3d 4153
444a 4b48 514b 425a 584f 5157 454f 5049
5541 5851 5745 4f49 553b 206d 6178 2d61
6765 3d33 3630 303b 2076 6572 7369 6f6e
3d31";
                        readable   = HexToBuffer(ref hex);
                        httpHeader = Hpack.ParseHttpHeader(ref readable, ref readerTable, memoryPool);
                        Assert.Equal(
                            @":status: 200
cache-control: private
date: Mon, 21 Oct 2013 20:13:22 GMT
location: https://www.example.com
content-encoding: gzip
set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
", httpHeader.ToString());
                        Assert.Equal(
                            @"[1] (s = 98) set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
[2] (s = 52) content-encoding: gzip
[3] (s = 65) date: Mon, 21 Oct 2013 20:13:22 GMT
Table size: 215
", readerTable.ToString());

                        wb = channel.Alloc();
                        Hpack.WriteHttpHeader(wb, httpHeader, ref writerTable, memoryPool);
                        Assert.Equal(hex, ToHex(wb));
                        await wb.FlushAsync();

                        Assert.Equal(
                            @"[1] (s = 98) set-cookie: foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU; max-age=3600; version=1
[2] (s = 52) content-encoding: gzip
[3] (s = 65) date: Mon, 21 Oct 2013 20:13:22 GMT
Table size: 215
", writerTable.ToString());
                    }
                    finally
                    {
                        readerTable.Dispose();
                        writerTable.Dispose();
                    }
                }
        }
Exemple #21
0
 public TrueTypeFont(decimal version, IReadOnlyDictionary <string, TrueTypeHeaderTable> tables, HeaderTable headerTable)
 {
     Version     = version;
     Tables      = tables;
     HeaderTable = headerTable;
 }