/// <summary> /// Set image options /// </summary> public PropertyOf <TEntity> SetImageOptions(NameCreation nameCreation, long maxFileSize, bool isMultiple, params string[] allowedFileExtensions) { _property.DataType = ViewModels.DataType.File; _property.ImageOptions = new ImageOptions { NameCreation = nameCreation, MaxFileSize = maxFileSize, IsMultiple = isMultiple, AllowedFileExtensions = allowedFileExtensions, Settings = new List <ImageSettings>() }; return(this); }
public static string SaveImage( HttpPostedFile file, string fileName, NameCreation nameCreation, params ImageSettings[] settings) { Image img; try { img = Image.FromStream(file.InputStream); } catch { throw new Exception( GetErrorMessage(FileUploadValidationResult.NotImage, "")); } switch (nameCreation) { default: case NameCreation.OriginalFileName: fileName = file.FileName; break; case NameCreation.Guid: fileName = "{0}.jpg".Fill(Guid.NewGuid()); break; case NameCreation.Timestamp: fileName = "{0}.jpg".Fill(DateTime.Now.ToString("ddMMyyhhmmss")); break; case NameCreation.UserInput: break; } foreach (var setting in settings) { SaveImage(setting, (Image)img.Clone(), fileName); } file.InputStream.Dispose(); img.Dispose(); return(fileName); }
/// <summary> /// Set image options /// </summary> public PropertyOf <TEntity> SetFileOptions( NameCreation nameCreation, long maxFileSize, bool isImage, string path, params string[] allowedFileExtensions) { _property.TypeInfo.DataType = DataType.File; _property.FileOptions = new FileOptions { NameCreation = nameCreation, MaxFileSize = maxFileSize, AllowedFileExtensions = allowedFileExtensions, IsImage = isImage, Path = path, Settings = new List <ImageSettings>() }; return(this); }
void Obj_OnNameChanging(object sender, EventArgs e) { EventArgNameChange en = (EventArgNameChange)e; TreeNode nd = this.Parent; if (nd != null) { for (int i = 0; i < nd.Nodes.Count; i++) { if (i != this.Index) { if (string.CompareOrdinal(nd.Nodes[i].Text, en.NewName) == 0) { MessageBox.Show(this.TreeView != null ? this.TreeView.FindForm() : null, "The component name is already used", "Reanme", MessageBoxButtons.OK, MessageBoxIcon.Error); en.Cancel = true; } } } if (!en.Cancel) { NameCreation nc = new NameCreation(); if (!nc.IsValidName(en.NewName)) { MessageBox.Show(this.TreeView != null ? this.TreeView.FindForm() : null, "Invalid component name", "Reanme", MessageBoxButtons.OK, MessageBoxIcon.Error); en.Cancel = true; } } if (!en.Cancel) { string sn = en.NewName.ToLowerInvariant(); if (WebPageCompilerUtility.IsReservedPhpWord(sn)) { MessageBox.Show(this.TreeView != null ? this.TreeView.FindForm() : null, "Invalid component name. It is a reserved word.", "Reanme", MessageBoxButtons.OK, MessageBoxIcon.Error); en.Cancel = true; } } } }
public IPropertyCustomizer File( NameCreation nameCreation, long maxFileSize, bool isImage, string path, params string[] allowedFileExtensions) { if (propertyCustomizerHolder.FileOptions == null) { propertyCustomizerHolder.FileOptions = new FileOptions { Settings = new List <ImageSettings>() }; } propertyCustomizerHolder.FileOptions.NameCreation = nameCreation; propertyCustomizerHolder.FileOptions.MaxFileSize = maxFileSize; propertyCustomizerHolder.FileOptions.IsImage = isImage; propertyCustomizerHolder.FileOptions.Path = path; propertyCustomizerHolder.FileOptions.AllowedFileExtensions = allowedFileExtensions; return(Type(isImage ? Core.DataType.Image : Core.DataType.File)); }
public IPropertyCustomizer File( NameCreation nameCreation, long maxFileSize, bool isImage, string path, params string[] allowedFileExtensions) { if (propertyCustomizerHolder.FileOptions == null) { propertyCustomizerHolder.FileOptions = new FileOptions { Settings = new List<ImageSettings>() }; } propertyCustomizerHolder.FileOptions.NameCreation = nameCreation; propertyCustomizerHolder.FileOptions.MaxFileSize = maxFileSize; propertyCustomizerHolder.FileOptions.IsImage = isImage; propertyCustomizerHolder.FileOptions.Path = path; propertyCustomizerHolder.FileOptions.AllowedFileExtensions = allowedFileExtensions; return Type(isImage ? Core.DataType.Image : Core.DataType.File); }
public bool ParameterNameValid(string name) { NameCreation nc = new NameCreation(); return(nc.IsValidName(name)); }