using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms.Design; using System.Windows.Forms; using System.Collections; using System.Drawing.Design; using System.ComponentModel; namespace DarkWynter.Stream.UIInterfacing { public class FileLocationEditor : System.Drawing.Design.UITypeEditor { private IWindowsFormsEditorService edSvc; public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { //If you want the editor to be based on a form (external form that appears when the user presses the ... button), return UITypeEditorEditStyle.Modal; //return UITypeEditorEditStyle.DropDown; } public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value) { edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = System.IO.Directory.GetCurrentDirectory() + "\\Content"; // Launch the FolderBrowserDialog Control if (openFileDialog1.ShowDialog() == DialogResult.OK) { // Parse selected file path int subfilename = openFileDialog1.FileName.LastIndexOf("Content"); int extension = openFileDialog1.FileName.LastIndexOf(".xnb"); string filename = openFileDialog1.FileName.Substring(subfilename, extension - subfilename); return filename; } } return value; } } public class ObjectPropertyEditor : System.Drawing.Design.UITypeEditor { /// /// Supplied from upper layer components that require notification whenever a new Level is loaded. /// /// Controller boolean event arguments public delegate void PropertyGridUpdates(object childObject); public static event PropertyGridUpdates propertyGridUpdates; private IWindowsFormsEditorService edSvc; public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { //If you want the editor to be based on a form (external form that appears when the user presses the ... button), return UITypeEditorEditStyle.Modal; //return UITypeEditorEditStyle.DropDown; } public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value) { // Pass the object to the Applicatoin layer delegates so UI can update propertyGridUpdates(value); // Return the original object return value; } } public class ListPropertyEditor : System.Drawing.Design.UITypeEditor { /// /// Supplied from upper layer components that require notification whenever a new Level is loaded. /// /// Controller boolean event arguments public delegate void ListUpdates(object[] list); public static event ListUpdates listUpdates; private IWindowsFormsEditorService edSvc; public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { //If you want the editor to be based on a form (external form that appears when the user presses the ... button), return UITypeEditorEditStyle.Modal; //return UITypeEditorEditStyle.DropDown; } public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value) { string temp = context.ToString(); //ArrayList arrayList = (ArrayList)value; //List list = Convert.ChangeType(value, value.GetType()); //List list = (List)value; // Pass the object to the Applicatoin layer delegates so UI can update listUpdates(null); // Return the original object return value; } } public class LocationMapEditor : System.Drawing.Design.UITypeEditor { /// /// Supplied from upper layer components that require notification whenever a new Level is loaded. /// /// Controller boolean event arguments public delegate void LocationMapUpdates(object[] locationMap); public static event LocationMapUpdates locationMapUpdates; private IWindowsFormsEditorService edSvc; public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { //If you want the editor to be based on a form (external form that appears when the user presses the ... button), return UITypeEditorEditStyle.Modal; //return UITypeEditorEditStyle.DropDown; } public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value) { // Pass the object to the Applicatoin layer delegates so UI can update locationMapUpdates(null); // Return the original object return value; } } }