////////////////////////////////////////////////////////////////////////// public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context == null) { return(value); } NativePropProxy Proxy = context.Instance as NativePropProxy; if (Proxy == null || Proxy.NativeObject == null) { SystemSounds.Asterisk.Play(); return(value); } ScriptCollection OrigCol = value as ScriptCollection; ScriptsForm dlg = new ScriptsForm(); dlg.Game = Proxy.NativeObject.Game; dlg.ParentForm = Form.ActiveForm; foreach (string Scr in OrigCol.Scripts) { dlg.Scripts.Add(Scr); } if (dlg.ShowDialog() == DialogResult.OK) { ScriptCollection NewCol = new ScriptCollection(); foreach (string Scr in dlg.Scripts) { NewCol.Scripts.Add(Scr); } return(NewCol); } else { return(OrigCol); } }
////////////////////////////////////////////////////////////////////////// public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { ScriptCollection Col = value as ScriptCollection; if (Col != null && destinationType == typeof(string)) { if (Col.Scripts.Count == 1) { return(Col.Scripts.Count.ToString() + " script"); } else if (Col.Scripts.Count > 1) { return(Col.Scripts.Count.ToString() + " scripts"); } else { return(""); } } else { return(base.ConvertTo(context, culture, value, destinationType)); } }
////////////////////////////////////////////////////////////////////////// public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context == null) return value; NativePropProxy Proxy = context.Instance as NativePropProxy; if (Proxy == null || Proxy.NativeObject == null) { SystemSounds.Asterisk.Play(); return value; } ScriptCollection OrigCol = value as ScriptCollection; ScriptsForm dlg = new ScriptsForm(); dlg.Game = Proxy.NativeObject.Game; dlg.ParentForm = Form.ActiveForm; foreach(string Scr in OrigCol.Scripts) { dlg.Scripts.Add(Scr); } if (dlg.ShowDialog() == DialogResult.OK) { ScriptCollection NewCol = new ScriptCollection(); foreach (string Scr in dlg.Scripts) { NewCol.Scripts.Add(Scr); } return NewCol; } else return OrigCol; }