2 This file is part of the HandBrake source code.
\r
3 Homepage: <http://handbrake.fr>.
\r
4 It may be used under the terms of the GNU General Public License. */
\r
6 namespace Handbrake.Functions
\r
9 using System.Collections.Generic;
\r
10 using System.Diagnostics;
\r
11 using System.Globalization;
\r
15 using System.Text.RegularExpressions;
\r
16 using System.Threading;
\r
17 using System.Windows.Forms;
\r
18 using System.Xml.Serialization;
\r
23 /// Useful functions which various screens can use.
\r
25 public static class Main
\r
28 /// The XML Serializer
\r
30 private static readonly XmlSerializer Ser = new XmlSerializer(typeof(List<Job>));
\r
33 /// Calculate the duration of the selected title and chapters
\r
35 /// <param name="chapterStart">
\r
36 /// The chapter Start.
\r
38 /// <param name="chapterEnd">
\r
39 /// The chapter End.
\r
41 /// <param name="selectedTitle">
\r
42 /// The selected Title.
\r
45 /// The calculated duration.
\r
47 public static TimeSpan CalculateDuration(int chapterStart, int chapterEnd, Title selectedTitle)
\r
49 TimeSpan duration = TimeSpan.FromSeconds(0.0);
\r
52 if (chapterStart != 0 && chapterEnd != 0 && chapterEnd <= selectedTitle.Chapters.Count)
\r
54 for (int i = chapterStart; i <= chapterEnd; i++)
\r
55 duration += selectedTitle.Chapters[i - 1].Duration;
\r
62 /// Set's up the DataGridView on the Chapters tab (frmMain)
\r
64 /// <param name="dataChpt">
\r
65 /// The DataGridView Control
\r
67 /// <param name="chapterEnd">
\r
68 /// The chapter End.
\r
71 /// The chapter naming.
\r
73 public static DataGridView ChapterNaming(DataGridView dataChpt, string chapterEnd)
\r
75 int i = 0, finish = 0;
\r
77 if (chapterEnd != "Auto")
\r
78 int.TryParse(chapterEnd, out finish);
\r
82 int n = dataChpt.Rows.Add();
\r
83 dataChpt.Rows[n].Cells[0].Value = i + 1;
\r
84 dataChpt.Rows[n].Cells[1].Value = "Chapter " + (i + 1);
\r
85 dataChpt.Rows[n].Cells[0].ValueType = typeof(int);
\r
86 dataChpt.Rows[n].Cells[1].ValueType = typeof(string);
\r
94 /// Import a CSV file which contains Chapter Names
\r
96 /// <param name="dataChpt">
\r
97 /// The DataGridView Control
\r
99 /// <param name="filename">
\r
100 /// The filepath and name
\r
102 /// <returns>A Populated DataGridView</returns>
\r
103 public static DataGridView ImportChapterNames(DataGridView dataChpt, string filename)
\r
105 IDictionary<int, string> chapterMap = new Dictionary<int, string>();
\r
108 StreamReader sr = new StreamReader(filename);
\r
109 string csv = sr.ReadLine();
\r
110 while (csv != null)
\r
112 if (csv.Trim() != string.Empty)
\r
114 csv = csv.Replace("\\,", "<!comma!>");
\r
115 string[] contents = csv.Split(',');
\r
117 int.TryParse(contents[0], out chapter);
\r
118 chapterMap.Add(chapter, contents[1].Replace("<!comma!>", ","));
\r
120 csv = sr.ReadLine();
\r
128 foreach (DataGridViewRow item in dataChpt.Rows)
\r
131 chapterMap.TryGetValue((int)item.Cells[0].Value, out name);
\r
132 item.Cells[1].Value = name ?? "Chapter " + item.Cells[0].Value;
\r
139 /// Function which generates the filename and path automatically based on
\r
140 /// the Source Name, DVD title and DVD Chapters
\r
142 /// <param name="mainWindow">
\r
143 /// The main Window.
\r
146 /// The Generated FileName
\r
148 public static string AutoName(frmMain mainWindow)
\r
150 string autoNamePath = string.Empty;
\r
151 if (mainWindow.drp_dvdtitle.Text != "Automatic")
\r
153 // Get the Source Name
\r
154 string sourceName = mainWindow.SourceName;
\r
156 // Remove any illeagal characters from the source name
\r
157 foreach (char character in Path.GetInvalidFileNameChars())
\r
159 if (autoNamePath != null)
\r
161 sourceName = sourceName.Replace(character.ToString(), string.Empty);
\r
165 if (Properties.Settings.Default.AutoNameRemoveUnderscore)
\r
166 sourceName = sourceName.Replace("_", " ");
\r
168 if (Properties.Settings.Default.AutoNameTitleCase)
\r
169 sourceName = TitleCase(sourceName);
\r
171 // Get the Selected Title Number
\r
172 string[] titlesplit = mainWindow.drp_dvdtitle.Text.Split(' ');
\r
173 string dvdTitle = titlesplit[0].Replace("Automatic", string.Empty);
\r
175 // Get the Chapter Start and Chapter End Numbers
\r
176 string chapterStart = mainWindow.drop_chapterStart.Text.Replace("Auto", string.Empty);
\r
177 string chapterFinish = mainWindow.drop_chapterFinish.Text.Replace("Auto", string.Empty);
\r
178 string combinedChapterTag = chapterStart;
\r
179 if (chapterFinish != chapterStart && chapterFinish != string.Empty)
\r
180 combinedChapterTag = chapterStart + "-" + chapterFinish;
\r
182 // Get the destination filename.
\r
183 string destinationFilename;
\r
184 if (Properties.Settings.Default.autoNameFormat != string.Empty)
\r
186 destinationFilename = Properties.Settings.Default.autoNameFormat;
\r
187 destinationFilename =
\r
188 destinationFilename.Replace("{source}", sourceName).Replace("{title}", dvdTitle).Replace(
\r
189 "{chapters}", combinedChapterTag);
\r
192 destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag;
\r
194 // Add the appropriate file extension
\r
195 if (mainWindow.drop_format.SelectedIndex == 0)
\r
197 if (Properties.Settings.Default.useM4v || mainWindow.Check_ChapterMarkers.Checked ||
\r
198 mainWindow.AudioSettings.RequiresM4V() || mainWindow.Subtitles.RequiresM4V())
\r
199 destinationFilename += ".m4v";
\r
201 destinationFilename += ".mp4";
\r
203 else if (mainWindow.drop_format.SelectedIndex == 1)
\r
204 destinationFilename += ".mkv";
\r
206 // Now work out the path where the file will be stored.
\r
207 // First case: If the destination box doesn't already contain a path, make one.
\r
208 if (!mainWindow.text_destination.Text.Contains(Path.DirectorySeparatorChar.ToString()))
\r
210 // If there is an auto name path, use it...
\r
211 if (Properties.Settings.Default.autoNamePath.Trim() != string.Empty &&
\r
212 Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")
\r
213 autoNamePath = Path.Combine(Properties.Settings.Default.autoNamePath, destinationFilename);
\r
214 else // ...otherwise, output to the source directory
\r
215 autoNamePath = null;
\r
217 else // Otherwise, use the path that is already there.
\r
219 // Use the path and change the file extension to match the previous destination
\r
220 autoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text),
\r
221 destinationFilename);
\r
223 if (Path.HasExtension(mainWindow.text_destination.Text))
\r
224 autoNamePath = Path.ChangeExtension(autoNamePath,
\r
225 Path.GetExtension(mainWindow.text_destination.Text));
\r
229 return autoNamePath;
\r
233 /// Get's HandBrakes version data from the CLI.
\r
235 public static void SetCliVersionData()
\r
239 // 0 = SVN Build / Version
\r
241 DateTime lastModified = File.GetLastWriteTime("HandBrakeCLI.exe");
\r
243 if (Properties.Settings.Default.cliLastModified == lastModified && Properties.Settings.Default.hb_build != 0)
\r
246 Properties.Settings.Default.cliLastModified = lastModified;
\r
248 Process cliProcess = new Process();
\r
249 ProcessStartInfo handBrakeCli = new ProcessStartInfo("HandBrakeCLI.exe", " -u -v0")
\r
251 UseShellExecute = false,
\r
252 RedirectStandardError = true,
\r
253 RedirectStandardOutput = true,
\r
254 CreateNoWindow = true
\r
256 cliProcess.StartInfo = handBrakeCli;
\r
260 cliProcess.Start();
\r
262 // Retrieve standard output and report back to parent thread until the process is complete
\r
263 TextReader stdOutput = cliProcess.StandardError;
\r
265 while (!cliProcess.HasExited)
\r
267 line = stdOutput.ReadLine() ?? string.Empty;
\r
268 Match m = Regex.Match(line, @"HandBrake ([svnM0-9.]*) \([0-9]*\)");
\r
269 Match platform = Regex.Match(line, @"- ([A-Za-z0-9\s ]*) -");
\r
273 string data = line.Replace("(", string.Empty).Replace(")", string.Empty).Replace("HandBrake ", string.Empty);
\r
274 string[] arr = data.Split(' ');
\r
276 Properties.Settings.Default.hb_build = int.Parse(arr[1]);
\r
277 Properties.Settings.Default.hb_version = arr[0];
\r
280 if (platform.Success)
\r
282 Properties.Settings.Default.hb_platform = platform.Value.Replace("-", string.Empty).Trim();
\r
285 if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.
\r
287 Process cli = Process.GetProcessById(cliProcess.Id);
\r
288 if (!cli.HasExited)
\r
295 Properties.Settings.Default.Save();
\r
297 catch (Exception e)
\r
299 MessageBox.Show("Unable to retrieve version information from the CLI. \nError:\n" + e);
\r
304 /// Check to make sure that the user has an up to date version of the CLI installed.
\r
306 public static void CheckForValidCliVersion()
\r
308 // Make sure we have a recent version for svn builds
\r
309 string version = Properties.Settings.Default.hb_version;
\r
310 if (version.Contains("svn"))
\r
312 version = version.Replace("svn", string.Empty).Trim();
\r
314 int.TryParse(version, out build);
\r
315 if (build < Properties.Settings.Default.hb_min_cli)
\r
318 "It appears you are trying to use a CLI executable that is too old for this version of the HandBrake GUI.\n" +
\r
319 "Please update the HandBrakeCLI.exe to a newer build.\n\n" +
\r
320 "HandBrake build Detected: " + Properties.Settings.Default.hb_version,
\r
322 MessageBoxButtons.OK,
\r
323 MessageBoxIcon.Error);
\r
330 /// Check if the queue recovery file contains records.
\r
331 /// If it does, it means the last queue did not complete before HandBrake closed.
\r
332 /// So, return a boolean if true.
\r
335 /// True if there is a queue to recover.
\r
337 public static bool CheckQueueRecovery()
\r
341 string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\hb_queue_recovery.xml");
\r
342 if (File.Exists(tempPath))
\r
344 using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))
\r
346 List<Job> list = Ser.Deserialize(strm) as List<Job>;
\r
348 if (list.Count != 0)
\r
356 return false; // Keep quiet about the error.
\r
361 /// Get the Process ID of HandBrakeCLI for the current instance.
\r
363 /// <param name="before">List of processes before the new process was started</param>
\r
364 /// <returns>Int - Process ID</returns>
\r
365 public static int GetCliProcess(Process[] before)
\r
367 // This is a bit of a cludge. Maybe someone has a better idea on how to impliment this.
\r
368 // Since we used CMD to start HandBrakeCLI, we don't get the process ID from hbProc.
\r
369 // Instead we take the processes before and after, and get the ID of HandBrakeCLI.exe
\r
370 // avoiding any previous instances of HandBrakeCLI.exe in before.
\r
371 // Kill the current process.
\r
373 DateTime startTime = DateTime.Now;
\r
376 Process[] hbProcesses = Process.GetProcessesByName("HandBrakeCLI");
\r
377 while (hbProcesses.Length == 0)
\r
379 hbProcesses = Process.GetProcessesByName("HandBrakeCLI");
\r
380 duration = DateTime.Now - startTime;
\r
381 if (duration.Seconds > 5 && hbProcesses.Length == 0)
\r
382 // Make sure we don't wait forever if the process doesn't start
\r
386 Process hbProcess = null;
\r
387 foreach (Process process in hbProcesses)
\r
389 bool found = false;
\r
390 // Check if the current CLI instance was running before we started the current one
\r
391 foreach (Process bprocess in before)
\r
393 if (process.Id == bprocess.Id)
\r
397 // If it wasn't running before, we found the process we want.
\r
400 hbProcess = process;
\r
404 if (hbProcess != null)
\r
405 return hbProcess.Id;
\r
411 /// Clear all the encode log files.
\r
413 public static void ClearLogs()
\r
415 string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
\r
416 if (Directory.Exists(logDir))
\r
418 DirectoryInfo info = new DirectoryInfo(logDir);
\r
419 FileInfo[] logFiles = info.GetFiles("*.txt");
\r
420 foreach (FileInfo file in logFiles)
\r
422 if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log") &&
\r
423 !file.Name.Contains("tmp_appReadable_log.txt"))
\r
424 File.Delete(file.FullName);
\r
430 /// Clear old log files x days in the past
\r
432 public static void ClearOldLogs()
\r
434 string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
\r
435 if (Directory.Exists(logDir))
\r
437 DirectoryInfo info = new DirectoryInfo(logDir);
\r
438 FileInfo[] logFiles = info.GetFiles("*.txt");
\r
440 foreach (FileInfo file in logFiles)
\r
442 if (file.LastWriteTime < DateTime.Now.AddDays(-30))
\r
444 if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log") &&
\r
445 !file.Name.Contains("tmp_appReadable_log.txt"))
\r
446 File.Delete(file.FullName);
\r
453 /// Begins checking for an update to HandBrake.
\r
455 /// <param name="callback">The method that will be called when the check is finished.</param>
\r
456 /// <param name="debug">Whether or not to execute this in debug mode.</param>
\r
457 public static void BeginCheckForUpdates(AsyncCallback callback, bool debug)
\r
459 ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
\r
463 // Is this a stable or unstable build?
\r
465 Properties.Settings.Default.hb_build.ToString()
\r
467 ? Properties.Settings.Default.
\r
469 : Properties.Settings.Default.appcast;
\r
471 // Initialize variables
\r
472 WebRequest request = WebRequest.Create(url);
\r
473 WebResponse response = request.GetResponse();
\r
474 AppcastReader reader = new AppcastReader();
\r
476 // Get the data, convert it to a string, and parse it into the AppcastReader
\r
478 new StreamReader(response.GetResponseStream())
\r
481 // Further parse the information
\r
482 string build = reader.Build;
\r
484 int latest = int.Parse(build);
\r
485 int current = Properties.Settings.Default.hb_build;
\r
486 int skip = Properties.Settings.Default.skipversion;
\r
488 // If the user wanted to skip this version, don't report the update
\r
489 if (latest == skip)
\r
491 UpdateCheckInformation info =
\r
492 new UpdateCheckInformation
\r
494 NewVersionAvailable = false,
\r
495 BuildInformation = null
\r
497 callback(new UpdateCheckResult(debug, info));
\r
501 // Set when the last update was
\r
502 Properties.Settings.Default.lastUpdateCheckDate =
\r
504 Properties.Settings.Default.Save();
\r
506 UpdateCheckInformation info2 =
\r
507 new UpdateCheckInformation
\r
509 NewVersionAvailable = latest > current,
\r
510 BuildInformation = reader
\r
512 callback(new UpdateCheckResult(debug, info2));
\r
514 catch (Exception exc)
\r
516 callback(new UpdateCheckResult(debug, new UpdateCheckInformation { Error = exc }));
\r
522 /// End Check for Updates
\r
524 /// <param name="result">
\r
528 /// Update Check information
\r
530 public static UpdateCheckInformation EndCheckForUpdates(IAsyncResult result)
\r
532 UpdateCheckResult checkResult = (UpdateCheckResult)result;
\r
533 return checkResult.Result;
\r
537 /// Map languages and their iso639_2 value into a IDictionary
\r
539 /// <returns>A Dictionary containing the language and iso code</returns>
\r
540 public static IDictionary<string, string> MapLanguages()
\r
542 IDictionary<string, string> languageMap = new Dictionary<string, string>
\r
546 {"Abkhazian", "abk"},
\r
547 {"Afrikaans", "afr"},
\r
549 {"Albanian", "sqi"},
\r
550 {"Amharic", "amh"},
\r
551 {"Arabic", "ara"},
\r
552 {"Aragonese", "arg"},
\r
553 {"Armenian", "hye"},
\r
554 {"Assamese", "asm"},
\r
555 {"Avaric", "ava"},
\r
556 {"Avestan", "ave"},
\r
557 {"Aymara", "aym"},
\r
558 {"Azerbaijani", "aze"},
\r
559 {"Bashkir", "bak"},
\r
560 {"Bambara", "bam"},
\r
561 {"Basque", "eus"},
\r
562 {"Belarusian", "bel"},
\r
563 {"Bengali", "ben"},
\r
564 {"Bihari", "bih"},
\r
565 {"Bislama", "bis"},
\r
566 {"Bosnian", "bos"},
\r
567 {"Breton", "bre"},
\r
568 {"Bulgarian", "bul"},
\r
569 {"Burmese", "mya"},
\r
570 {"Catalan", "cat"},
\r
571 {"Chamorro", "cha"},
\r
572 {"Chechen", "che"},
\r
573 {"Chinese", "zho"},
\r
574 {"Church Slavic", "chu"},
\r
575 {"Chuvash", "chv"},
\r
576 {"Cornish", "cor"},
\r
577 {"Corsican", "cos"},
\r
581 {"Divehi", "div"},
\r
582 {"Nederlands", "nld"},
\r
583 {"Dzongkha", "dzo"},
\r
584 {"English", "eng"},
\r
585 {"Esperanto", "epo"},
\r
586 {"Estonian", "est"},
\r
588 {"Faroese", "fao"},
\r
589 {"Fijian", "fij"},
\r
591 {"Francais", "fra"},
\r
592 {"Western Frisian", "fry"},
\r
594 {"Georgian", "kat"},
\r
595 {"Deutsch", "deu"},
\r
596 {"Gaelic (Scots)", "gla"},
\r
598 {"Galician", "glg"},
\r
600 {"Greek Modern", "ell"},
\r
601 {"Guarani", "grn"},
\r
602 {"Gujarati", "guj"},
\r
603 {"Haitian", "hat"},
\r
605 {"Hebrew", "heb"},
\r
606 {"Herero", "her"},
\r
608 {"Hiri Motu", "hmo"},
\r
609 {"Magyar", "hun"},
\r
611 {"Islenska", "isl"},
\r
613 {"Sichuan Yi", "iii"},
\r
614 {"Inuktitut", "iku"},
\r
615 {"Interlingue", "ile"},
\r
616 {"Interlingua", "ina"},
\r
617 {"Indonesian", "ind"},
\r
618 {"Inupiaq", "ipk"},
\r
619 {"Italiano", "ita"},
\r
620 {"Javanese", "jav"},
\r
621 {"Japanese", "jpn"},
\r
622 {"Kalaallisut", "kal"},
\r
623 {"Kannada", "kan"},
\r
624 {"Kashmiri", "kas"},
\r
625 {"Kanuri", "kau"},
\r
626 {"Kazakh", "kaz"},
\r
627 {"Central Khmer", "khm"},
\r
628 {"Kikuyu", "kik"},
\r
629 {"Kinyarwanda", "kin"},
\r
630 {"Kirghiz", "kir"},
\r
633 {"Korean", "kor"},
\r
634 {"Kuanyama", "kua"},
\r
635 {"Kurdish", "kur"},
\r
638 {"Latvian", "lav"},
\r
639 {"Limburgan", "lim"},
\r
640 {"Lingala", "lin"},
\r
641 {"Lithuanian", "lit"},
\r
642 {"Luxembourgish", "ltz"},
\r
643 {"Luba-Katanga", "lub"},
\r
645 {"Macedonian", "mkd"},
\r
646 {"Marshallese", "mah"},
\r
647 {"Malayalam", "mal"},
\r
649 {"Marathi", "mar"},
\r
651 {"Malagasy", "mlg"},
\r
652 {"Maltese", "mlt"},
\r
653 {"Moldavian", "mol"},
\r
654 {"Mongolian", "mon"},
\r
656 {"Navajo", "nav"},
\r
657 {"Ndebele, South", "nbl"},
\r
658 {"Ndebele, North", "nde"},
\r
659 {"Ndonga", "ndo"},
\r
660 {"Nepali", "nep"},
\r
661 {"Norwegian Nynorsk", "nno"},
\r
662 {"Norwegian Bokmål", "nob"},
\r
664 {"Chichewa; Nyanja", "nya"},
\r
665 {"Occitan", "oci"},
\r
666 {"Ojibwa", "oji"},
\r
669 {"Ossetian", "oss"},
\r
670 {"Panjabi", "pan"},
\r
671 {"Persian", "fas"},
\r
673 {"Polish", "pol"},
\r
674 {"Portugues", "por"},
\r
675 {"Pushto", "pus"},
\r
676 {"Quechua", "que"},
\r
677 {"Romansh", "roh"},
\r
678 {"Romanian", "ron"},
\r
680 {"Russian", "rus"},
\r
682 {"Sanskrit", "san"},
\r
683 {"Serbian", "srp"},
\r
684 {"Hrvatski", "hrv"},
\r
685 {"Sinhala", "sin"},
\r
686 {"Slovak", "slk"},
\r
687 {"Slovenian", "slv"},
\r
688 {"Northern Sami", "sme"},
\r
689 {"Samoan", "smo"},
\r
691 {"Sindhi", "snd"},
\r
692 {"Somali", "som"},
\r
693 {"Sotho Southern", "sot"},
\r
694 {"Espanol", "spa"},
\r
695 {"Sardinian", "srd"},
\r
697 {"Sundanese", "sun"},
\r
698 {"Swahili", "swa"},
\r
699 {"Svenska", "swe"},
\r
700 {"Tahitian", "tah"},
\r
703 {"Telugu", "tel"},
\r
705 {"Tagalog", "tgl"},
\r
707 {"Tibetan", "bod"},
\r
708 {"Tigrinya", "tir"},
\r
710 {"Tswana", "tsn"},
\r
711 {"Tsonga", "tso"},
\r
712 {"Turkmen", "tuk"},
\r
713 {"Turkish", "tur"},
\r
715 {"Uighur", "uig"},
\r
716 {"Ukrainian", "ukr"},
\r
720 {"Vietnamese", "vie"},
\r
721 {"Volapük", "vol"},
\r
723 {"Walloon", "wln"},
\r
726 {"Yiddish", "yid"},
\r
727 {"Yoruba", "yor"},
\r
728 {"Zhuang", "zha"},
\r
731 return languageMap;
\r
735 /// Get a list of available DVD drives which are ready and contain DVD content.
\r
737 /// <returns>A List of Drives with their details</returns>
\r
738 public static List<DriveInformation> GetDrives()
\r
740 List<DriveInformation> drives = new List<DriveInformation>();
\r
741 DriveInfo[] theCollectionOfDrives = DriveInfo.GetDrives();
\r
743 foreach (DriveInfo curDrive in theCollectionOfDrives)
\r
745 if (curDrive.DriveType == DriveType.CDRom && curDrive.IsReady &&
\r
746 File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO"))
\r
748 drives.Add(new DriveInformation
\r
751 VolumeLabel = curDrive.VolumeLabel,
\r
752 RootDirectory = curDrive.RootDirectory + "VIDEO_TS"
\r
761 /// Change a string to Title Case/
\r
763 /// <param name="input">
\r
767 /// A string in title case.
\r
769 public static string TitleCase(string input)
\r
771 string[] tokens = input.Split(' ');
\r
772 StringBuilder sb = new StringBuilder(input.Length);
\r
773 foreach (string s in tokens)
\r
775 sb.Append(s[0].ToString().ToUpper());
\r
776 sb.Append(s.Substring(1).ToLower());
\r
780 return sb.ToString().Trim();
\r