Example #1
0
        /**
         * バイナリログの画像ID情報を読み込む
         */
        private MemIconImages ReadLogImagesBin(UFileStream fs)
        {
            MemIconImages _images = new MemIconImages();

            // 件数取得
            int size = fs.GetInt32();

            for (int i = 0; i < size; i++)
            {
                // 1件分のログを取得
                MemIconImage image = new MemIconImage();

                // 名前
                image.Name = fs.GetSizeString();

                // 画像
                int imageSize = fs.GetInt32();
                if (imageSize > 0)
                {
                    byte[] byteImage = fs.GetBytes(imageSize);
                    image.SetByteImage(byteImage);
                }

                _images.Add(image);
            }

            return(_images);
        }
Example #2
0
        /**
         * 1行分のIconImage情報を取得する
         */
        private MemIconImages GetIconImagesText(StreamReader sr)
        {
            MemIconImages _images = new MemIconImages();

            while (!sr.EndOfStream)
            {
                string line = sr.ReadLine().Trim();
                Dictionary <string, string> fields = SplitLineStr(line);

                if (fields.Count == 0)
                {
                    continue;
                }
                // 終了判定
                if (line.Equals("</image>"))
                {
                    break;
                }

                // 画像情報を取得
                MemIconImage image = new MemIconImage();

                foreach (KeyValuePair <string, string> kvp in fields)
                {
                    // keyとvalueに分割
                    if (kvp.Value != null)
                    {
                        switch (kvp.Key.ToLower())
                        {
                        case "name":
                            image.Name = kvp.Value;
                            break;

                        case "image":
                            try
                            {
                                // Base64文字列を出コード
                                byte[] byteImage = Convert.FromBase64String(kvp.Value);
                                image.SetByteImage(byteImage);
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine("base64のデコードに失敗しました。");
                            }
                            break;
                        }
                    }
                }
                _images.Add(image);
            }
            return(_images);
        }
Example #3
0
        /**
         * バイナリログのヘッダ部分を取得
         * @input fs : ファイルオブジェクト
         *
         */
        private void ReadLogHeadBin(UFileStream fs)
        {
            // 文字コードを取得
            string encStr = fs.GetSizeString();

            this.encoding   = UUtility.GetEncodingFromStr(encStr);
            fs.EncodingType = encoding;

            // ログID情報
            logIDs = ReadLogIDsBin(fs);

            // レーン情報
            lanes = ReadLogLanesBin(fs);

            // アイコン画像
            images = ReadLogImagesBin(fs);

            // ログIDの画像を設定する
            foreach (LogID logId in logIDs)
            {
                logId.Image = images.GetImage(logId.ImageName);
            }
        }
Example #4
0
        /**
         * テキスト形式のログファイルを読み込んでメモリに展開する
         * @input inputFilePath: ログファイルのパス
         * @output : true:成功 / false:失敗
         */
        private bool ReadLogFileText(string inputFilePath)
        {
            bool isHeader = false;

            // まずはヘッダ部分からエンコードタイプを取得する
            encoding = GetEncodingText(inputFilePath);

            using (StreamReader sr = new StreamReader(inputFilePath, encoding))
            {
                // データ種別部分をスキップ
                sr.ReadLine();

                // ヘッダ部分を読み込む <head>~</head>
                while (!sr.EndOfStream)
                {
                    // ファイルを 1 行ずつ読み込む
                    string line = sr.ReadLine().Trim();

                    // <head>の行が見つかるまではスキップ
                    if (isHeader == false)
                    {
                        if (line.Equals("<head>"))
                        {
                            isHeader = true;
                        }
                    }
                    else
                    {
                        if (line.Equals("</head>"))
                        {
                            break;
                        }
                        Dictionary <string, string> fields = SplitLineStr(line, ',', ':');

                        // ヘッダーの読み込みメイン
                        switch (line)
                        {
                        case "<lane>":
                            lanes = GetLanesText(sr);
                            break;

                        case "<logid>":
                            logIDs = GetLogIDsText(sr);
                            break;

                        case "<image>":
                            images = GetIconImagesText(sr);
                            break;
                        }
                    }
                }

                // 本体部分を読み込む
                bool isBody = false;
                while (!sr.EndOfStream)
                {
                    // ファイルを 1 行ずつ読み込む
                    string line = sr.ReadLine().Trim();

                    // <body>を見つけたら本体の取得モードに入る
                    if (!isBody)
                    {
                        if (line.Equals("<body>"))
                        {
                            isBody = true;
                        }
                    }
                    else
                    {
                        areaManager = GetLogDataText(sr);
                    }
                }
            }
            return(true);
        }