(object sender, EventArgs e)
| 337 | } |
| 338 | |
| 339 | private void ToolStripMenuItem_export_Click(object sender, EventArgs e) |
| 340 | { |
| 341 | // 检查字符表 |
| 342 | HashSet<char> tCharset = new HashSet<char>(); |
| 343 | foreach(FontDef.CharDef x in _Def.CharList) |
| 344 | { |
| 345 | if(tCharset.Contains(x.Character)) |
| 346 | { |
| 347 | Helper.ShowErr("字符表中存在重复字符: " + x.Character.ToString()); |
| 348 | return; |
| 349 | } |
| 350 | else if(x.Character == '\0') |
| 351 | { |
| 352 | Helper.ShowErr("字符表中存在无效字符。"); |
| 353 | return; |
| 354 | } |
| 355 | else |
| 356 | tCharset.Add(x.Character); |
| 357 | } |
| 358 | |
| 359 | // 决定保存路径 |
| 360 | string tPathToSave; |
| 361 | if (DialogResult.Cancel == saveFileDialog_savexml.ShowDialog()) |
| 362 | return; |
| 363 | tPathToSave = saveFileDialog_savexml.FileName; |
| 364 | |
| 365 | string tOut; |
| 366 | if (DialogResult.Cancel == Dialog_InputBox.OpenDialog("请输入行间距:", "设置行间距", "0", out tOut)) |
| 367 | return; |
| 368 | |
| 369 | int tLineGap; |
| 370 | try |
| 371 | { |
| 372 | tLineGap = Convert.ToInt32(tOut); |
| 373 | } |
| 374 | catch (Exception Expt) |
| 375 | { |
| 376 | Helper.ShowErr("格式不正确: " + Expt.Message); |
| 377 | return; |
| 378 | } |
| 379 | |
| 380 | XmlDocument tDoc = new XmlDocument(); |
| 381 | |
| 382 | XmlElement tRoot = tDoc.CreateElement("f2dTexturedFont"); |
| 383 | |
| 384 | XmlElement tMeasure = tDoc.CreateElement("Measure"); |
| 385 | tMeasure.SetAttribute("LineHeight", (_Def.MaxLineHeight + tLineGap).ToString()); |
| 386 | tMeasure.SetAttribute("Ascender", _Def.MaxLineHeight.ToString()); |
| 387 | tMeasure.SetAttribute("Descender", "0"); |
| 388 | tRoot.AppendChild(tMeasure); |
| 389 | |
| 390 | // 追加字符表 |
| 391 | XmlElement tCharTable = tDoc.CreateElement("CharList"); |
| 392 | foreach (FontDef.CharDef x in _Def.CharList) |
| 393 | { |
| 394 | XmlElement tItem = tDoc.CreateElement("Item"); |
| 395 | |
| 396 | tItem.SetAttribute("Char", x.Character.ToString()); |
nothing calls this directly
no test coverage detected