protected override object OnEditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, System.Windows.Forms.Design.IWindowsFormsEditorService service, object value) { IWithProject mc = context.Instance as IWithProject; if (mc != null) { if (mc.Project == null) { MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType())); } else { GetterClass val = value as GetterClass; System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position; rc.X = curPoint.X; rc.Y = curPoint.Y; DlgMethod dlg = val.CreateMethodEditor(rc); try { dlg.SetNameReadOnly(); dlg.LoadMethod(val, EnumParameterEditType.ReadOnly); dlg.Text = val.ToString(); if (service.ShowDialog(dlg) == DialogResult.OK) { value = val; ILimnorDesignerLoader l = LimnorProject.ActiveDesignerLoader as ILimnorDesignerLoader; if (l != null) { //save the property and hence save the getter DesignUtil.SaveCustomProperty(LimnorProject.ActiveDesignerLoader.Node, l.Writer, val.Property); //save actions List <IAction> actions = val.GetActions(); if (actions != null) { foreach (IAction a in actions) { l.GetRootId().SaveAction(a, l.Writer); } } LimnorProject.ActiveDesignerLoader.NotifyChanges(); } } } catch (Exception err) { MathNode.Log(TraceLogClass.GetForm(provider), err); } finally { val.ExitEditor(); } } } return(value); }
public DlgMethod GetEditDialog(Rectangle rcStart, ILimnorDesignerLoader loader) { if (Owner == null) { MathNode.Log(loader.DesignPane.Window as Form, new DesignerException("Calling EventHandlerMethod.Edit with null method owner")); } if (this.Owner == null) { this.Owner = loader.GetRootId(); } DlgMethod dlg = this.CreateMethodEditor(rcStart); if (Parameters != null && Parameters.Count > 0) { if (typeof(object).Equals(Parameters[0].ObjectType) && string.CompareOrdinal(Parameters[0].Name, "sender") == 0) { Parameters[0] = new ParameterClass(this.Event.Owner.ObjectType, "sender", this); Parameters[0].ReadOnly = true; } if (Parameters.Count > 1) { if (typeof(EventArgs).Equals(Parameters[1].ObjectType) && string.CompareOrdinal(Parameters[1].Name, "e") == 0) { ICustomEventMethodDescriptor ce = this.Event.Owner.ObjectInstance as ICustomEventMethodDescriptor; if (ce != null) { Type pType = ce.GetEventArgumentType(this.Event.Name); if (pType != null) { Parameters[1] = new ParameterClass(pType, "e", this); Parameters[1].ReadOnly = true; } } } } } dlg.LoadMethod(this, EnumParameterEditType.ReadOnly); return(dlg); }