subtitleMemorize.UtilsInputFiles.GetFileDescriptions C# (CSharp) 메소드

GetFileDescriptions() 공개 메소드

Gets the file descriptions. It resolves wildcards so that this function returns a list of usable files.
public GetFileDescriptions ( ) : List
리턴 List
		public List<FileDesc> GetFileDescriptions() {
			Dictionary<String, String> currentDictionary = new Dictionary<String, String>();
			List<FileDesc> fileDescs = new List<FileDesc>();
			foreach (DataEntry dataEntry in m_dataEntries) {
				currentDictionary = dataEntry.properties ?? currentDictionary;

				if (String.IsNullOrWhiteSpace (dataEntry.filename)) {
					fileDescs.Add (new FileDesc (null, new Dictionary<String,String> (currentDictionary)));
				} else {
					// resolve wildcards
					fileDescs.AddRange(AddFileDescToList(false, dataEntry.filename, currentDictionary));
				}
			}

			return fileDescs;
		}

Usage Example

예제 #1
0
		private void OpenSubtitleWindow(int subIndex) {
			m_subtitleOptionsWindow.Title = "Sub" + (subIndex + 1) + " Options";

			Gtk.Entry currentEntry = subIndex == 0 ? m_entryTargetLanguage : m_entryNativeLanguage;
			m_subOptionsWindow_subIndex = subIndex;

			// read properties of first file to get selected stream and show them in combobox
			UtilsInputFiles uif = new UtilsInputFiles(currentEntry.Text);
			List<UtilsInputFiles.FileDesc> fileDescs = uif.GetFileDescriptions ();

			String selectedEncoding = "utf-8";
			String selectedStreamString = null;
			if (fileDescs.Count > 0 && fileDescs [0].properties.ContainsKey ("enc"))
				selectedEncoding = fileDescs [0].properties ["enc"];
			if (fileDescs.Count > 0 && fileDescs [0].properties.ContainsKey ("stream"))
				selectedStreamString = fileDescs [0].properties ["stream"];

			int selectedStreamIndex = -1;
			if (!Int32.TryParse (selectedStreamString, out selectedStreamIndex))
				selectedStreamIndex = -1;

			// get all streams in first video file
			List<StreamInfo> firstVideoFileStreams = null;
			for (int index = 0; index < fileDescs.Count; index++) {
				String thisFilename = fileDescs [index].filename;

				if (!String.IsNullOrWhiteSpace (thisFilename) && UtilsCommon.GetFileTypeByFilename (thisFilename) == UtilsCommon.FileType.FT_VIDEO) {
					if (!File.Exists (thisFilename))
						throw new Exception ("File \"" + thisFilename + "\" does not exist");
					firstVideoFileStreams = StreamInfo.ReadAllStreams (thisFilename);

					break;
				}
			}

			// fill streams box
			int selectedEntry_SubStreams = -1;
			int numberOfEntries_SubStreams = 0;
			m_liststoreSubStreams.Clear();
			m_subOptionsWindowStreamIndices.Clear ();
			if (firstVideoFileStreams != null) {
				for (int index = 0; index < firstVideoFileStreams.Count; index++) {
					if (firstVideoFileStreams [index].StreamTypeValue == StreamInfo.StreamType.ST_SUBTITLE) {
						selectedEntry_SubStreams = selectedEntry_SubStreams == -1 ? 0 : selectedEntry_SubStreams;
						if (index == selectedStreamIndex)
							selectedEntry_SubStreams = numberOfEntries_SubStreams;
						numberOfEntries_SubStreams++;

						m_subOptionsWindowStreamIndices.Add (index);
						m_liststoreSubStreams.AppendValues ("Stream " + index + " - " + firstVideoFileStreams [index].Language);
					}
				}
			}
			if(selectedEntry_SubStreams >= 0)
				m_comboboxSubStream.Active = selectedEntry_SubStreams;


			// fill encodings in subtitle options
			m_liststoreSubEncoding.Clear();
			int encodingIndex = 0;
			int utf8index = -1;
			int selectedEncodingIndex = -1;
			foreach (InfoEncoding enc in InfoEncoding.getEncodings()) {
				if (enc.ShortName == "utf-8")
					utf8index = encodingIndex;
				if (enc.ShortName == selectedEncoding)
					selectedEncodingIndex = encodingIndex;
				m_liststoreSubEncoding.AppendValues (enc.LongName);
				encodingIndex++;
			}
			if (selectedEncodingIndex >= 0)
				m_comboboxSubEncoding.Active = selectedEncodingIndex;
			else if (utf8index >= 0)
				m_comboboxSubEncoding.Active = utf8index;
			else
				m_comboboxSubEncoding.Active = 0;


			m_subtitleOptionsWindow.ShowAll ();
		}
All Usage Examples Of subtitleMemorize.UtilsInputFiles::GetFileDescriptions