public BinDirectoryStructure EditValue(BinDirectoryStructure value, ITypeDescriptorContext context) { FolderBrowserDialog dialog = new FolderBrowserDialog(); DescriptionAttribute descAtt = (DescriptionAttribute)context.PropertyDescriptor.Attributes[typeof(DescriptionAttribute)]; if (descAtt != null) { dialog.Description = descAtt.Description; } // Allow the user to create new files via the FolderBrowserDialog. dialog.ShowNewFolderButton = false; // Default to the My Documents folder. dialog.RootFolder = Environment.SpecialFolder.MyComputer; dialog.SelectedPath = value.BinDirectory; DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { value.BinDirectory = dialog.SelectedPath; value.Candle = null; value.Xsds = null; value.Dark = null; } return(value); }
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType) { if (destinationType == typeof(System.String) && value is BinDirectoryStructure) { BinDirectoryStructure bd = (BinDirectoryStructure)value; if (bd.HasSameBinDirectory()) { if (bd.Candle == String.Empty || bd.Candle == null) { return(null); } else { bd.BinDirectory = new FileInfo(bd.Candle).Directory.FullName; return(bd.BinDirectory); } } else { return("..."); } } return(base.ConvertTo(context, culture, value, destinationType)); }
public BinDirectoryStructure EditValue(BinDirectoryStructure value, ITypeDescriptorContext context) { FolderBrowserDialog dialog = new FolderBrowserDialog(); DescriptionAttribute descAtt = (DescriptionAttribute) context.PropertyDescriptor.Attributes[typeof(DescriptionAttribute)]; if (descAtt != null) { dialog.Description = descAtt.Description; } // Allow the user to create new files via the FolderBrowserDialog. dialog.ShowNewFolderButton = false; // Default to the My Documents folder. dialog.RootFolder = Environment.SpecialFolder.MyComputer; dialog.SelectedPath = value.BinDirectory; DialogResult result = dialog.ShowDialog(); if(result == DialogResult.OK) { value.BinDirectory = dialog.SelectedPath; value.Candle = null; value.Xsds = null; value.Dark = null; } return value; }