public bool Edit(XmlObjectWriter writer, IMethod context, Form caller, bool isNewAction) { LimnorProject project = _class.Project; FormActionParameters dlgData = new FormActionParameters(); if (_parameters == null) { _parameters = new ParameterValueCollection(); } ActionMethod.ValidateParameterValues(_parameters); dlgData.SetScopeMethod(context); dlgData.LoadAction(this, _class.XmlData); DialogResult ret = dlgData.ShowDialog(caller); if (ret == DialogResult.OK) { _class.SaveAction(this, writer); ILimnorDesignPane pane = project.GetTypedData <ILimnorDesignPane>(_class.ClassId); if (pane != null) { pane.OnActionChanged(_class.ClassId, this, isNewAction); pane.OnNotifyChanges(); } else { DesignUtil.WriteToOutputWindowAndLog("Error editong ActionAssignInstance. ClassPointer [{0}] is not in design mode when creating an action. Please close the design pane and re-open it.", _class.ClassId); } return(true); } return(false); }
public override bool LoadToDesigner(List <UInt32> used, MethodDiagramViewer designer) { if (!used.Contains(this.BranchId)) { used.Add(BranchId); if (_decisionTable != null) { ClassPointer list = designer.ActionEventCollection; if (list != null) { for (int i = 0; i < _decisionTable.ConditionCount; i++) { if (_decisionTable[i].Actions != null) { for (int k = 0; k < _decisionTable[i].Actions.Count; k++) { _decisionTable[i].Actions[k].Action = this.ActionsHolder.GetActionInstance(_decisionTable[i].Actions[k].ActionId); if (_decisionTable[i].Actions[k].Action == null) { DesignUtil.WriteToOutputWindowAndLog("Action data for {0} not found [{1}] calling {1}.LoadToDesigner. You may delete it from the method and re-create it.", _decisionTable[i].Actions[k].ActionId, this.GetType().Name); } } } } } } return(designer.LoadAction(this)); } return(false); }
protected override void OnImportAction() { base.OnImportAction(); ISingleAction av = this.ActionObject as ISingleAction; if (av.ActionData != null) { ActionName = av.ActionData.ActionName; Description = av.ActionData.Description; MethodDiagramViewer mv = this.Parent as MethodDiagramViewer; List <ParameterValue> ps = av.ActionData.ParameterValues; if (ps != null && ps.Count > 0) { foreach (ParameterValue p in ps) { if (p != null) { p.SetCustomMethod(mv.DesignerHolder.Method); } } } } else { DesignUtil.WriteToOutputWindowAndLog("Action data for {0} not found for [{1}]. You may delete the action from the method and re-create it.", av.ActionId, this.ActionName); } }
public override bool LoadToDesigner(List <UInt32> used, MethodDiagramViewer designer) { if (!used.Contains(BranchId)) { used.Add(BranchId); if (_actionList != null) { ClassPointer list = designer.ActionEventCollection; if (list != null) { for (int k = 0; k < _actionList.Count; k++) { TaskID tid = new TaskID(_actionList[k].ActionId, list.ClassId); _actionList[k].Action = GetActionInstance(_actionList[k].ActionId); // list.GetAction(tid); if (_actionList[k].Action == null) { _actionList[k].Action = designer.DesignerHolder.GetAction(tid); if (_actionList[k].Action == null) { DesignUtil.WriteToOutputWindowAndLog("Action data for {0} not found for [{1}] calling {2}.LoadToDesigner. You may delete it from the method and re-create it.", _actionList[k].ActionId, this.Name, this.GetType().Name); } } } } } return(designer.LoadAction(this)); } return(false); }
public override bool LoadToDesigner(List <UInt32> used, MethodDiagramViewer designer) { if (!used.Contains(BranchId)) { used.Add(BranchId); ActionSubMethod act = (ActionSubMethod)_actId.LoadActionInstance(this.ActionsHolder); if (act != null) { _actionData = act; } else { if (_actionData != null) { _actId.SetAction(_actionData); } } if (_actionData == null) { _actionData = (ActionSubMethod)designer.DesignerHolder.GetAction(_actId); } if (_actionData == null) { DesignUtil.WriteToOutputWindowAndLog("Action data for {0} not found for [{1}] calling {2}.LoadToDesigner", ActionId, this.Name, this.GetType().Name); } return(designer.LoadAction(this)); } return(false); }
public override string GetPhpScriptReferenceCode(StringCollection code) { if (this.Method == null) { DesignUtil.WriteToOutputWindowAndLog("GetPhpScriptReferenceCode failed. Method not found. ParameterID:{0}, ActionID:{1}, ClassId:{2}", this.ParameterID, ActionId, this.ClassId); } else { SubMethodInfoPointer smi = this.Method as SubMethodInfoPointer; if (smi == null) { MethodClass mc = this.Method as MethodClass; if (ActionId != 0 && mc != null && mc.ActionList != null) { IAction act = mc.ActionList.GetActionById(ActionId); if (act != null) { smi = act.ActionMethod as SubMethodInfoPointer; } } } if (smi == null) { DesignUtil.WriteToOutputWindowAndLog("GetPhpScriptReferenceCode failed. method [{0}][{1}] found by parameter [{2}] is not a SubMethodInfoPointer", this.Method.MethodName, this.Method.ObjectKey, this.ParameterID); } else { if (this.ActionBranch == null) { MethodClass mc = this.Method as MethodClass; if (mc != null && mc.SubMethod != null && mc.SubMethod.Count > 0) { IMethod0 m0 = mc.SubMethod.Peek(); AB_SubMethodAction asa = m0 as AB_SubMethodAction; if (asa != null) { this.SetActionBranch(asa); } } } if (this.ActionBranch == null) { DesignUtil.WriteToOutputWindowAndLog("GetPhpScriptReferenceCode failed. parameter [{2}] for method [{0}][{1}] missing ActionBranch", this.Method.MethodName, this.Method.ObjectKey, this.ParameterID); } else { SubMethodInfo mi = smi.MethodInformation as SubMethodInfo; string target = smi.Owner.GetPhpScriptReferenceCode(code); return(string.Format(CultureInfo.InvariantCulture, "{0}[{1}]", target, mi.GetIndexCodePHP(smi, this.ActionBranch.BranchId))); } } } return(CodeName); }
protected override void OnImportAction() { base.OnImportAction(); AB_DecisionTableActions av = this.ActionObject as AB_DecisionTableActions; if (av != null) { ActionName = av.Name; Description = av.Description; } else { DesignUtil.WriteToOutputWindowAndLog("Decision table not found"); } }
/// <summary> /// create action component /// </summary> /// <param name="designer"></param> public override bool LoadToDesigner(List <UInt32> used, MethodDiagramViewer designer) { if (_actionData == null) { ClassPointer root = designer.ActionEventCollection; if (root != null && _actId != null) { _actionData = _actId.LoadActionInstance(this.ActionsHolder); } if (_actionData == null && _actId != null) { _actionData = designer.DesignerHolder.GetAction(_actId); } if (_actionData == null) { DesignUtil.WriteToOutputWindowAndLog("Action data for {0} not found for [{1}] calling {2}.LoadToDesigner. You may delete the action from the method and re-create it.", ActionId, this.Name, this.GetType().Name); } } return(designer.LoadAction(this)); }
public bool Edit(XmlObjectWriter writer, IMethod context, Form caller, bool isNewAction) { IMathExpression mathExp = MathExp; if (mathExp != null) { ActionExecMath a2 = (ActionExecMath)this.Clone(); Rectangle rc = new Rectangle(0, 0, 100, 30); System.Drawing.Point curPoint = System.Windows.Forms.Cursor.Position; rc.X = curPoint.X; rc.Y = curPoint.Y; a2.MathExp.ScopeMethod = context; IMathEditor dlg = a2.MathExp.CreateEditor(rc); if (((Form)dlg).ShowDialog(caller) == DialogResult.OK) { MathExpMethod mem = new MathExpMethod(); mem.Action = this; mem.MathExpression = dlg.MathExpression; ActionMethod = mem; if (_class != null) { LimnorProject project = _class.Project; ILimnorDesignPane pane = project.GetTypedData <ILimnorDesignPane>(_class.ClassId); if (pane != null) { pane.OnActionChanged(_class.ClassId, this, isNewAction); pane.OnNotifyChanges(); } else { DesignUtil.WriteToOutputWindowAndLog("Error Editng ActionExecMath. ClassPointer [{0}] is not in design mode when creating an action. Please close the design pane and re-open it.", _class.ClassId); } } return(true); } } return(false); }
public override CodeExpression GetReferenceCode(IMethodCompile method, CodeStatementCollection statements, bool forValue) { if (this.Method == null) { DesignUtil.WriteToOutputWindowAndLog("Method not found. ParameterID:{0}, ActionID:{1}, ClassId:{2}", this.ParameterID, ActionId, this.ClassId); } else { SubMethodInfoPointer smi = this.Method as SubMethodInfoPointer; if (smi == null) { DesignUtil.WriteToOutputWindowAndLog("method [{0}][{1}] found by parameter [{2}] is not a SubMethodInfoPointer", this.Method.MethodName, this.Method.ObjectKey, this.ParameterID); } else { SubMethodInfo mi = smi.MethodInformation as SubMethodInfo; CodeExpression[] ps = mi.GetIndexCodes(smi, method, MemberId); CodeExpression ce = new CodeArrayIndexerExpression(smi.Owner.GetReferenceCode(method, statements, forValue), ps); return(ce); } } return(null); }
protected virtual void OnRead(IXmlCodeReader reader, XmlNode node) { //get local variable from method component list based on _memberId XmlNode varNode = DesignUtil.GetMethodVariableNode(node.OwnerDocument.DocumentElement, _memberId); if (varNode == null) { LocalVariable v = LocalVariable.GetUnsavedLocalVariable(_classId, _memberId); if (v == null) { //it can be a variable in an exception handler //get method id UInt32 methodId = 0; XmlNode mn = node; while (mn != null) { methodId = XmlUtil.GetAttributeUInt(mn, XmlTags.XMLATT_ScopeId); if (methodId != 0) { break; } mn = mn.ParentNode; } if (methodId != 0) { ClassPointer root = ((XmlObjectReader)reader).ObjectList.GetTypedData <ClassPointer>(); MethodClass mc = root.GetCustomMethodById(methodId); if (mc != null) { v = mc.GetLocalVariable(_memberId); } } else { DesignUtil.WriteToOutputWindowAndLog("Error reading local variable. Variable node not found [{0},{1}]", _classId, _memberId); } } if (v != null) { _name = v.Name; _type = v.ClassType; _owner = v._owner; _instance = v._instance; _nameChecker = v._nameChecker; _debug = v._debug; } } else { _name = XmlUtil.GetNameAttribute(varNode); Type t = XmlUtil.GetLibTypeAttribute(varNode); if (t != null) { if (t.Equals(typeof(ParameterClass))) { MethodClass mc = _owner as MethodClass; if (mc != null) { _type = (DataTypePointer)Activator.CreateInstance(t, mc); } } else { _type = (DataTypePointer)Activator.CreateInstance(t); } reader.ReadObjectFromXmlNode(varNode, _type, t, this); } else { UInt32 id = XmlUtil.GetAttributeUInt(node, XmlTags.XMLATT_ComponentID); if (id != 0) { //try to get it from exception handler of a method ClassPointer root = ClassPointer.CreateClassPointer(((XmlObjectReader)reader).ObjectList); LocalVariable v = root.GetLocalVariable(id); if (v != null) { _name = v.Name; _type = v.ClassType; _owner = v._owner; _instance = v._instance; _nameChecker = v._nameChecker; _debug = v._debug; } } else { #if DEBUG throw new DesignerException("Error reading local variable from class [{0}]. XPath:[{1}]", reader.ClassId, XmlUtil.GetPath(node)); #endif } } } }
public void ReloadActions() { ActionGroupDesignerHolder holder = DesignerHolder as ActionGroupDesignerHolder; AB_Squential actions = holder.Actions; bool b = holder.DisableUndo; holder.DisableUndo = true; holder.ClearAllComponent(); Controls.Clear(); BranchList bl = actions.ActionList; LoadActions(bl); //load component icons List <ComponentIcon> iconList = IconList; if (iconList == null) { iconList = new List <ComponentIcon>(); } List <ComponentIcon> invalids = new List <ComponentIcon>(); foreach (ComponentIcon ci in iconList) { if (ci.ClassPointer == null) { invalids.Add(ci); } } foreach (ComponentIcon ci in invalids) { iconList.Remove(ci); } //find root ClassPointer root = holder.Designer.GetRootId(); List <IClass> objList; if (Method.IsStatic) { objList = new List <IClass>(); } else { objList = root.GetClassList(); } SubMethodInfoPointer smi = null; if (Method.SubMethod.Count > 0) { smi = Method.SubMethod.Peek() as SubMethodInfoPointer; } //initialize existing icons, creating ComponentIcon.ClassPointer foreach (ComponentIcon ic in iconList) { ic.SetDesigner(holder.Designer); ComponentIconPublic cip = ic as ComponentIconPublic; if (cip == null) { ComponentIconLocal lv = ic as ComponentIconLocal; if (lv != null) { lv.ReadOnly = true; if (!ParentEditor.LocalVariableDeclared(lv)) { lv.ScopeGroupId = actions.BranchId; } } else { } if (smi != null) { ParameterClassSubMethod sm = ic.ClassPointer as ParameterClassSubMethod; if (sm != null) { if (sm.ActionId == 0) { sm.ActionId = smi.ActionOwner.ActionId; } ParameterClass pc = ic.ClassPointer as ParameterClass; if (pc != null && pc.ObjectType != null) { if (pc.ObjectType.IsGenericParameter) { if (pc.ConcreteType == null) { if (smi.ActionOwner.MethodOwner != null) { CustomPropertyPointer cpp = smi.ActionOwner.MethodOwner.Owner as CustomPropertyPointer; if (cpp != null) { pc.ConcreteType = cpp.GetConcreteType(pc.ObjectType); } } } } } } } } else { } } //add new public component icons int x0 = 10; int y0 = 30; int x = x0; int y = y0; int dx = 10; int dy = 10; foreach (IClass c in objList) { bool bFound = false; foreach (ComponentIcon ic in iconList) { if (ic.ClassPointer == null) { } else { if (ic.ClassPointer.IsSameObjectRef(c)) { bFound = true; break; } } } if (!bFound) { ComponentIconPublic cip = new ComponentIconPublic(holder.Designer, c, Method); cip.Location = new Point(x, y); y += dy; y += cip.Height; if (y >= this.Height) { y = y0; x += dx; x += cip.Width; } iconList.Add(cip); } } //add new local component icons List <ComponentIcon> picons = ParentEditor.IconList; foreach (ComponentIcon lv in picons) { ComponentIconPublic cip0 = lv as ComponentIconPublic; if (cip0 == null) { bool bFound = false; foreach (ComponentIcon ic in iconList) { if (ic.ClassPointer.IsSameObjectRef(lv.ClassPointer)) { bFound = true; break; } } if (!bFound) { ComponentIcon cip = (ComponentIcon)lv.Clone(); cip.SetDesigner(holder.Designer); cip.ReadOnly = true; cip.Location = new Point(x, y); y += dy; y += cip.Height; if (y >= this.Height) { y = y0; x += dx; x += cip.Width; } iconList.Add(cip); } } } //add parameters if (Method.ParameterCount > 0) { foreach (ParameterClass c in Method.Parameters) { bool bFound = false; foreach (ComponentIcon ic in iconList) { if (ic.ClassPointer.IsSameObjectRef(c)) { bFound = true; break; } } if (!bFound) { ComponentIconParameter cip = new ComponentIconParameter(holder.Designer, c, Method); cip.Location = new Point(x, y); y += dy; y += cip.Height; if (y >= this.Height) { y = y0; x += dx; x += cip.Width; } iconList.Add(cip); } } } //add action parameters ISingleAction sa = actions as ISingleAction; if (sa != null && sa.ActionData != null && sa.ActionData.ActionMethod != null && sa.ActionData.ActionMethod.MethodPointed.MethodParameterTypes != null) { List <ParameterClass> plist = new List <ParameterClass>(); SubMethodInfoPointer smp = sa.ActionData.ActionMethod.MethodPointed as SubMethodInfoPointer; if (smp != null) { foreach (ParameterClassSubMethod p in smp.Parameters) { plist.Add(p); } } else { foreach (IParameter p in sa.ActionData.ActionMethod.MethodPointed.MethodParameterTypes) { ParameterClass c = p as ParameterClass; if (c == null) { try { c = sa.ActionData.ActionMethod.MethodPointed.GetParameterType(p.ParameterID) as ParameterClass; if (c == null) { DesignUtil.WriteToOutputWindowAndLog("Cannot get ParameterClass {0} for method {1} of {2}.", p.Name, sa.ActionData.ActionMethod.MethodName, sa.ActionData.ActionMethod.MethodPointed.GetType()); continue; } } catch (Exception errp) { DesignUtil.WriteToOutputWindowAndLog(errp, "Cannot get ParameterClass {0} for method {1} of {2}", p.Name, sa.ActionData.ActionMethod.MethodName, sa.ActionData.ActionMethod.MethodPointed.GetType()); continue; } } if (c != null) { plist.Add(c); } } } foreach (ParameterClass c in plist) { bool bFound = false; foreach (ComponentIcon ic in iconList) { if (ic.ClassPointer.IsSameObjectRef(c)) { ParameterClass c0 = ic.ClassPointer as ParameterClass; c0.ReadOnly = true; c0.Description = c.Description; bFound = true; break; } } if (!bFound) { ComponentIcon cip; ActionBranchParameter abp = c as ActionBranchParameter; if (abp != null) { cip = new ComponentIconActionBranchParameter(actions); cip.ClassPointer = abp; cip.SetDesigner(holder.Designer); } else { cip = new ComponentIconParameter(holder.Designer, c, Method); } cip.Location = new Point(x, y); y += dy; y += cip.Height; if (y >= this.Height) { y = y0; x += dx; x += cip.Width; } iconList.Add(cip); } } } //add icons holder.AddControlsToIconsHolder(iconList.ToArray()); foreach (ComponentIcon ic in iconList) { ComponentIconPublic cip = ic as ComponentIconPublic; if (cip == null) { if (ic.Left < 0) { ic.Left = 2; } if (ic.Top < 0) { ic.Top = 2; } ic.BringToFront(); ic.RefreshLabelPosition(); ic.RefreshLabelText(); ComponentIconLocal cil = ic as ComponentIconLocal; if (cil != null) { cil.HookNameChecker(); } } } //} InitializeInputTypes(); ValidateControlPositions(); holder.DisableUndo = b; }