using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Globalization; using System.Threading; namespace ChangeTextCase { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void btnCopy_Click(object sender, EventArgs e) { txtDestination.SelectAll(); txtDestination.Copy(); } private void btnChangeCase_Click(object sender, EventArgs e) { string sText = txtSource.Text; txtSource.Text = ""; txtDestination.Text = ""; #region Get the culture property of the thread. CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; //Create TextInfo object. TextInfo textInfo = cultureInfo.TextInfo; #endregion Get the culture property of the thread. #region Title case if (rbTitleCase.Checked == true) { sText = sText.ToLower(); txtDestination.Text = textInfo.ToTitleCase(sText); } #endregion Title case #region Lower case if (rbLowerCase.Checked == true) { txtDestination.Text = sText.ToLower(); } #endregion Lower case #region Upper case if (rbUpperCase.Checked == true) { txtDestination.Text = sText.ToUpper(); } #endregion Upper case #region Remove Line Break - Start if (rbRemoveLineBreak.Checked == true) { if (ckRemoveTabs.Checked == false) { //txtDestination.Text = sText.Replace(System.Environment.NewLine, sText); string replaceWith = ""; txtDestination.Text = sText.Replace("rn", replaceWith).Replace("n", replaceWith).Replace("r", replaceWith); } else { //txtDestination.Text = sText.Replace(System.Environment.NewLine, sText); string replaceWith = ""; txtDestination.Text = sText.Replace("rn", replaceWith).Replace("n", replaceWith).Replace("r", replaceWith).Replace("t", replaceWith).Replace(" '", "'"); } } #endregion Remove Line Break - Stop } } }
Last Updated on February 8, 2016
You must be logged in to post a comment.