/// <summary> /// Called when folder is selected. /// </summary> /// <param name="obj">The object.</param> private void OnFolderSelectCommand(TopicFacts obj) { var directory = string.IsNullOrEmpty(obj.ImagePath) ? Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) : File.Exists(obj.ImagePath) ? obj.ImagePath : File.Exists(Path.Combine(Environment.CurrentDirectory, "Resources", "Templates", "Site", obj.ImagePath)) ? Path.Combine(Environment.CurrentDirectory, "Resources", "Templates", "Site", obj.ImagePath) : Path.Combine(Environment.CurrentDirectory, "Resources", "Templates", "Site", Path.GetDirectoryName(obj.ImagePath)); using (var dlg = new OpenFileDialog()) { //dlg.InitialDirectory = string.IsNullOrEmpty(obj.ImagePath) ? Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) // : System.IO.Path.GetFullPath(obj.ImagePath); dlg.InitialDirectory = directory; dlg.Filter = "png files (*.png)|*.png|jpeg files (*.jpeg)|(*.jpeg)"; dlg.FilterIndex = 1; dlg.RestoreDirectory = true; dlg.Multiselect = false; // Get the selected file name and display in a TextBox if (dlg.ShowDialog() == DialogResult.OK && obj != null) { obj.ImagePath = dlg.FileName; } } }
/// <summary> /// Initializes a new instance of the <see cref="FactStruct"/> class. /// </summary> /// <param name="fact">The fact.</param> public FactStruct(TopicFacts fact) { ImagePath = fact.ImagePath; Text = fact.Text; CitationText = fact.CitationText; }