context: using System;
  using System.Collections.Generic;
  using System.Reflection;
  using System.Runtime.CompilerServices;
  using System.Text.RegularExpressions;
  using System.Windows;
  using System.Xml.Serialization;
  
  namespace Kasuga
  {
  	[Serializable]
  	public class Word
  	{
  		[XmlIgnore]
  		public double? Angle
  		{
  			get
  			{
  				double? nullable;
  				try
  				{
  					double angle = this.TextCharactors[0].Angle;
  					foreach (Charactor textCharactor in this.TextCharactors)
  					{
  						if (angle == textCharactor.Angle)
  						{
  							continue;
  						}
  						nullable = null;
  						return nullable;
  					}
  					foreach (Charactor rubyCharactor in this.RubyCharactors)
  					{
  						if (angle == rubyCharactor.Angle)
  						{
  							continue;
  						}
  						nullable = null;
  						return nullable;
  					}
  					nullable = new double?(angle);
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					nullable = null;
  				}
  				return nullable;
  			}
  			set
  			{
  				try
  				{
  					double? angle = this.Angle;
  					double? nullable = value;
  					if (((double)angle.GetValueOrDefault() != (double)nullable.GetValueOrDefault() ? true : angle.HasValue != nullable.HasValue) && value.HasValue)
  					{
  						double num = (double)value.Value;
  						this.DefaultAngle = num;
  						foreach (Charactor textCharactor in this.TextCharactors)
  						{
  							textCharactor.Angle = num;
  						}
  						foreach (Charactor rubyCharactor in this.RubyCharactors)
  						{
  							rubyCharactor.Angle = num;
  						}
  					}
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  				}
  			}
  		}
  
  		[XmlIgnore]
  		public List<Charactor> Charactors
  		{
  			get
  			{
  				List<Charactor> charactors;
  				try
  				{
  					List<Charactor> charactors1 = new List<Charactor>();
  					foreach (Charactor textCharactor in this.TextCharactors)
  					{
  						charactors1.Add(textCharactor);
  					}
  					foreach (Charactor rubyCharactor in this.RubyCharactors)
  					{
  						charactors1.Add(rubyCharactor);
  					}
  					charactors = charactors1;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					charactors = null;
  				}
  				return charactors;
  			}
  		}
  
  		[XmlIgnore]
  		public string ColorSetName
  		{
  			get
  			{
  				string empty;
  				try
  				{
  					string colorSetName = this.TextCharactors[0].ColorSetName;
  					foreach (Charactor textCharactor in this.TextCharactors)
  					{
  						if (colorSetName == textCharactor.ColorSetName)
  						{
  							continue;
  						}
  						empty = string.Empty;
  						return empty;
  					}
  					foreach (Charactor rubyCharactor in this.RubyCharactors)
  					{
  						if (colorSetName == rubyCharactor.ColorSetName)
  						{
  							continue;
  						}
  						empty = string.Empty;
  						return empty;
  					}
  					empty = colorSetName;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					empty = string.Empty;
  				}
  				return empty;
  			}
  			set
  			{
  				try
  				{
  					if (this.ColorSetName != value && value != string.Empty)
  					{
  						this.DefaultColorSetName = value;
  						foreach (Charactor textCharactor in this.TextCharactors)
  						{
  							textCharactor.ColorSetName = value;
  						}
  						foreach (Charactor rubyCharactor in this.RubyCharactors)
  						{
  							rubyCharactor.ColorSetName = value;
  						}
  					}
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  				}
  			}
  		}
  
  		public double DefaultAngle
  		{
  			get;
  			set;
  		}
  
  		public string DefaultColorSetName
  		{
  			get;
  			set;
  		}
  
  		public string DefaultFontSetName
  		{
  			get;
  			set;
  		}
  
  		public double DistanceToRuby
  		{
  			get;
  			set;
  		}
  
  		[XmlIgnore]
  		public PlayTime FirstSingStart
  		{
  			get
  			{
  				PlayTime empty;
  				try
  				{
  					PlayTime singStart = this.TextCharactors[0].SingStart;
  					foreach (Charactor textCharactor in this.TextCharactors)
  					{
  						singStart = PlayTime.Min(singStart, textCharactor.SingStart);
  					}
  					foreach (Charactor rubyCharactor in this.RubyCharactors)
  					{
  						singStart = PlayTime.Min(singStart, rubyCharactor.SingStart);
  					}
  					empty = singStart;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					empty = PlayTime.Empty;
  				}
  				return empty;
  			}
  		}
  
  		[XmlIgnore]
  		public string FontSetName
  		{
  			get
  			{
  				string empty;
  				try
  				{
  					string fontSetName = this.TextCharactors[0].FontSetName;
  					foreach (Charactor textCharactor in this.TextCharactors)
  					{
  						if (fontSetName == textCharactor.FontSetName)
  						{
  							continue;
  						}
  						empty = string.Empty;
  						return empty;
  					}
  					foreach (Charactor rubyCharactor in this.RubyCharactors)
  					{
  						if (fontSetName == rubyCharactor.FontSetName)
  						{
  							continue;
  						}
  						empty = string.Empty;
  						return empty;
  					}
  					empty = fontSetName;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					empty = string.Empty;
  				}
  				return empty;
  			}
  			set
  			{
  				try
  				{
  					if (this.FontSetName != value && value != string.Empty)
  					{
  						this.DefaultFontSetName = value;
  						foreach (Charactor textCharactor in this.TextCharactors)
  						{
  							textCharactor.FontSetName = value;
  						}
  						foreach (Charactor rubyCharactor in this.RubyCharactors)
  						{
  							rubyCharactor.FontSetName = value;
  						}
  					}
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  				}
  			}
  		}
  
  		public bool IsDefaultWithoutSing
  		{
  			get;
  			set;
  		}
  
  		public bool IsLikeUgaWord
  		{
  			get;
  			set;
  		}
  
  		public bool IsSpacingEnabled
  		{
  			get;
  			set;
  		}
  
  		[XmlIgnore]
  		public bool? IsWithoutSing
  		{
  			get
  			{
  				bool? nullable;
  				try
  				{
  					bool isWithoutSing = this.TextCharactors[0].IsWithoutSing;
  					foreach (Charactor textCharactor in this.TextCharactors)
  					{
  						if (isWithoutSing == textCharactor.IsWithoutSing)
  						{
  							continue;
  						}
  						nullable = null;
  						return nullable;
  					}
  					foreach (Charactor rubyCharactor in this.RubyCharactors)
  					{
  						if (isWithoutSing == rubyCharactor.IsWithoutSing)
  						{
  							continue;
  						}
  						nullable = null;
  						return nullable;
  					}
  					nullable = new bool?(isWithoutSing);
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					nullable = null;
  				}
  				return nullable;
  			}
  			set
  			{
  				try
  				{
  					bool? isWithoutSing = this.IsWithoutSing;
  					bool? nullable = value;
  					if ((isWithoutSing.GetValueOrDefault() != nullable.GetValueOrDefault() ? true : isWithoutSing.HasValue != nullable.HasValue) && value.HasValue)
  					{
  						bool flag = value.Value;
  						this.IsDefaultWithoutSing = flag;
  						foreach (Charactor textCharactor in this.TextCharactors)
  						{
  							textCharactor.IsWithoutSing = flag;
  						}
  						foreach (Charactor rubyCharactor in this.RubyCharactors)
  						{
  							rubyCharactor.IsWithoutSing = flag;
  						}
  					}
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  				}
  			}
  		}
  
  		[XmlIgnore]
  		public PlayTime LastSingEnd
  		{
  			get
  			{
  				PlayTime empty;
  				try
  				{
  					PlayTime singEnd = this.TextCharactors[0].SingEnd;
  					foreach (Charactor textCharactor in this.TextCharactors)
  					{
  						singEnd = PlayTime.Max(singEnd, textCharactor.SingEnd);
  					}
  					foreach (Charactor rubyCharactor in this.RubyCharactors)
  					{
  						singEnd = PlayTime.Max(singEnd, rubyCharactor.SingEnd);
  					}
  					empty = singEnd;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					empty = PlayTime.Empty;
  				}
  				return empty;
  			}
  		}
  
  		[XmlIgnore]
  		public Line ParentalLine
  		{
  			get;
  			set;
  		}
  
  		[XmlIgnore]
  		public Page ParentalPage
  		{
  			get
  			{
  				Page parentalPage;
  				try
  				{
  					parentalPage = this.ParentalLine.ParentalPage;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					parentalPage = null;
  				}
  				return parentalPage;
  			}
  		}
  
  		[XmlIgnore]
  		public Part ParentalPart
  		{
  			get
  			{
  				Part parentalPart;
  				try
  				{
  					parentalPart = this.ParentalLine.ParentalPart;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					parentalPart = null;
  				}
  				return parentalPart;
  			}
  		}
  
  		[XmlIgnore]
  		public Sub ParentalSub
  		{
  			get
  			{
  				Sub parentalSub;
  				try
  				{
  					parentalSub = this.ParentalLine.ParentalSub;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					parentalSub = null;
  				}
  				return parentalSub;
  			}
  		}
  
  		[XmlIgnore]
  		public string Ruby
  		{
  			get
  			{
  				string empty;
  				try
  				{
  					string str = string.Empty;
  					for (int i = 0; i < this.RubyCharactors.Count; i++)
  					{
  						char chr = this.RubyCharactors[i].Char;
  						str = string.Concat(str, chr.ToString());
  					}
  					empty = str;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					empty = string.Empty;
  				}
  				return empty;
  			}
  		}
  
  		public List<Charactor> RubyCharactors
  		{
  			get;
  			set;
  		}
  
  		[XmlIgnore]
  		protected Size RubySize
  		{
  			get
  			{
  				Size size;
  				try
  				{
  					if (this.RubyCharactors.Count > 0)
  					{
  						double width = 0;
  						double num = 0;
  						foreach (Charactor rubyCharactor in this.RubyCharactors)
  						{
  							Size size1 = rubyCharactor.Size;
  							width = width + size1.Width;
  							num = Math.Max(num, size1.Height);
  						}
  						size = new Size(width, num);
  					}
  					else
  					{
  						size = Size.Empty;
  					}
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					size = Size.Empty;
  				}
  				return size;
  			}
  		}
  
  		[XmlIgnore]
  		public string Text
  		{
  			get
  			{
  				string empty;
  				try
  				{
  					string str = string.Empty;
  					for (int i = 0; i < this.TextCharactors.Count; i++)
  					{
  						char chr = this.TextCharactors[i].Char;
  						str = string.Concat(str, chr.ToString());
  					}
  					empty = str;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					empty = string.Empty;
  				}
  				return empty;
  			}
  		}
  
  		public List<Charactor> TextCharactors
  		{
  			get;
  			set;
  		}
  
  		[XmlIgnore]
  		public Size TextSize
  		{
  			get
  			{
  				Size size;
  				try
  				{
  					if (this.TextCharactors.Count > 0)
  					{
  						double width = 0;
  						double num = 0;
  						foreach (Charactor textCharactor in this.TextCharactors)
  						{
  							Size size1 = textCharactor.Size;
  							width = width + size1.Width;
  							num = Math.Max(num, size1.Height);
  						}
  						size = new Size(width, num);
  					}
  					else
  					{
  						size = Size.Empty;
  					}
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					size = Size.Empty;
  				}
  				return size;
  			}
  		}
  
  		[XmlIgnore]
  		public string TimeTaggedRuby
  		{
  			get
  			{
  				string empty;
  				try
  				{
  					string str = string.Empty;
  					PlayTime singEnd = PlayTime.Empty;
  					for (int i = 0; i < this.RubyCharactors.Count; i++)
  					{
  						Charactor item = this.RubyCharactors[i];
  						if (item.SingStart != singEnd && item.IsSolidSingStart)
  						{
  							str = string.Concat(str, item.SingStart.TimeTag);
  						}
  						char chr = item.Char;
  						str = string.Concat(str, chr.ToString());
  						if (item.IsSolidSingEnd)
  						{
  							str = string.Concat(str, item.SingEnd.TimeTag);
  						}
  						singEnd = item.SingEnd;
  					}
  					empty = str;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					empty = string.Empty;
  				}
  				return empty;
  			}
  			set
  			{
  				PlayTime empty;
  				PlayTime playTime;
  				try
  				{
  					if (this.TimeTaggedRuby != value)
  					{
  						this.RubyCharactors.Clear();
  						int length = 0;
  						while (length < value.Length)
  						{
  							Match match = PlayTime.HeadTimeTagRegex.Match(value.Substring(length));
  							if (!match.Success)
  							{
  								empty = PlayTime.Empty;
  							}
  							else
  							{
  								empty = PlayTime.FromTimeTag(match.Value);
  								length = length + match.Length;
  							}
  							if (length >= value.Length)
  							{
  								continue;
  							}
  							match = PlayTime.HeadTimeTagRegex.Match(value.Substring(length));
  							if (match.Success)
  							{
  								continue;
  							}
  							char charArray = value.Substring(length, 1).ToCharArray()[0];
  							length++;
  							if (length >= value.Length)
  							{
  								playTime = PlayTime.Empty;
  							}
  							else
  							{
  								match = PlayTime.HeadTimeTagRegex.Match(value.Substring(length));
  								playTime = (!match.Success ? PlayTime.Empty : PlayTime.FromTimeTag(match.Value));
  							}
  							Charactor charactor = new Charactor(this, charArray, CharactorKind.Ruby, empty, playTime, this.IsDefaultWithoutSing, this.DefaultAngle, this.DefaultFontSetName, this.DefaultColorSetName);
  							this.RubyCharactors.Add(charactor);
  						}
  					}
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  				}
  			}
  		}
  
  		[XmlIgnore]
  		public string TimeTaggedText
  		{
  			get
  			{
  				string empty;
  				try
  				{
  					string str = string.Empty;
  					PlayTime singEnd = PlayTime.Empty;
  					for (int i = 0; i < this.TextCharactors.Count; i++)
  					{
  						Charactor item = this.TextCharactors[i];
  						if (item.SingStart != singEnd && item.IsSolidSingStart)
  						{
  							str = string.Concat(str, item.SingStart.TimeTag);
  						}
  						char chr = item.Char;
  						str = string.Concat(str, chr.ToString());
  						if (item.IsSolidSingEnd)
  						{
  							str = string.Concat(str, item.SingEnd.TimeTag);
  						}
  						singEnd = item.SingEnd;
  					}
  					empty = str;
  				}
  				catch (Exception exception)
  				{
  					ErrorMessage.Show(exception, Assembly.GetExecutingAssembly(), MethodBase.GetCurrentMethod());
  					empty = string.Empty;
  				}
  				return empty;
  			}
  			set
  			{
  				PlayTime empty;
  				PlayTime playTime;
  				try
  				{
  					if (this.TimeTaggedText != value)
  					{
  						this.TextCharactors.Clear();
  						int length = 0;
  						while (length < value.Length)
  						{
  							Match match = PlayTime.HeadTimeTagRegex.Match(value.Substring(length));
  							if (!match.Success)
  							{
  								empty = PlayTime.Empty;
  							}
  							else
  							{
  								empty = PlayTime.FromTimeTag(match.Value);
  								length = length + match.Length;
  							}
  							if (length >= value.Length)
  							{
  								continue;
  							}
  							match = PlayTime.HeadTimeTagRegex.Match(value.Substring(length));
  							if (match.Success)
  							{
  								continue;
  							}
  
gt: 							char charArray = value.Substring(length, 1).ToCharArray()[0];