private void button7_Click(object sender, EventArgs e) { Form3 obj = new Form3("编写内容", schoolPage1.Content, true); if (obj.ShowDialog() == DialogResult.OK) { string[] newContent = obj.Value.Replace("\r\n", "\n").Replace("\r", "\n").Split('\n'); string[] contents = FileHelper.ReadFile(FileHelper.htmlPath, Tag.ToString(), (pageIndex + 1) + ".html"); StringBuilder sb = new StringBuilder(); foreach (string s in contents) { if (s.EndsWith("</br>")) { break; } sb.AppendLine(s); } foreach (string s in newContent) { decimal count = 0; int index1 = 0, index2 = 0; foreach (char c in s) { if (c > 127) { count += 1; } else { count += 0.5M; } if (count > 20) { if (c > 127) { count = 1; } else { count = 0.5M; } sb.AppendLine(s.Substring(index1, index2 - index1) + "</br>"); index1 = index2; } index2++; } if (index2 > index1) { sb.AppendLine(s.Substring(index1, index2 - index1) + "</br>"); } } sb.AppendLine(" </font>"); sb.AppendLine(" </div></div> </td>"); sb.AppendLine(" </tr>"); sb.AppendLine("</table>"); sb.AppendLine("</body>"); sb.AppendLine("</html>"); FileHelper.WriteFile(FileHelper.htmlPath, Tag.ToString(), (pageIndex + 1) + ".html", sb.ToString()); ShowPage(); } }
private void button4_Click(object sender, EventArgs e) { try { Process.Start(FileHelper.GetFile(FileHelper.htmlPath, Tag.ToString(), (pageIndex + 1) + ".html")); } catch (Exception ex) { MessageBox.Show(ex.Message); } }