public bool AddImage(string imagePath, string category, out string errorMessage) { try { string folder = GetImagesFolder(); FileInfo fileInfo = new FileInfo(imagePath); string newImageName = "img_" + Guid.NewGuid().ToString().Replace("-", string.Empty) + fileInfo.Extension; string newImagePath = folder + "\\" + newImageName; File.Copy(imagePath, newImagePath); SC_Image img = new SC_Image(); img.ID = Guid.NewGuid(); img.Category = category; img.Name = fileInfo.Name; img.ImagePath = newImagePath; lock (this.Images) { this.Images.Add(img); } SaveConfiguration(this.Images); } catch (Exception ex) { errorMessage = ex.Message; return(false); } errorMessage = string.Empty; return(true); }
protected void ParentWindow_OKButtonSelected(object sender, EventArgs e) { DocumentTemplate documentTemplate = (DocumentTemplate)this.Tag; documentTemplate.Title = TitleTextBox.Text; documentTemplate.Description = DescriptionTextBox.Text; documentTemplate.ImageID = pictureSelection.ImageID; SC_Image image = ImageManager.GetInstance().Images.GetImageByID(pictureSelection.ImageID); documentTemplate.ImagePath = image.ImagePath; documentTemplate.TemplatePath = TemplatePath; if (WordTemplateApplicationRadioButton.IsChecked == true) { documentTemplate.ApplicationType = ApplicationTypes.Word; } else if (OutlookTemplateApplicationRadioButton.IsChecked == true) { documentTemplate.ApplicationType = ApplicationTypes.Outlook; } else { documentTemplate.ApplicationType = ApplicationTypes.Excel; } // documentTemplate.TargetFolder = this.SelectedFolder; // documentTemplate.ContentTypeID = ContentTypeComboBox.SelectedValue.ToString(); }
public void UpdateTemplateImages(DocumentTemplates documentTemplates) { foreach (DocumentTemplate documentTemplate in documentTemplates) { SC_Image image = ImageManager.GetInstance().Images.GetImageByID(documentTemplate.ImageID); documentTemplate.ImagePath = image.ImagePath; } }
protected override void OnLoad() { base.OnLoad(); if (ImageID != null && ImageID != Guid.Empty) { SC_Image img = ImageManager.GetInstance().Images.GetImageByID(ImageID); var uriSource = new Uri(img.ImagePath, UriKind.Absolute); image1.Source = new BitmapImage(uriSource); } }
void PictureSelectors_OKButtonSelected(object sender, EventArgs e) { if (PicturesListBox.SelectedValue == null) { MessageBox.Show(Languages.Translate("Please select an image")); return; } Guid selectedID = (Guid)PicturesListBox.SelectedValue; this.SelectedImage = ImageManager.GetInstance().Images.GetImageByID(selectedID); }
public bool DeleteImage(Guid id, out string errorMessage) { try { SC_Image img = this.Images.Single(t => t.ID.Equals(id)); File.Delete(img.ImagePath); lock (this.Images) { this.Images.Remove(img); } SaveConfiguration(this.Images); } catch (Exception ex) { errorMessage = ex.Message; return(false); } errorMessage = string.Empty; return(true); }