55
55
get { return file.FilePath; }
58
[DisplayName ("Type")]
59
[Description ("Type of the file.")]
60
public string FileType {
62
string type = MonoDevelop.Core.Gui.Services.PlatformService.GetMimeTypeForUri (file.Name);
63
return MonoDevelop.Core.Gui.Services.PlatformService.GetMimeTypeDescription (type);
58
67
[Category ("Build")]
59
68
[DisplayName ("Build action")]
60
69
[Description ("Action to perform when building this file.")]
61
public BuildAction BuildAction {
70
[TypeConverter (typeof (BuildActionStringsConverter))]
71
public string BuildAction {
62
72
get { return file.BuildAction; }
63
73
set { file.BuildAction = value; }
71
81
set { file.ResourceId = value; }
85
[DisplayName ("Copy to output directory")]
86
[Description ("Whether to copy the file to the project's output directory when the project is built.")]
87
public FileCopyMode CopyToOutputDirectory {
88
get { return file.CopyToOutputDirectory; }
89
set { file.CopyToOutputDirectory = value; }
74
92
protected override bool IsReadOnly (string propertyName)
76
if (propertyName == "ResourceId" && file.BuildAction != BuildAction.EmbedAsResource)
94
if (propertyName == "ResourceId" && file.BuildAction != MonoDevelop.Projects.BuildAction.EmbeddedResource)
99
[MonoDevelop.DesignerSupport.PropertyGrid.PropertyEditors.StandardValuesSeparator ("--")]
100
class BuildActionStringsConverter : StandardStringsConverter
102
public override System.Collections.ICollection GetStandardStrings (ITypeDescriptorContext context)
104
ProjectFileDescriptor descriptor = context != null?
105
context.Instance as ProjectFileDescriptor : null;
107
if (descriptor != null && descriptor.file != null && descriptor.file.Project != null) {
108
return descriptor.file.Project.GetBuildActions ();
110
return new string[] {"Content", "None", "Compile"};
114
public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
116
return sourceType == typeof (string);
119
public override object ConvertFrom (ITypeDescriptorContext context,
120
System.Globalization.CultureInfo culture, object value)
122
if (!IsValid (context, value))
123
throw new FormatException ("Invalid build target name");
128
//these must encode into XML element names
129
public override bool IsValid (ITypeDescriptorContext context, object value)
131
if (!(value is string))
134
string str = (string) value;
135
if (string.IsNullOrEmpty (str) || !char.IsLetter (str[0]))
138
for (int i = 1; i < str.Length; i++) {
140
if (char.IsLetterOrDigit (c) || c == '_')
149
public override bool GetStandardValuesExclusive (ITypeDescriptorContext context)
151
//only make the list exclusive if we managed to get a list from the parent project
152
ProjectFileDescriptor descriptor = context != null?
153
context.Instance as ProjectFileDescriptor : null;
155
return (descriptor != null && descriptor.file != null && descriptor.file.Project != null);
159
abstract class StandardStringsConverter : TypeConverter
161
public override bool GetStandardValuesSupported (ITypeDescriptorContext context)
166
public override bool CanConvertFrom (ITypeDescriptorContext context, Type sourceType)
168
return sourceType == typeof (string) || base.CanConvertFrom (context, sourceType);
171
public override bool CanConvertTo (ITypeDescriptorContext context, Type destinationType)
173
return destinationType == typeof (string) || base.CanConvertTo (context, destinationType);
176
public override object ConvertFrom (ITypeDescriptorContext context,
177
System.Globalization.CultureInfo culture, object value)
179
if (value != null && value is string)
182
return base.ConvertFrom (context, culture, value);
185
public override object ConvertTo (ITypeDescriptorContext context, System.Globalization.CultureInfo culture,
186
object value, Type destinationType)
188
if (value != null && (destinationType == typeof (string)))
191
return base.ConvertTo (context, culture, value, destinationType);
194
public override StandardValuesCollection GetStandardValues (ITypeDescriptorContext context)
196
return new StandardValuesCollection (GetStandardStrings (context));
199
public abstract System.Collections.ICollection GetStandardStrings (ITypeDescriptorContext context);