private void lstImageFiles_DoubleClick(object sender, EventArgs e) { if (DeclineToDiscardChanges()) { return; } Clear(); string imageFile = (string)lstImageFiles.SelectedItem; if (imageFile.StartsWith(_ImageUsedPrefix)) { imageFile = imageFile.Substring(_ImageUsedPrefix.Length); MessageBox.Show("NOTE: There is already a *.SGNDAT file with the same name as this image!"); } string outputNameWithoutType; List <string> nameWords; string encodedImageName; ImageNameParser.ExtractPlantFileAttributes(_PlantFolder, imageFile, chkRemoveExtraWord.Checked, cboExtraFactFile, out outputNameWithoutType, out nameWords, out encodedImageName, ref _LastGrower); txtEncodedImageName.Text = encodedImageName; txtPlantFileName.Text = outputNameWithoutType + ".sgndat"; txtVarietyName.Text = string.Join(" ", nameWords); GenerateContents(); _PlantIsNew = true; }
private void LoadImageFileList() { lvwImageFiles.Items.Clear(); foreach (string imageFile in _ImageFiles) { string lastGrower = string.Empty; ImageInfo imageInfo = new ImageInfo(); string[] subItems = new string[6]; subItems[0] = imageFile; subItems[1] = string.Empty; subItems[2] = string.Empty; subItems[3] = string.Empty; subItems[4] = string.Empty; subItems[5] = string.Empty; int factFileIndex = cboExtraFactFile.SelectedIndex; ImageNameParser.ExtractPlantFileAttributes(_PlantFolder, imageFile, false, cboExtraFactFile, out imageInfo.OutputNameWithoutType, out imageInfo.NameWords, out imageInfo.EncodedImageName, ref lastGrower); cboExtraFactFile.SelectedIndex = factFileIndex; imageInfo.PlantFile = imageInfo.OutputNameWithoutType + ".sgndat"; imageInfo.PlantPath = Path.Combine(_PlantFolder, imageInfo.PlantFile); subItems[5] = string.Join(" ", imageInfo.NameWords); if (File.Exists(imageInfo.PlantPath)) { imageInfo.PlantPathExists = true; subItems[1] = imageInfo.PlantFile; XmlDocument plantDoc = new XmlDocument(); plantDoc.Load(imageInfo.PlantPath); XmlElement varietyElm = plantDoc.DocumentElement.SelectSingleNode("data[@id='variety']") as XmlElement; if (varietyElm != null) { subItems[3] = varietyElm.InnerText; } foreach (XmlElement includeElm in plantDoc.DocumentElement.SelectNodes("include")) { string includeFile = includeElm.InnerText; if (includeFile.ToLower() != "facts.sgninc") { subItems[2] = includeFile; } } int varietyTips = 0; foreach (XmlElement dataElm in plantDoc.DocumentElement.SelectNodes("data")) { if (dataElm.GetAttribute("id").StartsWith("varietytip")) { varietyTips++; } } subItems[4] = varietyTips.ToString(); } ListViewItem item = new ListViewItem(subItems); item.Tag = imageInfo; lvwImageFiles.Items.Add(item); } }