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 void LoadActions() { actions = DesignUtil.GetActions(_map); eventHandlers = DesignUtil.GetEventHandlers(_map); if (ProjectEnvironment.RunMode) //&& _map.ParanetMap == null) { //if an action is for executing a custom method then the actions inside the method //only holds actions ID's. We need associate actions objects to those action ID's //by going through all action branches foreach (IAction a in actions) { //ActionCustom ac = a as ActionCustom; //if (ac != null) //{ // ac.SetActions(actions); //} CustomMethodPointer cmp = a.ActionMethod as CustomMethodPointer; if (cmp != null) { cmp.MethodDef.SetActions(actions); } } //link events to actions foreach (EventAction ea in eventHandlers) { if (ea.Event.ObjectInstance != null) { SetEventLink(ea.Event); } } } }
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); }
private void buttonInsert_Click(object sender, EventArgs e) { FrmObjectExplorer dlg = DesignUtil.GetPropertySelector(null, null, new DataTypePointer(new TypePointer(typeof(IProperty)))); if (dlg.ShowDialog(this) == DialogResult.OK) { IProperty p = dlg.SelectedObject as IProperty; if (p != null) { bool bFound = false; for (int i = 0; i < _table.Rows.Count; i++) { IProperty p0 = _table.Rows[i][0] as IProperty; if (p0 != null) { if (p0.IsSameObjectRef(p)) { dataGridView1.Rows[i].Selected = true; bFound = true; break; } } } if (!bFound) { _table.Rows.Add(p, null); dataGridView1.Refresh(); } } } }
/// <summary> /// it must be called from a separated app domain other than the designer. /// </summary> /// <param name="xmlFile"></param> public void Load(string xmlFile) { ProjectEnvironment.RunMode = true; XmlDocument doc = new XmlDocument(); doc.Load(xmlFile); XmlNode _node = doc.DocumentElement; LimnorProject project = new LimnorProject(LimnorProject.GetProjectFileByComponentFile(xmlFile)); //create root object UInt32 classId = XmlUtil.GetAttributeUInt(_node, XmlTags.XMLATT_ClassID); UInt32 memberId = XmlUtil.GetAttributeUInt(_node, XmlTags.XMLATT_ComponentID); ObjectIDmap map = new ObjectIDmap(project, DesignUtil.MakeDDWord(memberId, classId), _node); XmlObjectReader xr = new XmlObjectReader(map, ClassPointer.OnAfterReadRootComponent, ClassPointer.OnRootComponentCreated); map.SetReader(xr); _rootId = new ClassPointer(classId, memberId, map, null); string file = project.GetComponentFileByClassId(classId); ComponentLoader loader = new ComponentLoader(xr, file); DesignSurface ds = new DesignSurface(); ds.BeginLoad(loader); if (xr.Errors != null && xr.Errors.Count > 0) { MathNode.Log(xr.Errors); } _rootId.LoadActionInstances(); }
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 void OnComponentRemoved(object obj) { ObjectIDmap map = null; ClassInstancePointer cr = obj as ClassInstancePointer; if (cr != null) { map = _loader.ObjectMap.GetMap(cr.ObjectInstance); } else { map = _loader.ObjectMap.GetMap(obj); } //if (map == null) //{ // throw new DesignerException("object map not found for {0} when removing component", obj); //} if (map != null) { TreeNode node = null; if (cr != null) { node = _objExplorer.LocateNode(cr); } else { IObjectPointer o = DesignUtil.CreateObjectPointer(map, obj); node = _objExplorer.LocateNode(o); } if (node != null) { node.Remove(); } } }
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); }
public CustomInterfaceMethodPointer(InterfaceElementMethod method, IClass holder, IAction act) { _act = act; _method = method; _wholeId = DesignUtil.MakeDDWord(_method.MethodId, holder.ClassId); _holder = holder; }
//generate server php code public override string CreatePhpScript(StringCollection method) { string ce; if (_valuePointer != null) { if (DesignUtil.IsDataFieldPointer(_valuePointer)) { ce = _valuePointer.GetPhpScriptReferenceCode(method); } else if (this.CanBeWebServerValue()) { //a server value ce = _valuePointer.GetPhpScriptReferenceCode(method); } else { //a client value uploaded ce = string.Format(System.Globalization.CultureInfo.InvariantCulture, "$this->jsonFromClient->values->{0}", DataPassingCodeName); } } else { ce = CodeName; } return(ce); }
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 void OnDoubleClick(Control host) { Form f = host.FindForm(); host.Cursor = System.Windows.Forms.Cursors.WaitCursor; if (f != null) { f.Cursor = System.Windows.Forms.Cursors.WaitCursor; } IObjectPointer pp = _valuePointer; IMethod method = null; MathNodeRoot r = this.root; if (r != null) { method = r.ScopeMethod; } FrmObjectExplorer dlg = DesignUtil.GetPropertySelector(pp, method, null); if (dlg != null) { if (dlg.ShowDialog(f) == DialogResult.OK) { _valuePointer = dlg.SelectedObject as IObjectPointer; host.Invalidate(); } } host.Cursor = System.Windows.Forms.Cursors.Default; if (f != null) { f.Cursor = System.Windows.Forms.Cursors.Default; } }
private async void CreateFolderOnClick(object sender, RoutedEventArgs routedEventArgs) { string text = await DesignUtil.InputTextDialogAsync("Name"); FileUtil.CreateFolder(App.sub + "\\" + currentPath + "\\" + text); InitListAsync(currentPath); }
public void OnComponentRemoved(object obj) { ObjectIDmap map = null; ClassInstancePointer cr = obj as ClassInstancePointer; if (cr != null) { map = _loader.ObjectMap.GetMap(cr.ObjectInstance); } else { map = _loader.ObjectMap.GetMap(obj); } if (map != null) { TreeNode node = null; if (cr != null) { node = _objExplorer.LocateNode(cr); } else { IObjectPointer o = DesignUtil.CreateObjectPointer(map, obj); node = _objExplorer.LocateNode(o); } if (node != null) { node.Remove(); } } }
public bool CanBeWebServerValue() { if (_valuePointer == null) { return(false); } return(DesignUtil.CanBeWebServerObject(_valuePointer)); }
public override ActionClass CreateSetPropertyAction(ILimnorDesignPane designPane, IClass holder, IMethod scopeMethod, IActionsHolder actsHolder) { PropertyPointer pp = new PropertyPointer(); pp.SetPropertyInfo(_val); pp.Owner = Owner; return(DesignUtil.CreateSetPropertyAction(pp, designPane, scopeMethod, actsHolder, designPane.PaneHolder.FindForm())); }
public override bool ExecuteMenuCommand(LimnorProject project, IClass holder, XmlNode node, MultiPanes pane, IMethod scopeMethod, IActionsHolder actsHolder) { PropertyPointer pp = new PropertyPointer(); pp.SetPropertyInfo(_val); pp.Owner = Owner; return(DesignUtil.CreateSetPropertyAction(pp, pane.Loader.DesignPane, scopeMethod, actsHolder, pane.FindForm()) != null); }
public bool IsWebClientValue() { if (_valuePointer == null) { return(false); } return(DesignUtil.IsWebClientObject(_valuePointer)); }
public override bool ExecuteMenuCommand(LimnorProject project, IClass holder, XmlNode node, MultiPanes pane, IMethod scopeMethod, IActionsHolder actsHolder) { IMethodPointer mi = DesignUtil.EditFrequentlyUsedMethodList(project, node, _menuData, pane.Loader.DesignPane, pane.FindForm()); if (mi != null) { return(DesignUtil.OnCreateAction(holder, mi, scopeMethod, actsHolder, pane, node) != null); } return(false); }
public override IAction CreateMethodAction(ILimnorDesignPane designPane, IClass holder, IMethod scopeMethod, IActionsHolder actsHolder) { IMethodPointer mi = DesignUtil.EditFrequentlyUsedMethodList(designPane.Loader.Project, designPane.RootXmlNode, _menuData, designPane, designPane.PaneHolder.FindForm()); if (mi != null) { return(DesignUtil.OnCreateAction(holder, mi, scopeMethod, actsHolder, designPane.PaneHolder, designPane.RootXmlNode)); } return(null); }
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 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); }
static void ThrowIfNotModel <TModel>() { if (!DesignUtil.ClassCache <TModel> .IsModel) { var error = string.Format("Type '{0}' should have '{1}' with '{2}' tag.", typeof(TModel), typeof(ClassDesignAttribute), DesignUtil.ConvertTagToString(DesignTag.Model)); throw new ArgumentException(error); } }
void miChangeIcon_Click(object sender, EventArgs e) { LocalVariable lv = this.ClassPointer as LocalVariable; Image img = DesignUtil.ChangeTypeIcon(lv.ObjectType, IconImage, this.FindForm()); if (img != null) { SetIconImage(img); Refresh(); } }
public void AddProperty(IProperty p) { if (_dataTransfers == null) { _dataTransfers = new Dictionary <IProperty, ParameterValue>(); } foreach (IProperty p0 in _dataTransfers.Keys) { if (p0.IsSameObjectRef(p)) { return; } } if (_rootClass.IsWebPage) { EnumWebActionType at = EnumWebActionType.Unknown; Dictionary <IProperty, ParameterValue> .KeyCollection.Enumerator en = _dataTransfers.Keys.GetEnumerator(); while (en.MoveNext()) { bool isClient = DesignUtil.IsWebClientObject(en.Current); bool isServer = DesignUtil.IsWebServerObject(en.Current); if (isClient && !isServer) { at = EnumWebActionType.Client; break; } else if (!isClient && isServer) { at = EnumWebActionType.Server; break; } } if (at == EnumWebActionType.Server) { if (DesignUtil.IsWebClientObject(p)) { MessageBox.Show(string.Format(CultureInfo.InvariantCulture, "Cannot add a client property [{0}] because there are server properties in the list", p.ExpressionDisplay), "Data transfer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } else if (at == EnumWebActionType.Client) { if (DesignUtil.IsWebServerObject(p)) { MessageBox.Show(string.Format(CultureInfo.InvariantCulture, "Cannot add a server property [{0}] because there are client properties in the list", p.ExpressionDisplay), "Data transfer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } } } _dataTransfers.Add(p, CreateDefaultParameter(p)); }
protected virtual void OnCreateFirstFormDebug() { ClassPointer startForm = null; if (_startClassId != 0) { startForm = ClassPointer.CreateClassPointer(_startClassId, Project); } if (startForm != null) { CodeExpressionStatement cs = new CodeExpressionStatement( new CodeMethodInvokeExpression( new CodeTypeReferenceExpression(typeof(Application)), "Run", new CodePropertyReferenceExpression(new CodeTypeReferenceExpression(startForm.TypeString), DrawingPage.DEFAULTFORM))); mainMethod.Statements.Add(cs); } else if (_startForm != null) { string formName = DesignUtil.CreateUniqueName("form"); mainMethod.Statements.Add(new CodeVariableDeclarationStatement( _startForm.GetTypeName(this.Namespace), formName, new CodeObjectCreateExpression(_startForm.GetTypeName(this.Namespace)) )); // mainMethod.Statements.Add(new CodeExpressionStatement( new CodeMethodInvokeExpression( DebuggerVar, "OnCreateComponent", new CodePrimitiveExpression(_startForm.ObjectKey), new CodeVariableReferenceExpression(formName) ) ) ); // if (!InitializeComponentAdded()) { CodeMethodReferenceExpression mre = new CodeMethodReferenceExpression(); mre.MethodName = "InitializeComponent"; mainMethod.Statements.Add(new CodeExpressionStatement( new CodeMethodInvokeExpression(mre, new CodeExpression[] { }) )); } // CodeExpressionStatement cs = new CodeExpressionStatement( new CodeMethodInvokeExpression( new CodeTypeReferenceExpression(typeof(Application)), "Run", new CodeVariableReferenceExpression(formName))); mainMethod.Statements.Add(cs); } else { throw new DesignerException("StartForm property is not specified in the application class."); } }
public override bool IsSameObjectRef(IObjectIdentity obj) { ConstructorPointer mpp = obj as ConstructorPointer; if (mpp != null) { if (base.IsSameObjectRef(obj)) { return(DesignUtil.IsSameValueTypes(ParameterTypes, mpp.ParameterTypes)); } } return(false); }
private void edit() { if (dataGridView1.CurrentCell != null && dataGridView1.CurrentCell.RowIndex >= 0 && dataGridView1.CurrentCell.RowIndex < _dataTable.Rows.Count) { ILimnorDesignPane pane = _prj.GetTypedData <ILimnorDesignPane>(_method.ClassId); ActionItem ai = _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][0] as ActionItem; List <IAction> actList = DesignUtil.SelectAction(pane.Loader, ai.Action, null, false, _method, _method.CurrentActionsHolder, this.FindForm()); if (actList != null && actList.Count > 0) { ai = new ActionItem(actList[0]); _dataTable.Rows[dataGridView1.CurrentCell.RowIndex][0] = ai; } } }
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) { MethodDataTransfer mdt = context.Instance as MethodDataTransfer; if (mdt == null) { IAction act = context.Instance as IAction; if (act != null) { mdt = act.ActionMethod as MethodDataTransfer; } } if (mdt != null) { FrmObjectExplorer dlg = DesignUtil.GetPropertySelector(null, mdt.Action.ScopeMethod, null); dlg.SetMultipleSelection(true); dlg.ObjectSubType = EnumObjectSelectSubType.Property; if (edSvc.ShowDialog(dlg) == System.Windows.Forms.DialogResult.OK) { if (dlg.SelectedProperties != null) { foreach (IProperty p in dlg.SelectedProperties) { mdt.AddProperty(p); } PropertyGrid pg = null; Type t = edSvc.GetType(); PropertyInfo pif0 = t.GetProperty("OwnerGrid"); if (pif0 != null) { object g = pif0.GetValue(edSvc, null); pg = g as PropertyGrid; } if (pg != null && pg.SelectedGridItem != null) { pg.SelectedGridItem.Expanded = true; } mdt.OnChanged(); return(true); } } } } } return(string.Empty); }
public static void CreatePhpScript(IProperty SetProperty, string v, StringCollection sb, StringCollection parameters) { if (DesignUtil.IsSessionVariable(SetProperty)) { string code = string.Format(CultureInfo.InvariantCulture, "$this->WebAppPhp->SetSessionVariable('{0}',{1});\r\n", SetProperty.Name, v); sb.Add(code); } else { string left = SetProperty.GetPhpScriptReferenceCode(sb); string code = string.Format(CultureInfo.InvariantCulture, "{0}={1};\r\n", left, v); sb.Add(code); } }