protected BlockMegAndColor[] separateMegColor(BlockMegAndColor megColor) { List<BlockMegAndColor> rowWordCounts = new List<BlockMegAndColor>(); string[] megs = megColor.Message.Split('\r'); int str_row_count = 0; int char_count = 0; for (int i = 0; i < megs.Length; i++) { if (string.IsNullOrEmpty(megs[i]) || megs[i].Trim() == "") { rowWordCounts.Add(new BlockMegAndColor("", new System.Drawing.Color[0], new System.Drawing.Color[0])); rowWordCounts.Add(new BlockMegAndColor("", new System.Drawing.Color[0], new System.Drawing.Color[0])); str_row_count = +2; ; } else { string[] submegs = megs[i].Split('��'); for (int j = 0; j < submegs.Length; j++) { if (string.IsNullOrEmpty(submegs[j])) { rowWordCounts.Add(new BlockMegAndColor("", new System.Drawing.Color[0], new System.Drawing.Color[0])); str_row_count++; } else { BlockMegAndColor myMegColor = new BlockMegAndColor(submegs[j], megColor.getSubColors(megColor.ForeColor, char_count, submegs[j].Length), megColor.getSubColors(megColor.BackColor, char_count, submegs[j].Length)); if (j % 2 == 0) rowWordCounts.AddRange(separateMegColor(devType, 1, 2, myMegColor)); else rowWordCounts.AddRange(separateMegColor(devType, 1, 4, myMegColor)); char_count += submegs[j].Length + 1; } if (j == 1) break; } if (submegs.Length == 1) { rowWordCounts.Add(new BlockMegAndColor("", new System.Drawing.Color[0], new System.Drawing.Color[0])); str_row_count++; } char_count--; } if (i == 3) break; } return rowWordCounts.ToArray(); }
/// <summary> /// ���ѰT���M�C�� /// </summary> /// <param name="rowCount"></param> /// <param name="colCount"></param> /// <param name="megColor"></param> /// <returns></returns> protected BlockMegAndColor[] separateMegColor(DeviceType type, int rowCount, int colCount, BlockMegAndColor megColor) { BlockMegAndColor[] rowWordCounts = new BlockMegAndColor[rowCount]; if (string.IsNullOrEmpty(megColor.Message)) { for (int i = 0; i < rowWordCounts.Length; i++) { rowWordCounts[i] = new BlockMegAndColor("", new System.Drawing.Color[0], new System.Drawing.Color[0]); } } else { int str_row_count = 0; int char_count = 0; foreach (string meg in megColor.Message.Split('\r')) { if (string.IsNullOrEmpty(meg)) { rowWordCounts[str_row_count] = new BlockMegAndColor("", new System.Drawing.Color[0], new System.Drawing.Color[0]); str_row_count++; } else { int index = 0; double k = 0; for (int i = 0; i < meg.Length; i++) { if (k == colCount) { string newmeg = meg.Substring(index, i - index); System.Drawing.Color[] foreColor = megColor.getSubColors(megColor.ForeColor, index + char_count, newmeg.Length); System.Drawing.Color[] backColor = megColor.getSubColors(megColor.BackColor, index + char_count, newmeg.Length); byte[] color = megColor.getSubColors(megColor.Color, index + char_count, newmeg.Length); if (type == DeviceType.CMS) rowWordCounts[str_row_count] = new BlockMegAndColor(newmeg, color); else rowWordCounts[str_row_count] = new BlockMegAndColor(newmeg, foreColor, backColor); k = 0; index = i; if (++str_row_count == rowCount) break; } if (decisionHolomorphic(meg[i])) k += 1; else k += .5; if (i + 1 < meg.Length && decisionHolomorphic(meg[i + 1]) && ((k + 0.5) == (colCount))) k = colCount; ; if (i == meg.Length - 1) { string newmeg = meg.Substring(index, meg.Length - index); System.Drawing.Color[] foreColor = megColor.getSubColors(megColor.ForeColor, index + char_count, newmeg.Length); System.Drawing.Color[] backColor = megColor.getSubColors(megColor.BackColor, index + char_count, newmeg.Length); byte[] color = megColor.getSubColors(megColor.Color, index + char_count, newmeg.Length); if (type == DeviceType.CMS) rowWordCounts[str_row_count] = new BlockMegAndColor(newmeg, color); else rowWordCounts[str_row_count] = new BlockMegAndColor(newmeg, foreColor, backColor); str_row_count++; } } if (str_row_count == rowCount) break; char_count += meg.Length; } } } return rowWordCounts; }
/// <summary> /// ���ѰT���M�C�� /// </summary> /// <param name="rowCount"></param> /// <param name="colCount"></param> /// <param name="megColor"></param> /// <returns></returns> protected BlockMegAndColor[] separateMegColor(DeviceType type, int rowCount, int colCount, BlockMegAndColor megColor) { BlockMegAndColor[] rowWordCounts = new BlockMegAndColor[rowCount]; if (string.IsNullOrEmpty(megColor.Message)) { for (int i = 0; i < rowWordCounts.Length; i++) { rowWordCounts[i] = new BlockMegAndColor("", new System.Drawing.Color[0], new System.Drawing.Color[0]); } } else { int str_row_count = 0; int char_count = 0; foreach (string meg in megColor.Message.Split('\r')) { if (string.IsNullOrEmpty(meg)) { rowWordCounts[str_row_count] = new BlockMegAndColor("", new System.Drawing.Color[0], new System.Drawing.Color[0]); str_row_count++; } else { bool cont = false; int index = 0; double k = 0; int BK = 0; for (int i = 0; i < meg.Length; i++) { if (meg[i] == '\b') { cont = true; BK = i; continue; } else if (meg[i] == '\f') { cont = false; if (i < meg.Length -1) continue; } if (k == colCount) { if (cont && str_row_count + 1 < rowCount && Encoding.GetEncoding("Big5").GetByteCount(meg.Substring(BK+1,i - BK)) <= colCount * 2 ) { if (BK > 0) i = BK - 1; else i = 0; } string newmeg = meg.Substring(index, i - index).Replace("\b", string.Empty).Replace("\f", string.Empty); System.Drawing.Color[] foreColor = megColor.getSubColors(megColor.ForeColor, index + char_count, newmeg.Length, meg.Substring(index, i - index)); System.Drawing.Color[] backColor = megColor.getSubColors(megColor.BackColor, index + char_count, newmeg.Length, meg.Substring(index, i - index)); byte[] color = megColor.getSubColors(megColor.Color, index + char_count, newmeg.Length, meg.Substring(index, i - index)); if ((rowCount == 1 && colCount == 8) || (rowCount == 2 && colCount == 5)) { FixVDevBug(ref newmeg, ref color, ref foreColor, ref backColor); } if (type == DeviceType.CMS) rowWordCounts[str_row_count] = new BlockMegAndColor(newmeg, color); else rowWordCounts[str_row_count] = new BlockMegAndColor(newmeg, foreColor, backColor); k = 0; index = i; if (++str_row_count == rowCount) break; if (i == BK -1) { continue; } } if (decisionHolomorphic(meg[i])) k += 1; else k += .5; if (i + 1 < meg.Length && ((k + 0.5) == colCount) && (decisionHolomorphic(meg[i + 1]) || meg[i+1] == '\b' || meg[i +1] == '\f' ))//�b�νվ� { k = colCount; } if (i == meg.Length - 1) { string newmeg = meg.Substring(index, meg.Length - index).Replace("\b", string.Empty).Replace("\f", string.Empty); ; System.Drawing.Color[] foreColor = megColor.getSubColors(megColor.ForeColor, index + char_count, newmeg.Length, meg.Substring(index, meg.Length - index)); System.Drawing.Color[] backColor = megColor.getSubColors(megColor.BackColor, index + char_count, newmeg.Length, meg.Substring(index, meg.Length - index)); byte[] color = megColor.getSubColors(megColor.Color, index + char_count, newmeg.Length, meg.Substring(index, meg.Length - index)); if ((rowCount == 1 && colCount == 8) || (rowCount == 2 && colCount == 5)) { FixVDevBug(ref newmeg, ref color, ref foreColor, ref backColor); } if (type == DeviceType.CMS) rowWordCounts[str_row_count] = new BlockMegAndColor(newmeg, color); else rowWordCounts[str_row_count] = new BlockMegAndColor(newmeg, foreColor, backColor); str_row_count++; } } if (str_row_count == rowCount) break; char_count += meg.Length; } } } return rowWordCounts; }