/// <summary> /// 傳回點字頁尾。 /// </summary> /// <param name="lineIdx">目前列印的列索引。用來計算頁尾的文件標題。</param> /// <param name="pageNum">頁碼。</param> /// <param name="beginOrgPageNum">起始原書頁碼。</param> /// <param name="endOrgPageNum">終止原書頁碼。</param> /// <returns></returns> /// <remarks>注意:點字頁碼的 # 號要固定印在第 37 方的位置(requested by 秋華)</remarks> private string GetBraillePageFoot(int lineIdx, int pageNum, int beginOrgPageNum, int endOrgPageNum) { StringBuilder sb = new StringBuilder(); StringBuilder sbPageNum = new StringBuilder(); // 標題 BrailleLine titleLine = m_BrDoc.GetPageTitle(lineIdx); string title = BrailleCharConverter.ToString(titleLine); // 原書頁碼 if (beginOrgPageNum >= 0) { string orgPageNum = ""; if (endOrgPageNum < 0) { orgPageNum = BrailleCharConverter.GetDigitCharCode(beginOrgPageNum, true); } else { if (beginOrgPageNum == endOrgPageNum) { orgPageNum = BrailleCharConverter.GetDigitCharCode(beginOrgPageNum, true); } else { orgPageNum = BrailleCharConverter.GetDigitCharCode(beginOrgPageNum, true) + BrailleCharConverter.ToChar(BrailleCell.DotsToByte(3, 6).ToString("X2")) + BrailleCharConverter.GetDigitCharCode(endOrgPageNum, true); } } sbPageNum.Append('#'); // 數字點 sbPageNum.Append(orgPageNum); // 原書頁碼 sbPageNum.Append(' '); // 空方 } sbPageNum.Append('#'); // 數字點 string pageNumStr = BrailleCharConverter.GetDigitCharCode(pageNum, true); sbPageNum.Append(pageNumStr.PadRight(3)); // 點字頁碼的數字部分固定佔三方,亦即 # 固定在第 37 方的位置 // 計算剩餘可容納標題的空間。 int roomForTitle = m_BrDoc.CellsPerLine - sbPageNum.Length - 1; // 多留一個空白 if (title.Length > roomForTitle) { title = title.Substring(0, roomForTitle); } else { title = title.PadRight(roomForTitle); } sb.Append(title); // 標題 sb.Append(' '); // 空方 sb.Append(sbPageNum.ToString()); // 原書頁碼、點字頁碼 return(sb.ToString()); }
private void btnConvert_Click(object sender, EventArgs e) { int[] dots = new int[txtDots.Text.Length]; for (int i = 0; i < txtDots.Text.Length && i < 8; i++) { dots[i] = Convert.ToInt32(new string(txtDots.Text[i], 1)); } byte value = BrailleCell.DotsToByte(dots); txtByte.Text = String.Format("{0:X}", value); }