倒着輸出來

 C#真是很方便啊

 

  1. using System; 
  2. using System.Collections.Generic; 
  3. using System.ComponentModel; 
  4. using System.Data; 
  5. using System.Drawing; 
  6. using System.Text; 
  7. using System.Windows.Forms; 
  8.  
  9. namespace ForrApplication 
  10.     public partial class Form1 : Form 
  11.     { 
  12.         public Form1() 
  13.         { 
  14.             InitializeComponent(); 
  15.             this.btnClean.Click += new EventHandler(CleanTextbox); 
  16.             this.btnTrans.Click += new EventHandler(StartToTranse); 
  17.             cleanAll = new CleanStream(cleanTarget); 
  18.             showMessage = new ShowMessage(showit); 
  19.             tMethod = delegate(string beforTran)  
  20.             { 
  21.                 StringBuilder sb = new StringBuilder(); 
  22.                 for (int i = beforTran.Length - 1; i >= 0; i--) 
  23.                 { 
  24.                     sb.Append(beforTran[i].ToString()); 
  25.                 } 
  26.                 return sb.ToString(); 
  27.             }; 
  28.         } 
  29.         void showit(string message)  
  30.         { 
  31.             MessageBox.Show("tips:" + message); 
  32.         } 
  33.         delegate string Trancelation(string beforTran); 
  34.         Trancelation tMethod; 
  35.         delegate void CleanStream(); 
  36.         CleanStream cleanAll; 
  37.         delegate void ShowMessage(string message); 
  38.         ShowMessage showMessage; 
  39.         void StartToTranse(object sender, EventArgs e) 
  40.         { 
  41.             TranceFunction(this.txtUp,this.txtDown); 
  42.         } 
  43.  
  44.         private void TranceFunction(TextBox textBox, TextBox textBox_2) 
  45.         { 
  46.             if (textBox.Text.Length < 1 && textBox_2.Text.Length < 1) 
  47.             { 
  48.                 showit("沒有輸入字哦"); 
  49.                 return
  50.             } 
  51.             if (textBox.Text.Length > 0 && textBox_2.Text.Length > 0) 
  52.             { 
  53.                 showit("兩邊都有,您要怎麼翻?"); 
  54.                 return
  55.             } 
  56.  
  57.             if (textBox.Text.Trim() != ""
  58.             { 
  59.                 textBox_2.Text = tMethod(textBox.Text); 
  60.             } 
  61.             else if (textBox_2.Text.Trim() != ""
  62.             { 
  63.                 textBox.Text = tMethod(textBox_2.Text); 
  64.             } 
  65.         } 
  66.         void cleanTarget()  
  67.         { 
  68.             this.txtUp.Text = ""
  69.             this.txtDown.Text = ""
  70.         } 
  71.         void CleanTextbox(object sender, EventArgs e) 
  72.         { 
  73.             cleanAll(); 
  74.         } 
  75.     } 

 

 

 

  1. namespace ForrApplication 
  2.     partial class Form1 
  3.     { 
  4.         /// <summary> 
  5.         /// 必需的設計器變量。 
  6.         /// </summary> 
  7.         private System.ComponentModel.IContainer components = null
  8.  
  9.         /// <summary> 
  10.         /// 清理所有正在使用的資源。 
  11.         /// </summary> 
  12.         /// <param name="disposing">如果應釋放託管資源,爲 true;否則爲 false。</param> 
  13.         protected override void Dispose(bool disposing) 
  14.         { 
  15.             if (disposing && (components != null)) 
  16.             { 
  17.                 components.Dispose(); 
  18.             } 
  19.             base.Dispose(disposing); 
  20.         } 
  21.  
  22.         #region Windows 窗體設計器生成的代碼 
  23.  
  24.         /// <summary> 
  25.         /// 設計器支持所需的方法 - 不要 
  26.         /// 使用代碼編輯器修改此方法的內容。 
  27.         /// </summary> 
  28.         private void InitializeComponent() 
  29.         { 
  30.             this.txtUp = new System.Windows.Forms.TextBox(); 
  31.             this.txtDown = new System.Windows.Forms.TextBox(); 
  32.             this.label1 = new System.Windows.Forms.Label(); 
  33.             this.label2 = new System.Windows.Forms.Label(); 
  34.             this.btnClean = new System.Windows.Forms.Button(); 
  35.             this.btnTrans = new System.Windows.Forms.Button(); 
  36.             this.SuspendLayout(); 
  37.             //  
  38.             // txtUp 
  39.             //  
  40.             this.txtUp.Location = new System.Drawing.Point(12, 23); 
  41.             this.txtUp.Multiline = true
  42.             this.txtUp.Name = "txtUp"
  43.             this.txtUp.Size = new System.Drawing.Size(268, 102); 
  44.             this.txtUp.TabIndex = 0; 
  45.             //  
  46.             // txtDown 
  47.             //  
  48.             this.txtDown.Location = new System.Drawing.Point(12, 159); 
  49.             this.txtDown.Multiline = true
  50.             this.txtDown.Name = "txtDown"
  51.             this.txtDown.Size = new System.Drawing.Size(268, 102); 
  52.             this.txtDown.TabIndex = 0; 
  53.             //  
  54.             // label1 
  55.             //  
  56.             this.label1.AutoSize = true
  57.             this.label1.Location = new System.Drawing.Point(12, 8); 
  58.             this.label1.Name = "label1"
  59.             this.label1.Size = new System.Drawing.Size(41, 12); 
  60.             this.label1.TabIndex = 1; 
  61.             this.label1.Text = "正着寫"
  62.             //  
  63.             // label2 
  64.             //  
  65.             this.label2.AutoSize = true
  66.             this.label2.Location = new System.Drawing.Point(14, 141); 
  67.             this.label2.Name = "label2"
  68.             this.label2.Size = new System.Drawing.Size(41, 12); 
  69.             this.label2.TabIndex = 2; 
  70.             this.label2.Text = "反着寫"
  71.             //  
  72.             // btnClean 
  73.             //  
  74.             this.btnClean.Location = new System.Drawing.Point(12, 267); 
  75.             this.btnClean.Name = "btnClean"
  76.             this.btnClean.Size = new System.Drawing.Size(128, 23); 
  77.             this.btnClean.TabIndex = 3; 
  78.             this.btnClean.Text = "清空"
  79.             this.btnClean.UseVisualStyleBackColor = true
  80.             //  
  81.             // btnTrans 
  82.             //  
  83.             this.btnTrans.Location = new System.Drawing.Point(146, 267); 
  84.             this.btnTrans.Name = "btnTrans"
  85.             this.btnTrans.Size = new System.Drawing.Size(134, 23); 
  86.             this.btnTrans.TabIndex = 4; 
  87.             this.btnTrans.Text = "翻譯"
  88.             this.btnTrans.UseVisualStyleBackColor = true
  89.             //  
  90.             // Form1 
  91.             //  
  92.             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); 
  93.             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 
  94.             this.ClientSize = new System.Drawing.Size(292, 292); 
  95.             this.Controls.Add(this.btnTrans); 
  96.             this.Controls.Add(this.btnClean); 
  97.             this.Controls.Add(this.label2); 
  98.             this.Controls.Add(this.label1); 
  99.             this.Controls.Add(this.txtDown); 
  100.             this.Controls.Add(this.txtUp); 
  101.             this.Name = "Form1"
  102.             this.Text = "snowleung"
  103.             this.ResumeLayout(false); 
  104.             this.PerformLayout(); 
  105.  
  106.         } 
  107.  
  108.         #endregion 
  109.  
  110.         private System.Windows.Forms.TextBox txtUp; 
  111.         private System.Windows.Forms.TextBox txtDown; 
  112.         private System.Windows.Forms.Label label1; 
  113.         private System.Windows.Forms.Label label2; 
  114.         private System.Windows.Forms.Button btnClean; 
  115.         private System.Windows.Forms.Button btnTrans; 
  116.     } 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章