/// <summary> /// Displays a selection form to the user. /// </summary> /// <remarks> /// The items, previews, and descriptions are repectively ordered. In other words, /// the i-th item in <paramref name="p_strItems" /> uses the i-th preview in /// <paramref name="p_strPreviews" /> and the i-th description in <paramref name="p_strDescriptions" />. /// Similarly, the idices return as results correspond to the indices of the items in /// <paramref name="p_strItems" />. /// </remarks> /// <param name="p_strItems">The items from which to select.</param> /// <param name="p_strPreviews">The preview image file names for the items.</param> /// <param name="p_strDescriptions">The descriptions of the items.</param> /// <param name="p_strTitle">The title of the selection form.</param> /// <param name="p_booSelectMany">Whether more than one item can be selected.</param> /// <returns>The indices of the selected items.</returns> public int[] Select(string[] p_strItems, string[] p_strPreviews, string[] p_strDescriptions, string p_strTitle, bool p_booSelectMany) { PermissionsManager.CurrentPermissions.Assert(); Image[] imgPreviews = null; if (p_strPreviews != null) { imgPreviews = new Image[p_strPreviews.Length]; for (var i = 0; i < p_strPreviews.Length; i++) { if (p_strPreviews[i] == null) { continue; } try { imgPreviews[i] = Fomod.GetImage(p_strPreviews[i]); } catch (Exception e) { if (!((e is FileNotFoundException) || (e is DecompressionException))) { throw e; } } } //for now I don't think the user needs to be able to detect this. // i don't think it is severe enough to be an exception, as it may be // intentional, and if it is a bug it should be readily apparent // during testing. /*if (intMissingImages > 0) * { * m_strLastError = "There were " + intMissingImages + " filenames specified for preview images which could not be loaded"; * }*/ } var sfmSelectForm = new SelectForm(p_strItems, p_booSelectMany, imgPreviews, p_strDescriptions); sfmSelectForm.Text = p_strTitle; sfmSelectForm.ShowDialog(); var intResults = new int[sfmSelectForm.SelectedIndex.Length]; for (var i = 0; i < sfmSelectForm.SelectedIndex.Length; i++) { intResults[i] = sfmSelectForm.SelectedIndex[i]; } return(intResults); }
/// <summary> /// Displays a selection form to the user. /// </summary> /// <remarks> /// The items, previews, and descriptions are repectively ordered. In other words, /// the i-th item in <paramref name="p_strItems" /> uses the i-th preview in /// <paramref name="p_strPreviews" /> and the i-th description in <paramref name="p_strDescriptions" />. /// Similarly, the idices return as results correspond to the indices of the items in /// <paramref name="p_strItems" />. /// </remarks> /// <param name="p_strItems">The items from which to select.</param> /// <param name="p_strPreviews">The preview image file names for the items.</param> /// <param name="p_strDescriptions">The descriptions of the items.</param> /// <param name="p_strTitle">The title of the selection form.</param> /// <param name="p_booSelectMany">Whether more than one item can be selected.</param> /// <returns>The indices of the selected items.</returns> public int[] Select(string[] p_strItems, string[] p_strPreviews, string[] p_strDescriptions, string p_strTitle, bool p_booSelectMany) { PermissionsManager.CurrentPermissions.Assert(); Image[] imgPreviews = null; if (p_strPreviews != null) { imgPreviews = new Image[p_strPreviews.Length]; for (var i = 0; i < p_strPreviews.Length; i++) { if (p_strPreviews[i] == null) { continue; } try { imgPreviews[i] = Fomod.GetImage(p_strPreviews[i]); } catch (Exception e) { if (!((e is FileNotFoundException) || (e is DecompressionException))) { throw e; } } } //for now I don't think the user needs to be able to detect this. // i don't think it is severe enough to be an exception, as it may be // intentional, and if it is a bug it should be readily apparent // during testing. /*if (intMissingImages > 0) { m_strLastError = "There were " + intMissingImages + " filenames specified for preview images which could not be loaded"; }*/ } var sfmSelectForm = new SelectForm(p_strItems, p_booSelectMany, imgPreviews, p_strDescriptions); sfmSelectForm.Text = p_strTitle; sfmSelectForm.ShowDialog(); var intResults = new int[sfmSelectForm.SelectedIndex.Length]; for (var i = 0; i < sfmSelectForm.SelectedIndex.Length; i++) { intResults[i] = sfmSelectForm.SelectedIndex[i]; } return intResults; }