protected override object CreateResourceConfiguration(string fileName) { var extension = Path.GetExtension(fileName); fileName = PathConvert.GetProjectPath(fileName); Texture2D configuration; if (Array.IndexOf(VideoExtensions, extension) >= 0) { if (Control.ModifierKeys == Keys.Control) { configuration = new ImageSequence { FileName = fileName } } ; else { configuration = new VideoTexture { FileName = fileName } }; } else { configuration = new ImageTexture { FileName = fileName } }; configuration.Name = Path.GetFileNameWithoutExtension(fileName); return(configuration); } }
protected override object CreateResourceConfiguration(string fileName) { var configuration = new TexturedModel(); configuration.FileName = PathConvert.GetProjectPath(fileName); configuration.Name = Path.GetFileNameWithoutExtension(fileName); return(configuration); }
static string GetProjectFileName(string fileName) { if (fileName != null && Path.IsPathRooted(fileName)) { fileName = PathConvert.GetProjectPath(fileName); } return(fileName); }
protected virtual string[] CreateSupportedExtensions() { var newItemTypes = NewItemTypes; if (newItemTypes == null || newItemTypes.Length == 0) { return(new string[0]); } var extensions = from type in newItemTypes from property in type.GetProperties() where property.PropertyType == typeof(string) let filterAttribute = property.GetCustomAttribute <FileNameFilterAttribute>() where filterAttribute != null from extension in ParseFilterExtensions(filterAttribute.Filter).Distinct() select new { extension, type, property }; resourceConstructors = new Dictionary <string, Func <string, object> >(); foreach (var item in extensions) { var itemType = item.type; var itemProperty = item.property; if (item.extension.Contains('*') || resourceConstructors.ContainsKey(item.extension)) { continue; } var nameProperty = itemType.GetProperty("Name"); resourceConstructors[item.extension] = fileName => { var instance = Activator.CreateInstance(itemType); itemProperty.SetValue(instance, PathConvert.GetProjectPath(fileName)); if (nameProperty != null) { nameProperty.SetValue(instance, Path.GetFileNameWithoutExtension(fileName)); } return(instance); }; } return(extensions.Select(item => item.extension).ToArray()); }