自动生成仿古文字:横文转竖文,自定义分隔符

来源:互联网 发布:java国际化 编辑:程序博客网 时间:2024/04/29 06:54

自动生成仿古文字
|低|举|疑|床|静
|头|头|是|前|夜
|思|望|地|明|思
|故|明|上|月|
|乡|月|霜|光|
自定义分隔符:
☽低☽举☽疑☽床☽静
☽头☽头☽是☽前☽夜
☽思☽望☽地☽明☽思
☽故☽明☽上☽月☽
☽乡☽月☽霜☽光☽
上面这些怎么自动生成呢!
下面共享C#源代码,需要改进的请自行修改,该版本纯属测试。



 

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Drawing.Imaging;
  10. namespace easysayit
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }
  18.         private void button1_Click(object sender, EventArgs e)
  19.         {
  20.             textBox2.Text = "";
  21.             if (textBox1.Text == "")
  22.             { textBox1.Text = "sosecret.net 专注个人隐私保护"; }
  23.             int line = 10;
  24.             int colum = 10;
  25.                 line = int.Parse(textBox4.Text);
  26.                 colum = int.Parse(textBox3.Text);
  27.             string a = textBox1.Text;
  28.            
  29.             //hengtoshu(a, line, colum);
  30.             string s = hengtoshu (a, line, colum);
  31.             //textBox2.Text += s;
  32.          }
  33.         private string hengtoshu(string origin, int line, int colum)
  34.         {
  35.             char[] ori = origin.ToCharArray();
  36.             char[] after = new char[line * (colum * 2 + 1) + line + 4];
  37.             //-----------------添加分隔符---------------
  38.             for (int i = 1; i <= line * (colum * 2 + 1) + line + 1; i++)
  39.             {
  40.                 char ins = char.Parse (textBox5.Text);
  41.                 after[i - 1] = ins;
  42.             }
  43.             //--------------------添加换行符-------
  44.             for (int i = 1; i <= line; i++)
  45.             {
  46.                 after[colum * 2 + 1 + (i - 1) * (colum * 2 + 2)-1] = '/r';
  47.                 after[colum * 2 + 1 + (i - 1) * (colum * 2 + 2)] = '/n';
  48.             }
  49.             after[line * (colum * 2 + 1) + line-1] ='/r';
  50.             after[line * (colum * 2 + 1) + line] = '/n';
  51.             after[line * (colum * 2 + 1) + line+1] = '/r';
  52.             after[line * (colum * 2 + 1) + line+2] = '/n';
  53.             //---------------------添加空格------------
  54.             bool flag = false;
  55.             for (int i = 1, count = 0, off = 0; i <= colum; i++, off += 2)
  56.             {
  57.                 for (int j = 1; j <= line; j++, count++)
  58.                 {
  59.                     if (count < ori.Length)
  60.                     { after[colum * 2 - 1 - off + (colum * 2 + 2) * (j - 1)] = ori[count]; }
  61.                     else
  62.                     {
  63.                         after[colum * 2 - 1 - off + (colum * 2 + 2) * (j - 1)] = ' ';
  64.                         flag = true;
  65.                     }
  66.                 }
  67.             }
  68.             //------------------------------
  69.             textBox2.Text += new string(after);
  70.             if (!flag)
  71.             {
  72.                 origin = origin.Remove(0, colum * line);
  73.                 hengtoshu (origin, line, colum);
  74.                 return "sosecret.net";
  75.             }
  76.             else { return "sosecret.net"; }
  77.             
  78.         }
  79.         private void pictureBox1_Click(object sender, EventArgs e)
  80.         {
  81.             System.Diagnostics.Process.Start("http://www.sosecret.net");
  82.         }
  83.         private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  84.         {
  85.             form2 form2 = new form2();
  86.             form2.ShowDialog(); 
  87.         }
  88.         private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  89.         {
  90.            
  91.         }
  92.         private void menuStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
  93.         {
  94.         }
  95.         private void Form1_Load(object sender, EventArgs e)
  96.         {
  97.         }
  98.     }
  99. }
原创粉丝点击