Пример #1
0
        // メソッド

        public void t読み込み(string boxdefファイル名)
        {
            Encoding boxdefEnc = CJudgeTextEncoding.JudgeFileEncoding(boxdefファイル名);

            using (StreamReader reader = new StreamReader(boxdefファイル名, boxdefEnc))
            {
                string str = null;
                while ((str = reader.ReadLine()) != null)
                {
                    if (str.Length != 0)
                    {
                        try
                        {
                            char[] ignoreCharsWoColon = new char[] { ' ', '\t' };

                            str = str.TrimStart(ignoreCharsWoColon);
                            if ((str[0] == '#') && (str[0] != ';'))
                            {
                                if (str.IndexOf(';') != -1)
                                {
                                    str = str.Substring(0, str.IndexOf(';'));
                                }

                                char[] ignoreChars = new char[] { ':', ' ', '\t' };

                                if (str.StartsWith("#TITLE", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.Title = str.Substring(6).Trim(ignoreChars);
                                }
                                else if (str.StartsWith("#GENRE", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.Genre = str.Substring(6).Trim(ignoreChars);
                                }
                                else if (str.StartsWith("#FONTCOLOR", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.Color = ColorTranslator.FromHtml(str.Substring(10).Trim(ignoreChars));
                                }
                                else if (str.StartsWith("#FORECOLOR", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.ForeColor     = ColorTranslator.FromHtml(str.Substring(10).Trim(ignoreChars));
                                    IsChangedForeColor = true;
                                }
                                else if (str.StartsWith("#BACKCOLOR", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.BackColor     = ColorTranslator.FromHtml(str.Substring(10).Trim(ignoreChars));
                                    IsChangedBackColor = true;
                                }
                            }
                            continue;
                        }
                        catch (Exception e)
                        {
                            Trace.TraceError(e.ToString());
                            Trace.TraceError("例外が発生しましたが処理を継続します。 (178a9a36-a59e-4264-8e4c-b3c3459db43c)");
                            continue;
                        }
                    }
                }
            }
        }
Пример #2
0
        // メソッド

        public void tLoad(string boxdefFileName)
        {
            Encoding boxdefEnc = CJudgeTextEncoding.JudgeFileEncoding(boxdefFileName);

            using (StreamReader reader = new StreamReader(boxdefFileName, boxdefEnc))
            {
                string str = null;
                while ((str = reader.ReadLine()) != null)
                {
                    if (str.Length != 0)
                    {
                        try
                        {
                            char[] ignoreCharsWoColon = new char[] { ' ', '\t' };

                            str = str.TrimStart(ignoreCharsWoColon);
                            if ((str[0] == '#') && (str[0] != ';'))
                            {
                                if (str.IndexOf(';') != -1)
                                {
                                    str = str.Substring(0, str.IndexOf(';'));
                                }

                                char[] ignoreChars = new char[] { ':', ' ', '\t' };

                                if (str.StartsWith("#TITLE", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.Title = str.Substring(6).Trim(ignoreChars);
                                }
                                else if (str.StartsWith("#GENRE", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.Genre = str.Substring(6).Trim(ignoreChars);
                                }
                                else if (str.StartsWith("#FORECOLOR", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.ForeColor = ColorTranslator.FromHtml(str.Substring(10).Trim(ignoreChars));
                                }
                                else if (str.StartsWith("#BACKCOLOR", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.BackColor = ColorTranslator.FromHtml(str.Substring(10).Trim(ignoreChars));
                                }
                            }
                            continue;
                        }
                        catch (Exception e)
                        {
                            Trace.TraceError(e.ToString());
                            Trace.TraceError("An exception has occurred, but processing continues.");
                            continue;
                        }
                    }
                }
            }
        }