public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { ActionAttachEvent aae = context.Instance as ActionAttachEvent; if (aae != null) { ClassPointer root = aae.Class; if (root != null) { ILimnorDesignerLoader loader = root.GetCurrentLoader(); if (loader != null) { EventHandlerMethod ehm = aae.GetHandlerMethod(); if (ehm != null) { DlgMethod dlg = ehm.GetEditDialog(Rectangle.Empty, loader); dlg.DisableAnimate(); if (edSvc.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK) { ehm.OnFinishEdit(aae.ActionId, loader); } } } } } } } return(value); }
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); }
public override bool Edit(UInt32 actionBranchId, Rectangle rcStart, ILimnorDesignerLoader loader, Form caller) { try { _origiContext = VPLUtil.CurrentRunContext; if (loader.Project.IsWebApplication) { if (this.RunAt == EnumWebRunAt.Client) { VPLUtil.CurrentRunContext = EnumRunContext.Client; } else { VPLUtil.CurrentRunContext = EnumRunContext.Server; } } else { VPLUtil.CurrentRunContext = EnumRunContext.Server; } DlgMethod dlg = GetEditDialog(rcStart, loader); if (dlg.ShowDialog(caller) == DialogResult.OK) { OnFinishEdit(actionBranchId, loader); return(true); } } catch (Exception err) { MathNode.Log(caller, err); } finally { VPLUtil.CurrentRunContext = _origiContext; } return(false); }