private void Ok(object param) { if (m_addingOriginalPath != null) { File.Copy(m_addingOriginalPath, m_part.CustomPath); } string imagesPath = Global.AppDataPath + Path.DirectorySeparatorChar + Global.ImagesCacheDirectory; if (!string.IsNullOrWhiteSpace(m_manufacturerLogo) && File.Exists(m_manufacturerLogo) && !m_manufacturerLogo.StartsWith(imagesPath)) { string resultImagePath = imagesPath + Path.DirectorySeparatorChar + Path.GetFileName(m_manufacturerLogo); int count = 1; while (File.Exists(resultImagePath)) { resultImagePath = $"{imagesPath}{Path.DirectorySeparatorChar}{Path.GetFileNameWithoutExtension(m_manufacturerLogo)}({count.ToString()}){Path.GetExtension(m_manufacturerLogo)}"; count++; } File.Copy(m_manufacturerLogo, resultImagePath); ManufacturerLogo = resultImagePath; } string oldImage = m_part.ManufacturerImageLink; m_part.Name = m_name.ValidValue; m_part.Description = m_description; m_part.Manufacturer = m_manufacturer; m_part.ManufacturerImageLink = m_manufacturerLogo; m_part.ManufacturerSite = m_manufacturerSite; m_part.Tags.Clear(); foreach (var item in m_tags.ValidValue) { m_part.Tags.Add(new ValueViewModel <string>(item.RemoveAll(x => char.IsWhiteSpace(x) || x == ','))); } if (oldImage != m_part.ManufacturerImageLink) { m_part.LoadImage(); } m_result = EditPartResult.Ok; Global.Dialogs.Close(this); }
private void Cancel(object param) { m_result = EditPartResult.Cancel; Global.Dialogs.Close(this); }
private void Ok(object param) { if (m_addingOriginalPath != null) { File.Copy(m_addingOriginalPath, m_part.CustomPath); } string imagesPath = Global.AppDataPath + Path.DirectorySeparatorChar + Global.ImagesCacheDirectory; if (!string.IsNullOrWhiteSpace(m_manufacturerLogo) && File.Exists(m_manufacturerLogo) && !m_manufacturerLogo.StartsWith(imagesPath)) { string resultImagePath = imagesPath + Path.DirectorySeparatorChar + Path.GetFileName(m_manufacturerLogo); int count = 1; while(File.Exists(resultImagePath)) { resultImagePath = imagesPath + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(m_manufacturerLogo) + "(" + count.ToString() + ")" + Path.GetExtension(m_manufacturerLogo); count++; } File.Copy(m_manufacturerLogo, resultImagePath); ManufacturerLogo = resultImagePath; } string oldImage = m_part.ManufacturerImageLink; m_part.Name = m_name.ValidValue; m_part.Description = m_description; m_part.Manufacturer = m_manufacturer; m_part.ManufacturerImageLink = m_manufacturerLogo; m_part.ManufacturerSite = m_manufacturerSite; m_part.Tags.Clear(); foreach (var item in m_tags.ValidValue) { m_part.Tags.Add(new ValueViewModel<string>(item.RemoveAll(x => char.IsWhiteSpace(x) || x == ','))); } if (oldImage != m_part.ManufacturerImageLink) m_part.LoadImage(); m_result = EditPartResult.Ok; Global.Dialogs.Close(this); }