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 /// Create a CSV file with the data from the Main Window Chapters tab
\r
141 /// <param name="mainWindow">Main Window</param>
\r
142 /// <param name="filePathName">Path to save the csv file</param>
\r
143 /// <returns>True if successful </returns>
\r
144 public static bool SaveChapterMarkersToCsv(frmMain mainWindow, string filePathName)
\r
148 string csv = string.Empty;
\r
150 foreach (DataGridViewRow row in mainWindow.data_chpt.Rows)
\r
152 csv += row.Cells[0].Value.ToString();
\r
154 csv += row.Cells[1].Value.ToString().Replace(",", "\\,");
\r
155 csv += Environment.NewLine;
\r
157 StreamWriter file = new StreamWriter(filePathName);
\r
163 catch (Exception exc)
\r
165 MessageBox.Show("Unable to save Chapter Makrers file! \nChapter marker names will NOT be saved in your encode \n\n" + exc, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
171 /// Function which generates the filename and path automatically based on
\r
172 /// the Source Name, DVD title and DVD Chapters
\r
174 /// <param name="mainWindow">
\r
175 /// The main Window.
\r
178 /// The Generated FileName
\r
180 public static string AutoName(frmMain mainWindow)
\r
182 string autoNamePath = string.Empty;
\r
183 if (mainWindow.drp_dvdtitle.Text != "Automatic")
\r
185 // Get the Source Name
\r
186 string sourceName = mainWindow.SourceName;
\r
188 // Remove any illeagal characters from the source name
\r
189 foreach (char character in Path.GetInvalidFileNameChars())
\r
191 if (autoNamePath != null)
\r
193 sourceName = sourceName.Replace(character.ToString(), string.Empty);
\r
197 if (Properties.Settings.Default.AutoNameRemoveUnderscore)
\r
198 sourceName = sourceName.Replace("_", " ");
\r
200 if (Properties.Settings.Default.AutoNameTitleCase)
\r
201 sourceName = TitleCase(sourceName);
\r
203 // Get the Selected Title Number
\r
204 string[] titlesplit = mainWindow.drp_dvdtitle.Text.Split(' ');
\r
205 string dvdTitle = titlesplit[0].Replace("Automatic", string.Empty);
\r
207 // Get the Chapter Start and Chapter End Numbers
\r
208 string chapterStart = mainWindow.drop_chapterStart.Text.Replace("Auto", string.Empty);
\r
209 string chapterFinish = mainWindow.drop_chapterFinish.Text.Replace("Auto", string.Empty);
\r
210 string combinedChapterTag = chapterStart;
\r
211 if (chapterFinish != chapterStart && chapterFinish != string.Empty)
\r
212 combinedChapterTag = chapterStart + "-" + chapterFinish;
\r
214 // Get the destination filename.
\r
215 string destinationFilename;
\r
216 if (Properties.Settings.Default.autoNameFormat != string.Empty)
\r
218 destinationFilename = Properties.Settings.Default.autoNameFormat;
\r
219 destinationFilename =
\r
220 destinationFilename.Replace("{source}", sourceName).Replace("{title}", dvdTitle).Replace(
\r
221 "{chapters}", combinedChapterTag);
\r
224 destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag;
\r
226 // Add the appropriate file extension
\r
227 if (mainWindow.drop_format.SelectedIndex == 0)
\r
229 if (Properties.Settings.Default.useM4v || mainWindow.Check_ChapterMarkers.Checked ||
\r
230 mainWindow.AudioSettings.RequiresM4V() || mainWindow.Subtitles.RequiresM4V())
\r
231 destinationFilename += ".m4v";
\r
233 destinationFilename += ".mp4";
\r
235 else if (mainWindow.drop_format.SelectedIndex == 1)
\r
236 destinationFilename += ".mkv";
\r
238 // Now work out the path where the file will be stored.
\r
239 // First case: If the destination box doesn't already contain a path, make one.
\r
240 if (!mainWindow.text_destination.Text.Contains(Path.DirectorySeparatorChar.ToString()))
\r
242 // If there is an auto name path, use it...
\r
243 if (Properties.Settings.Default.autoNamePath.Trim() != string.Empty &&
\r
244 Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")
\r
245 autoNamePath = Path.Combine(Properties.Settings.Default.autoNamePath, destinationFilename);
\r
246 else // ...otherwise, output to the source directory
\r
247 autoNamePath = null;
\r
249 else // Otherwise, use the path that is already there.
\r
251 // Use the path and change the file extension to match the previous destination
\r
252 autoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text),
\r
253 destinationFilename);
\r
255 if (Path.HasExtension(mainWindow.text_destination.Text))
\r
256 autoNamePath = Path.ChangeExtension(autoNamePath,
\r
257 Path.GetExtension(mainWindow.text_destination.Text));
\r
261 return autoNamePath;
\r
265 /// Get's HandBrakes version data from the CLI.
\r
267 public static void SetCliVersionData()
\r
271 // 0 = SVN Build / Version
\r
273 DateTime lastModified = File.GetLastWriteTime("HandBrakeCLI.exe");
\r
275 if (Properties.Settings.Default.cliLastModified == lastModified && Properties.Settings.Default.hb_build != 0)
\r
278 Properties.Settings.Default.cliLastModified = lastModified;
\r
280 Process cliProcess = new Process();
\r
281 ProcessStartInfo handBrakeCli = new ProcessStartInfo("HandBrakeCLI.exe", " -u -v0")
\r
283 UseShellExecute = false,
\r
284 RedirectStandardError = true,
\r
285 RedirectStandardOutput = true,
\r
286 CreateNoWindow = true
\r
288 cliProcess.StartInfo = handBrakeCli;
\r
292 cliProcess.Start();
\r
294 // Retrieve standard output and report back to parent thread until the process is complete
\r
295 TextReader stdOutput = cliProcess.StandardError;
\r
297 while (!cliProcess.HasExited)
\r
299 line = stdOutput.ReadLine() ?? string.Empty;
\r
300 Match m = Regex.Match(line, @"HandBrake ([svnM0-9.]*) \([0-9]*\)");
\r
301 Match platform = Regex.Match(line, @"- ([A-Za-z0-9\s ]*) -");
\r
305 string data = line.Replace("(", string.Empty).Replace(")", string.Empty).Replace("HandBrake ", string.Empty);
\r
306 string[] arr = data.Split(' ');
\r
308 Properties.Settings.Default.hb_build = int.Parse(arr[1]);
\r
309 Properties.Settings.Default.hb_version = arr[0];
\r
312 if (platform.Success)
\r
314 Properties.Settings.Default.hb_platform = platform.Value.Replace("-", string.Empty).Trim();
\r
317 if (cliProcess.TotalProcessorTime.Seconds > 10) // Don't wait longer than 10 seconds.
\r
319 Process cli = Process.GetProcessById(cliProcess.Id);
\r
320 if (!cli.HasExited)
\r
327 Properties.Settings.Default.Save();
\r
329 catch (Exception e)
\r
331 MessageBox.Show("Unable to retrieve version information from the CLI. \nError:\n" + e);
\r
336 /// Check to make sure that the user has an up to date version of the CLI installed.
\r
338 public static void CheckForValidCliVersion()
\r
340 // Make sure we have a recent version for svn builds
\r
341 string version = Properties.Settings.Default.hb_version;
\r
342 if (version.Contains("svn"))
\r
344 version = version.Replace("svn", string.Empty).Trim();
\r
346 int.TryParse(version, out build);
\r
347 if (build < Properties.Settings.Default.hb_min_cli)
\r
350 "It appears you are trying to use a CLI executable that is too old for this version of the HandBrake GUI.\n" +
\r
351 "Please update the HandBrakeCLI.exe to a newer build.\n\n" +
\r
352 "HandBrake build Detected: " + Properties.Settings.Default.hb_version,
\r
354 MessageBoxButtons.OK,
\r
355 MessageBoxIcon.Error);
\r
362 /// Check if the queue recovery file contains records.
\r
363 /// If it does, it means the last queue did not complete before HandBrake closed.
\r
364 /// So, return a boolean if true.
\r
367 /// True if there is a queue to recover.
\r
369 public static bool CheckQueueRecovery()
\r
373 string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\hb_queue_recovery.xml");
\r
374 if (File.Exists(tempPath))
\r
376 using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))
\r
378 List<Job> list = Ser.Deserialize(strm) as List<Job>;
\r
380 if (list.Count != 0)
\r
388 return false; // Keep quiet about the error.
\r
393 /// Get the Process ID of HandBrakeCLI for the current instance.
\r
395 /// <param name="before">List of processes before the new process was started</param>
\r
396 /// <returns>Int - Process ID</returns>
\r
397 public static int GetCliProcess(Process[] before)
\r
399 // This is a bit of a cludge. Maybe someone has a better idea on how to impliment this.
\r
400 // Since we used CMD to start HandBrakeCLI, we don't get the process ID from hbProc.
\r
401 // Instead we take the processes before and after, and get the ID of HandBrakeCLI.exe
\r
402 // avoiding any previous instances of HandBrakeCLI.exe in before.
\r
403 // Kill the current process.
\r
405 DateTime startTime = DateTime.Now;
\r
408 Process[] hbProcesses = Process.GetProcessesByName("HandBrakeCLI");
\r
409 while (hbProcesses.Length == 0)
\r
411 hbProcesses = Process.GetProcessesByName("HandBrakeCLI");
\r
412 duration = DateTime.Now - startTime;
\r
413 if (duration.Seconds > 5 && hbProcesses.Length == 0)
\r
414 // Make sure we don't wait forever if the process doesn't start
\r
418 Process hbProcess = null;
\r
419 foreach (Process process in hbProcesses)
\r
421 bool found = false;
\r
422 // Check if the current CLI instance was running before we started the current one
\r
423 foreach (Process bprocess in before)
\r
425 if (process.Id == bprocess.Id)
\r
429 // If it wasn't running before, we found the process we want.
\r
432 hbProcess = process;
\r
436 if (hbProcess != null)
\r
437 return hbProcess.Id;
\r
443 /// Clear all the encode log files.
\r
445 public static void ClearLogs()
\r
447 string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
\r
448 if (Directory.Exists(logDir))
\r
450 DirectoryInfo info = new DirectoryInfo(logDir);
\r
451 FileInfo[] logFiles = info.GetFiles("*.txt");
\r
452 foreach (FileInfo file in logFiles)
\r
454 if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log") &&
\r
455 !file.Name.Contains("tmp_appReadable_log.txt"))
\r
456 File.Delete(file.FullName);
\r
462 /// Clear old log files x days in the past
\r
464 public static void ClearOldLogs()
\r
466 string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
\r
467 if (Directory.Exists(logDir))
\r
469 DirectoryInfo info = new DirectoryInfo(logDir);
\r
470 FileInfo[] logFiles = info.GetFiles("*.txt");
\r
472 foreach (FileInfo file in logFiles)
\r
474 if (file.LastWriteTime < DateTime.Now.AddDays(-30))
\r
476 if (!file.Name.Contains("last_scan_log") && !file.Name.Contains("last_encode_log") &&
\r
477 !file.Name.Contains("tmp_appReadable_log.txt"))
\r
478 File.Delete(file.FullName);
\r
485 /// Begins checking for an update to HandBrake.
\r
487 /// <param name="callback">The method that will be called when the check is finished.</param>
\r
488 /// <param name="debug">Whether or not to execute this in debug mode.</param>
\r
489 public static void BeginCheckForUpdates(AsyncCallback callback, bool debug)
\r
491 ThreadPool.QueueUserWorkItem(new WaitCallback(delegate
\r
495 // Is this a stable or unstable build?
\r
497 Properties.Settings.Default.hb_build.ToString()
\r
499 ? Properties.Settings.Default.
\r
501 : Properties.Settings.Default.appcast;
\r
503 // Initialize variables
\r
504 WebRequest request = WebRequest.Create(url);
\r
505 WebResponse response = request.GetResponse();
\r
506 AppcastReader reader = new AppcastReader();
\r
508 // Get the data, convert it to a string, and parse it into the AppcastReader
\r
510 new StreamReader(response.GetResponseStream())
\r
513 // Further parse the information
\r
514 string build = reader.Build;
\r
516 int latest = int.Parse(build);
\r
517 int current = Properties.Settings.Default.hb_build;
\r
518 int skip = Properties.Settings.Default.skipversion;
\r
520 // If the user wanted to skip this version, don't report the update
\r
521 if (latest == skip)
\r
523 UpdateCheckInformation info =
\r
524 new UpdateCheckInformation
\r
526 NewVersionAvailable = false,
\r
527 BuildInformation = null
\r
529 callback(new UpdateCheckResult(debug, info));
\r
533 // Set when the last update was
\r
534 Properties.Settings.Default.lastUpdateCheckDate =
\r
536 Properties.Settings.Default.Save();
\r
538 UpdateCheckInformation info2 =
\r
539 new UpdateCheckInformation
\r
541 NewVersionAvailable = latest > current,
\r
542 BuildInformation = reader
\r
544 callback(new UpdateCheckResult(debug, info2));
\r
546 catch (Exception exc)
\r
548 callback(new UpdateCheckResult(debug, new UpdateCheckInformation { Error = exc }));
\r
554 /// End Check for Updates
\r
556 /// <param name="result">
\r
560 /// Update Check information
\r
562 public static UpdateCheckInformation EndCheckForUpdates(IAsyncResult result)
\r
564 UpdateCheckResult checkResult = (UpdateCheckResult)result;
\r
565 return checkResult.Result;
\r
569 /// Map languages and their iso639_2 value into a IDictionary
\r
571 /// <returns>A Dictionary containing the language and iso code</returns>
\r
572 public static IDictionary<string, string> MapLanguages()
\r
574 IDictionary<string, string> languageMap = new Dictionary<string, string>
\r
578 {"Abkhazian", "abk"},
\r
579 {"Afrikaans", "afr"},
\r
581 {"Albanian", "sqi"},
\r
582 {"Amharic", "amh"},
\r
583 {"Arabic", "ara"},
\r
584 {"Aragonese", "arg"},
\r
585 {"Armenian", "hye"},
\r
586 {"Assamese", "asm"},
\r
587 {"Avaric", "ava"},
\r
588 {"Avestan", "ave"},
\r
589 {"Aymara", "aym"},
\r
590 {"Azerbaijani", "aze"},
\r
591 {"Bashkir", "bak"},
\r
592 {"Bambara", "bam"},
\r
593 {"Basque", "eus"},
\r
594 {"Belarusian", "bel"},
\r
595 {"Bengali", "ben"},
\r
596 {"Bihari", "bih"},
\r
597 {"Bislama", "bis"},
\r
598 {"Bosnian", "bos"},
\r
599 {"Breton", "bre"},
\r
600 {"Bulgarian", "bul"},
\r
601 {"Burmese", "mya"},
\r
602 {"Catalan", "cat"},
\r
603 {"Chamorro", "cha"},
\r
604 {"Chechen", "che"},
\r
605 {"Chinese", "zho"},
\r
606 {"Church Slavic", "chu"},
\r
607 {"Chuvash", "chv"},
\r
608 {"Cornish", "cor"},
\r
609 {"Corsican", "cos"},
\r
613 {"Divehi", "div"},
\r
614 {"Nederlands", "nld"},
\r
615 {"Dzongkha", "dzo"},
\r
616 {"English", "eng"},
\r
617 {"Esperanto", "epo"},
\r
618 {"Estonian", "est"},
\r
620 {"Faroese", "fao"},
\r
621 {"Fijian", "fij"},
\r
623 {"Francais", "fra"},
\r
624 {"Western Frisian", "fry"},
\r
626 {"Georgian", "kat"},
\r
627 {"Deutsch", "deu"},
\r
628 {"Gaelic (Scots)", "gla"},
\r
630 {"Galician", "glg"},
\r
632 {"Greek Modern", "ell"},
\r
633 {"Guarani", "grn"},
\r
634 {"Gujarati", "guj"},
\r
635 {"Haitian", "hat"},
\r
637 {"Hebrew", "heb"},
\r
638 {"Herero", "her"},
\r
640 {"Hiri Motu", "hmo"},
\r
641 {"Magyar", "hun"},
\r
643 {"Islenska", "isl"},
\r
645 {"Sichuan Yi", "iii"},
\r
646 {"Inuktitut", "iku"},
\r
647 {"Interlingue", "ile"},
\r
648 {"Interlingua", "ina"},
\r
649 {"Indonesian", "ind"},
\r
650 {"Inupiaq", "ipk"},
\r
651 {"Italiano", "ita"},
\r
652 {"Javanese", "jav"},
\r
653 {"Japanese", "jpn"},
\r
654 {"Kalaallisut", "kal"},
\r
655 {"Kannada", "kan"},
\r
656 {"Kashmiri", "kas"},
\r
657 {"Kanuri", "kau"},
\r
658 {"Kazakh", "kaz"},
\r
659 {"Central Khmer", "khm"},
\r
660 {"Kikuyu", "kik"},
\r
661 {"Kinyarwanda", "kin"},
\r
662 {"Kirghiz", "kir"},
\r
665 {"Korean", "kor"},
\r
666 {"Kuanyama", "kua"},
\r
667 {"Kurdish", "kur"},
\r
670 {"Latvian", "lav"},
\r
671 {"Limburgan", "lim"},
\r
672 {"Lingala", "lin"},
\r
673 {"Lithuanian", "lit"},
\r
674 {"Luxembourgish", "ltz"},
\r
675 {"Luba-Katanga", "lub"},
\r
677 {"Macedonian", "mkd"},
\r
678 {"Marshallese", "mah"},
\r
679 {"Malayalam", "mal"},
\r
681 {"Marathi", "mar"},
\r
683 {"Malagasy", "mlg"},
\r
684 {"Maltese", "mlt"},
\r
685 {"Moldavian", "mol"},
\r
686 {"Mongolian", "mon"},
\r
688 {"Navajo", "nav"},
\r
689 {"Ndebele, South", "nbl"},
\r
690 {"Ndebele, North", "nde"},
\r
691 {"Ndonga", "ndo"},
\r
692 {"Nepali", "nep"},
\r
693 {"Norwegian Nynorsk", "nno"},
\r
694 {"Norwegian Bokmål", "nob"},
\r
696 {"Chichewa; Nyanja", "nya"},
\r
697 {"Occitan", "oci"},
\r
698 {"Ojibwa", "oji"},
\r
701 {"Ossetian", "oss"},
\r
702 {"Panjabi", "pan"},
\r
703 {"Persian", "fas"},
\r
705 {"Polish", "pol"},
\r
706 {"Portugues", "por"},
\r
707 {"Pushto", "pus"},
\r
708 {"Quechua", "que"},
\r
709 {"Romansh", "roh"},
\r
710 {"Romanian", "ron"},
\r
712 {"Russian", "rus"},
\r
714 {"Sanskrit", "san"},
\r
715 {"Serbian", "srp"},
\r
716 {"Hrvatski", "hrv"},
\r
717 {"Sinhala", "sin"},
\r
718 {"Slovak", "slk"},
\r
719 {"Slovenian", "slv"},
\r
720 {"Northern Sami", "sme"},
\r
721 {"Samoan", "smo"},
\r
723 {"Sindhi", "snd"},
\r
724 {"Somali", "som"},
\r
725 {"Sotho Southern", "sot"},
\r
726 {"Espanol", "spa"},
\r
727 {"Sardinian", "srd"},
\r
729 {"Sundanese", "sun"},
\r
730 {"Swahili", "swa"},
\r
731 {"Svenska", "swe"},
\r
732 {"Tahitian", "tah"},
\r
735 {"Telugu", "tel"},
\r
737 {"Tagalog", "tgl"},
\r
739 {"Tibetan", "bod"},
\r
740 {"Tigrinya", "tir"},
\r
742 {"Tswana", "tsn"},
\r
743 {"Tsonga", "tso"},
\r
744 {"Turkmen", "tuk"},
\r
745 {"Turkish", "tur"},
\r
747 {"Uighur", "uig"},
\r
748 {"Ukrainian", "ukr"},
\r
752 {"Vietnamese", "vie"},
\r
753 {"Volapük", "vol"},
\r
755 {"Walloon", "wln"},
\r
758 {"Yiddish", "yid"},
\r
759 {"Yoruba", "yor"},
\r
760 {"Zhuang", "zha"},
\r
763 return languageMap;
\r
767 /// Get a list of available DVD drives which are ready and contain DVD content.
\r
769 /// <returns>A List of Drives with their details</returns>
\r
770 public static List<DriveInformation> GetDrives()
\r
772 List<DriveInformation> drives = new List<DriveInformation>();
\r
773 DriveInfo[] theCollectionOfDrives = DriveInfo.GetDrives();
\r
775 foreach (DriveInfo curDrive in theCollectionOfDrives)
\r
777 if (curDrive.DriveType == DriveType.CDRom && curDrive.IsReady &&
\r
778 File.Exists(curDrive.RootDirectory + "VIDEO_TS\\VIDEO_TS.IFO"))
\r
780 drives.Add(new DriveInformation
\r
783 VolumeLabel = curDrive.VolumeLabel,
\r
784 RootDirectory = curDrive.RootDirectory + "VIDEO_TS"
\r
793 /// Change a string to Title Case/
\r
795 /// <param name="input">
\r
799 /// A string in title case.
\r
801 public static string TitleCase(string input)
\r
803 string[] tokens = input.Split(' ');
\r
804 StringBuilder sb = new StringBuilder(input.Length);
\r
805 foreach (string s in tokens)
\r
807 sb.Append(s[0].ToString().ToUpper());
\r
808 sb.Append(s.Substring(1).ToLower());
\r
812 return sb.ToString().Trim();
\r