/// <summary>Get the shortname based on the output filter to select the correct output item</summary> /// <param name="filterIndex">The filter index</param> /// <returns>The shortname</returns> public static string GetShortNameFromOutputFilter(int filterIndex) { // Get the cached output filter: var filter = Output; // Split the filter into an array: var filters = filter.Split('|'); // Get selected filter, each filter has 2 '|': var selectedFilter = filters[(filterIndex - 1) * 2]; var tmp = selectedFilter.Split('('); selectedFilter = tmp[0].Trim(); // Get shortname based on longname: var shortname = string.Empty; foreach (var gdalInfoFormat in GdalInfoFormatList.Where(gdalInfoFormat => gdalInfoFormat.LongName.StartsWith(selectedFilter))) { shortname = gdalInfoFormat.ShortName; break; } return(shortname); }
/// <summary>Create the input filter based on the parsed gdal formats</summary> /// <returns>The filter</returns> private static string GetInputFilter() { var filter = new StringBuilder("All files (*.*)|*.*"); foreach (var gdalInfoFormat in GdalInfoFormatList.Where(gdalInfoFormat => !string.IsNullOrEmpty(gdalInfoFormat.Extension))) { // Sometimes the long name already shows the extension. No need to do it twice: if (gdalInfoFormat.LongName.EndsWith(string.Format(".{0})", gdalInfoFormat.Extension))) { filter.AppendFormat("|{0}|*.{1}", gdalInfoFormat.LongName, gdalInfoFormat.Extension); } else { filter.AppendFormat("|{0} (*.{1})|*.{1}", gdalInfoFormat.LongName, gdalInfoFormat.Extension); } } // "GeoTiff (*.tif)|*.tif|All files|*.*" return(filter.ToString()); }
/// <summary>Create the output filter based on the parsed gdal formats</summary> /// <returns>The filter</returns> private static string GetOutputFilter() { var filter = new StringBuilder(); foreach (var gdalInfoFormat in GdalInfoFormatList.Where(gdalInfoFormat => !string.IsNullOrEmpty(gdalInfoFormat.Extension) && gdalInfoFormat.ReadWrite.StartsWith("rw"))) { // Sometimes the long name already shows the extension. No need to do it twice: if (gdalInfoFormat.LongName.EndsWith(string.Format(".{0})", gdalInfoFormat.Extension))) { filter.AppendFormat("{0}|*.{1}|", gdalInfoFormat.LongName, gdalInfoFormat.Extension); } else { filter.AppendFormat("{0} (*.{1})|*.{1}|", gdalInfoFormat.LongName, gdalInfoFormat.Extension); } } // Remove last | return(filter.ToString().TrimEnd('|')); }