Ejemplo n.º 1
0
		private XmlNode GetReadList(string title, GlossaryWord[] words){
			if(words == null || words.Length == 0) return Html.Null;

			XmlNode result = Html.Div("word-list");
			result.AppendChild(Html.H(3, null, title));
			XmlElement p = WordList(words);
			result.AppendChild(p);
			return result;
		}
Ejemplo n.º 2
0
		private void AddRead(string read, GlossaryWord gw){
			if(string.IsNullOrEmpty(read)) return;
			char key = read[0].ToReadChar();
			if('\x4E00' <= key && key < '\xAC00') return;
			if(HatomaruGlossary.ReadOrder.IndexOf(key) < 0) key = HatomaruGlossary.ReadNull;
			Object[] data = new Object[]{key, read, gw};
			DataRow row = this.NewRow();
			row.ItemArray = data;
			this.Rows.Add(row);
		}
Ejemplo n.º 3
0
// データの取得



// データのロード


		// 読みを追加
		// 先頭文字が同じで長さが異なる読みがある場合、長い方だけ採用する
		// 先頭文字が同じ読みが二回登録されることはない。
		public void AddReads(GlossaryWord gw){
			List<string> reads = new List<string>();
			AddReadList(reads, gw.Name);
			AddReadList(reads, gw.Read);
			AddReadList(reads, gw.AltRead);
			AddReadList(reads, gw.Pronounce);
			foreach(string s in reads){
				AddRead(s, gw);
			}
		}
Ejemplo n.º 4
0
		protected XmlElement WordList(GlossaryWord[] words){
			XmlElement p = Html.P();
			for(int i=0; i < words.Length; i++){
				if(i > 0) p.AppendChild(Html.Text(" / "));
				AbsPath wordPath = BasePath.Combine(words[i].Name.PathEncode());
				XmlElement a = Html.A(wordPath);
				a.InnerText = words[i].Name;
				p.AppendChild(a);
			}
			return p;
		}
Ejemplo n.º 5
0
// データの取得



// データのロード

		public void AddGlossary(GlossaryWord gw){
			Object[] data = new Object[]{gw.Name, gw,};
			DataRow row = this.NewRow();
			row.ItemArray = data;
			this.Rows.Add(row);
		}
Ejemplo n.º 6
0
// データのロード
		/// <summary>
		/// XML ファイルからデータをロードします。
		/// </summary>
		public void Load(){
			XmlNodeList xnl = Document.GetElementsByTagName(HatomaruGlossary.WordElementName);
			myTable.MinimumCapacity = xnl.Count;
			foreach(XmlElement e in xnl){
				GlossaryWord gw = new GlossaryWord(e);
				// ジャンルを追加
				foreach(string s in gw.Genre){
					if(!myGenreDic.ContainsKey(s)) myGenreDic.Add(s, new GlossaryGenre(s));
					myGenreDic[s].Add(gw);
				}
				myTable.AddGlossary(gw);
				myReadTable.AddReads(gw);
			}
			myGenreList = new GlossaryGenre[myGenreDic.Count];
			myGenreDic.Values.CopyTo(myGenreList, 0);
			Array.Sort(myGenreList);
		}