From d9b030c21a0b104fb85400d9fc1526e6dc31acc0 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 4 Jan 2015 20:54:02 +0000 Subject: WinGui: Refracting some of the modelling around the Encode Services git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6685 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/CS/HandBrakeWPF/Extensions/StringExtensions.cs | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 win/CS/HandBrakeWPF/Extensions/StringExtensions.cs (limited to 'win/CS/HandBrakeWPF/Extensions') diff --git a/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs b/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs new file mode 100644 index 000000000..35cf4b128 --- /dev/null +++ b/win/CS/HandBrakeWPF/Extensions/StringExtensions.cs @@ -0,0 +1,41 @@ +// -------------------------------------------------------------------------------------------------------------------- +// +// This file is part of the HandBrake source code - It may be used under the terms of the GNU General Public License. +// +// +// String Extensions +// +// -------------------------------------------------------------------------------------------------------------------- + +namespace HandBrakeWPF.Extensions +{ + using System.Text; + + /// + /// String Extensions + /// + public static class StringExtensions + { + /// + /// Change the input string to title case + /// + /// the input string + /// the input string in title case + public static string ToTitleCase(this string input) + { + string[] tokens = input.Split(' '); + StringBuilder sb = new StringBuilder(input.Length); + foreach (string s in tokens) + { + if (!string.IsNullOrEmpty(s)) + { + sb.Append(s[0].ToString().ToUpper()); + sb.Append(s.Substring(1).ToLower()); + sb.Append(" "); + } + } + + return sb.ToString().Trim(); + } + } +} -- cgit v1.2.3