public override bool IsSameObjectRef(IObjectIdentity objectPointer) { ParameterClass p = objectPointer as ParameterClass; if (p == null) { CustomMethodParameterPointer cmpp = objectPointer as CustomMethodParameterPointer; if (cmpp != null) { p = cmpp.Parameter; } } if (p != null) { if (p.ParameterID == this.ParameterID) { return(true); } if (string.CompareOrdinal(p.CodeName, this.CodeName) == 0) { return(true); } } return(false); }
public override object Clone() { ParameterClass dtp = (ParameterClass)base.Clone(); dtp._desc = _desc; dtp.Name = Name; dtp.ParameterID = ParameterID; dtp.ReadOnly = ReadOnly; return(dtp); }
public override bool IsSameProperty(IPropertyPointer objectPointer) { ParameterClass p = objectPointer as ParameterClass; if (p != null) { if (p.ParameterID == this.ParameterID) { return(true); } if (string.CompareOrdinal(p.CodeName, this.CodeName) == 0) { return(true); } } return(false); }
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context) { if (context != null && context.Instance != null) { MethodDiagramViewer mdv = context.Instance as MethodDiagramViewer; if (mdv != null) { WebClientEventHandlerMethod wcehm = mdv.Method as WebClientEventHandlerMethod; if (wcehm != null) { if (string.CompareOrdinal("ReturnType", context.PropertyDescriptor.Name) == 0) { return(UITypeEditorEditStyle.None); } } } DataTypePointer dp = context.Instance as DataTypePointer; if (dp != null) { if (dp.ReadOnly) { return(UITypeEditorEditStyle.None); } ParameterClass pc = dp as ParameterClass; if (pc != null) { ConstructorClass cc = pc.Method as ConstructorClass; if (cc != null) { ClassPointer cp = cc.Owner as ClassPointer; if (cp != null) { if (typeof(Attribute).IsAssignableFrom(cp.BaseClassType)) { return(UITypeEditorEditStyle.DropDown); } } } } } } return(UITypeEditorEditStyle.Modal); }
public bool IsSameProperty(ISourceValuePointer p) { ParameterClass pc = p as ParameterClass; if (pc != null) { return(pc.ParameterID == this.ParameterID); } else { CustomMethodParameterPointer cmp = p as CustomMethodParameterPointer; if (cmp != null) { if (cmp.Parameter != null) { if (cmp.Parameter.ParameterID == this.ParameterID) { return(true); } } } } return(false); }
private void taskExecuter(IEventPointer eventPointer, object[] eventParameters) { try { foreach (EventAction ea in eventHandlers) { EventPointer ep = eventPointer as EventPointer; if (ea.Event.IsSameObjectRef(ep)) { List <ParameterClass> eventValues = new List <ParameterClass>(); if (eventParameters != null && eventParameters.Length > 0) { ParameterInfo[] pifs = ep.Parameters; if (pifs.Length != eventParameters.Length) { throw new DesignerException("Event {0} parameter count mismatch", ep.MemberName); } for (int i = 0; i < pifs.Length; i++) { ParameterClass p = new ParameterClass(new TypePointer(pifs[i].ParameterType)); p.Name = pifs[i].Name; p.ObjectInstance = eventParameters[i]; eventValues.Add(p); } } //execute the event handlers TaskIdList actIdList = ea.TaskIDList; foreach (TaskID tid in actIdList) { UInt32 classId = tid.ClassId; //if (tid.IsGroup) //{ //} //else //{ //find the action in the list of all actions List <IAction> acts = null; if (classId == _map.ClassId) { acts = actions; } else { ObjectIDmap classmap = _map.GetMapByClassId(classId); if (classmap != null) { ActionEventCollection av = classmap.GetTypedData <ActionEventCollection>(); if (av == null) { av = new ActionEventCollection(classmap); classmap.SetTypedData <ActionEventCollection>(av); av.LoadActions(); } acts = av.actions; } } if (acts != null) { foreach (IAction a in acts) { if (a.ActionId == tid.ActionId) { a.Execute(eventValues); break; } } } //} } break; } } } catch (Exception err) { MathNode.Log(err); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (service != null) { DataTypePointer typeScope = null; ITypeScopeHolder th = context.Instance as ITypeScopeHolder; if (th != null) { typeScope = th.GetTypeScope(context.PropertyDescriptor.Name); } if (typeScope == null) { foreach (Attribute a in context.PropertyDescriptor.Attributes) { TypeScopeAttribute ts = a as TypeScopeAttribute; if (ts != null && ts.Scope != null) { if (ts.Scope.IsGenericParameter) { Type[] ctps = ts.Scope.GetGenericParameterConstraints(); if (ctps != null && ctps.Length > 0) { typeScope = new DataTypePointer(new TypePointer(ctps[0])); break; } } else { typeScope = new DataTypePointer(new TypePointer(ts.Scope)); break; } } } } MethodClass scopeMethod = null; IScopeMethodHolder mh = context.Instance as IScopeMethodHolder; if (mh != null) { scopeMethod = mh.GetScopeMethod(); } IWithProject mc = context.Instance as IWithProject; if (mc == null) { ComponentInterfaceWrapper ciw = context.Instance as ComponentInterfaceWrapper; if (ciw != null) { mc = ciw.Value as IWithProject; } } if (mc == null) { MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("{0} does not implement IWithProject", context.Instance.GetType())); } else { if (mc.Project == null) { MathNode.Log(TraceLogClass.GetForm(provider), new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType())); } else { MethodDiagramViewer mdv = mc as MethodDiagramViewer; if (mdv != null) { WebClientEventHandlerMethod wcehm = mdv.Method as WebClientEventHandlerMethod; if (wcehm != null) { if (string.CompareOrdinal("ReturnType", context.PropertyDescriptor.Name) == 0) { return(value); } } } bool isMethodReturn = false; IObjectPointer op = value as IObjectPointer; DataTypePointer val = new DataTypePointer(); if (op != null) { val.SetDataType(op); } for (int i = 0; i < context.PropertyDescriptor.Attributes.Count; i++) { MethodReturnAttribute mra = context.PropertyDescriptor.Attributes[i] as MethodReturnAttribute; if (mra != null) { isMethodReturn = true; break; } } // bool bUseDropDown = false; EnumWebRunAt runAt = EnumWebRunAt.Inherit; PropertyClassWebClient pcwc = context.Instance as PropertyClassWebClient; if (pcwc != null) { bUseDropDown = true; runAt = EnumWebRunAt.Client; } else { PropertyClassWebServer pcws = context.Instance as PropertyClassWebServer; if (pcws != null) { bUseDropDown = true; runAt = EnumWebRunAt.Server; } } if (!bUseDropDown) { ParameterClass pc = context.Instance as ParameterClass; if (pc != null) { ConstructorClass cc = pc.Method as ConstructorClass; if (cc != null) { ClassPointer cp = cc.Owner as ClassPointer; if (cp != null) { if (typeof(Attribute).IsAssignableFrom(cp.BaseClassType)) { //use drop down bUseDropDown = true; } } } } } // if (bUseDropDown) { TypeSelector drp = TypeSelector.GetAttributeParameterDialogue(service, runAt, val.BaseClassType); service.DropDownControl(drp); if (drp.SelectedType != null) { val.SetDataType(drp.SelectedType); bool bIsForLocalType = false; if (string.Compare(context.PropertyDescriptor.Name, ActionAssignInstance.Instance_Type, StringComparison.Ordinal) == 0) { PropertiesWrapper pw = context.Instance as PropertiesWrapper; if (pw != null) { AB_SingleAction sa = pw.Owner as AB_SingleAction; if (sa != null) { ActionAssignInstance aa = sa.ActionData as ActionAssignInstance; if (aa != null) { bIsForLocalType = true; aa.SetParameterValue(ConstObjectPointer.VALUE_Type, drp.SelectedType); } } } } if (bIsForLocalType) { } else { value = val; } } } else { Type typeAttr = null; MethodClass mc0 = scopeMethod; if (mc0 == null) { mc0 = mc as MethodClass; } if (mc0 == null) { MethodDiagramViewer mcv = mc as MethodDiagramViewer; if (mcv != null) { mc0 = mcv.Method; } } if (mc0 != null) { if (mc.Project.ProjectType == EnumProjectType.WebAppPhp) { if (mc0.WebUsage == EnumMethodWebUsage.Server) { typeAttr = typeof(PhpTypeAttribute); } else { typeAttr = typeof(JsTypeAttribute); } } else if (mc.Project.ProjectType == EnumProjectType.WebAppAspx) { if (mc0.WebUsage == EnumMethodWebUsage.Client) { typeAttr = typeof(JsTypeAttribute); } } } FrmObjectExplorer dlg = DesignUtil.GetDataTypeSelectionDialogue(mc.Project, scopeMethod, val, isMethodReturn, typeScope, typeAttr); if (service.ShowDialog(dlg) == DialogResult.OK) { val.SetDataType(dlg.SelectedDataType); bool bIsForLocalType = false; if (string.Compare(context.PropertyDescriptor.Name, ActionAssignInstance.Instance_Type, StringComparison.Ordinal) == 0) { PropertiesWrapper pw = context.Instance as PropertiesWrapper; if (pw != null) { AB_SingleAction sa = pw.Owner as AB_SingleAction; if (sa != null) { ActionAssignInstance aa = sa.ActionData as ActionAssignInstance; if (aa != null) { bIsForLocalType = true; aa.SetParameterValue(ActionAssignInstance.Instance_Type, dlg.SelectedDataType); } } } } else { ComponentIconLocal cil = context.Instance as ComponentIconLocal; bIsForLocalType = (cil != null); if (bIsForLocalType) { cil.LocalPointer.ClassType = dlg.SelectedDataType; } } if (bIsForLocalType) { } else { ExceptionHandlerList.PropertyDescriptorExceptionHandler pdeh = context.PropertyDescriptor as ExceptionHandlerList.PropertyDescriptorExceptionHandler; if (pdeh != null) { pdeh.Handler.ExceptionType = val; } else { value = val; } } } } } } } } return(value); }
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index >= 0 && e.Index < this.Items.Count) { bool selected = ((e.State & DrawItemState.Selected) != 0); ParameterClass item = this.Items[e.Index] as ParameterClass; if (item != null) { Rectangle rcBK = new Rectangle(e.Bounds.Left, e.Bounds.Top, 1, this.ItemHeight); if (e.Bounds.Width > this.ItemHeight) { rcBK.Width = e.Bounds.Width - this.ItemHeight; rcBK.X = this.ItemHeight; if (selected) { e.Graphics.FillRectangle(Brushes.LightBlue, rcBK); } else { if (e.Index < FixedParameterCount) { e.Graphics.FillRectangle(Brushes.LightGray, rcBK); } else { e.Graphics.FillRectangle(Brushes.White, rcBK); } } } Rectangle rc = new Rectangle(e.Bounds.Left, e.Bounds.Top, this.ItemHeight, this.ItemHeight); float w = (float)(e.Bounds.Width - this.ItemHeight); if (w > 0) { RectangleF rcf = new RectangleF((float)(rc.Left + this.ItemHeight + 2), (float)(rc.Top), w, (float)this.ItemHeight); if (selected) { e.Graphics.DrawString(item.ToString(), this.Font, Brushes.White, rcf); } else { e.Graphics.DrawString(item.ToString(), this.Font, Brushes.Black, rcf); } } e.Graphics.DrawImage(item.Icon, rc); } else { if (selected) { e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds); } else { e.Graphics.FillRectangle(Brushes.White, e.Bounds); } if (this.Items[e.Index] != null) { e.Graphics.DrawString(this.Items[e.Index].ToString(), this.Font, Brushes.Black, e.Bounds.Left, e.Bounds.Top); } } } }