Example #1
0
        public void Test003()
        {
            var rotateCount = 0;
            var rotateWord  = new Func <string>(() =>
            {
                var wordList = new string[]
                {
                    "トヨタ自動車",
                    "日産自動車",
                    "本田技研",
                    "スバル自動車",

                    "東急電鉄",
                    "東武鉄道",
                    "京成電鉄",
                    "京浜急行電鉄",
                    "相模鉄道",
                    "小田急電鉄",
                    "京王電鉄",
                    "西武鉄道",

                    "日本テレビ",
                    "フジテレビ",
                    "TBS",
                    "テレビ朝日",
                    "テレビ東京",
                };
                rotateCount = (rotateCount + 1) % wordList.Length;

                return(wordList[rotateCount]);
            });

            var props = new Props();

            for (var i = 0; i < 100; i++)
            {
                var sect = new PropSection(String.Format("DEBUG_SECT_{0:000}", i));
                for (var j = 0; j < 500; j++)
                {
                    var item = new PropItem(
                        String.Format("DEBUG_{0:000}-{1:0000}", i, j),
                        PropType.String,
                        rotateWord());
                    sect.Items.Add(item);
                }
                props.Sections.Add(sect);
            }

            using (var fs = File.OpenWrite(".\\QuickTest-Test003.txt"))
                using (var pw = new PropWriter(fs))
                {
                    pw.Write(props);
                }
        }
Example #2
0
        public void Test001()
        {
            //
            // TODO: テスト ロジックをここに追加してください
            //

            using (var fs = File.OpenWrite(".\\QuickTest-Test001.txt"))
                using (var pw = new PropWriter(fs))
                {
                    pw.Write(new Props(new PropSectionCollection()
                    {
                        new PropSection("PropSection01", new PropItemCollection()
                        {
                            new PropItem("PropItem01-001", PropType.String, "hello"),
                            new PropItem("PropItem01-002", PropType.String, "world!!"),
                            new PropItem("PropItem01-003", PropType.String, "こんにちは"),
                            new PropItem("PropItem01-004", PropType.DateTime, DateTime.Parse("1970/01/01 00:00:00.000")),
                        }),

                        new PropSection("PropSection02", new PropItemCollection()
                        {
                            new PropItem("PropItem02-001", PropType.String, "りんご"),
                            new PropItem("PropItem02-002", PropType.String, "アップル"),
                            new PropItem("PropItem02-003", PropType.String, "エイッポゥ"),
                            new PropItem("PropItem02-004", PropType.Int16, Int16.MaxValue),
                            new PropItem("PropItem02-004", PropType.Int32, Int32.MaxValue),
                            new PropItem("PropItem02-004", PropType.Int64, Int64.MaxValue),
                        }),

                        new PropSection("PropSection03", new PropItemCollection()
                        {
                            new PropItem("PropItem03-001", PropType.InversedString, "りんご"),
                            new PropItem("PropItem03-002", PropType.InversedString, "林檎"),
                            new PropItem("PropItem03-003", PropType.InversedString, "Apple"),
                            new PropItem("PropItem03-004", PropType.Guid, Guid.Parse("35B9E3E5-FDCC-4F47-8C64-35DE4D521103")),
                        }),

                        new PropSection("PropSection04", new PropItemCollection()
                        {
                            new PropItem("PropItem03-001", PropType.InversedString, "私(わたくし)はその人を常に先生と呼んでいた。だからここでもただ先生と書くだけで本名は打ち明けない。これは世間を憚(はば)かる遠慮というよりも、その方が私にとって自然だからである。私はその人の記憶を呼び起すごとに、すぐ「先生」といいたくなる。筆を執(と)っても心持は同じ事である。よそよそしい頭文字(かしらもじ)などはとても使う気にならない。"),
                        }),
                    }));
                }
        }
Example #3
0
        public static void SaveTo(Stream outputStream, PixelArtDocument document)
        {
            // パレットの生成
            var itemPalette = new List <IMCItem>();

            foreach (var item in document.Pixels)
            {
                if (itemPalette.Contains(item) == false)
                {
                    itemPalette.Add(item);
                }
            }

            // ピクセル データのインデックス変換
            var pixelValues = document.Pixels.Select(item => (short)itemPalette.IndexOf(item)).ToArray();

            // 書き出し
            using (var binaryWriter = new BinaryWriter(outputStream))
            {
                binaryWriter.Write(_fileMn);
                using (var propWriter = new PropWriter(outputStream))
                {
                    var metaSec = new PropSection("mcpixart-file-meta");
                    metaSec.Items.Add(new PropItem("magic-number", PropType.String, "  MCPIXART  "));
                    metaSec.Items.Add(new PropItem("file-description", PropType.String, " This is MC Pixel Art Navi Document File. Please visit our web site: https://www.a32kita.net/ "));
                    metaSec.Items.Add(new PropItem("file-version", PropType.Int64, 1L));
                    metaSec.Items.Add(new PropItem("created-at", PropType.DateTime, DateTime.Now));

                    var docSec = new PropSection("mcpixart-file-doc");
                    docSec.Items.Add(new PropItem("document-title", PropType.String, document.DocumentTitle));
                    docSec.Items.Add(new PropItem("document-author", PropType.String, document.DocumentAuthor));
                    docSec.Items.Add(new PropItem("document-description", PropType.String, document.DocumentDescription));
                    docSec.Items.Add(new PropItem("art-size", PropType.Int16, (short)document.Size));
                    docSec.Items.Add(new PropItem("art-palette", PropType.StringArray, itemPalette.Select(item => item.ItemId).ToArray()));
                    docSec.Items.Add(new PropItem("art-pixels", PropType.Int16Array, pixelValues));

                    propWriter.Write(new Props(new PropSection[] { metaSec, docSec }));
                }
            }
        }