private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node != null) { mi = e.Node.Tag as MethodInfo; if (mi != null) { this.Text = "Method:" + e.Node.Text; ParameterInfo[] pis = mi.GetParameters(); parameters = new PropertyTable(); for (int i = 0; i < pis.Length; i++) { try { object v = VPLUtil.GetDefaultValue(pis[i].ParameterType); Type t = pis[i].ParameterType; if (t.Equals(typeof(object))) { t = typeof(string); } parameters.Properties.Add(new PropertySpec(pis[i].Name, t, "", "", v)); parameters[pis[i].Name] = v; } catch (Exception err) { MathNode.Log(this, err); } } propertyGrid1.SelectedObject = parameters; } } }
private void btTest_Click(object sender, EventArgs e) { btTest.Enabled = false; try { _testData = null; //generate the result result = root.Export(); // //check if compilation is needed IObjectTypeUnitTester uc = (IObjectTypeUnitTester)MathNode.GetService(typeof(IObjectTypeUnitTester)); if (uc != null) { _testData = uc.UseMemberTest(this); } if (_testData == null) { CompileResult compiled = result.CreateMethodCompilerUnit("TestMathExpression", "Test", "TestMathExpGroup"); // thTest = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(test)); thTest.SetApartmentState(System.Threading.ApartmentState.STA); _testData = new TestData(compiled); thTest.Start(_testData); } // timer1.Enabled = true; } catch (Exception err) { MathNode.Log(this.FindForm(), err); } }
/// <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 IAction GetActionById(UInt32 id, List <UInt32> usedBranches) { if (usedBranches.Contains(this.BranchId)) { return(null); } usedBranches.Add(this.BranchId); if (_actionList != null) { for (int k = 0; k < _actionList.Count; k++) { if (_actionList[k].ActionId == id) { if (_actionList[k].Action != null) { return(_actionList[k].Action); } #if DEBUG MathNode.Log(null, "Action {0} not loaded for Action list branch", id); #endif } } } return(null); }
public override bool Save() { ActionGroupDesignerHolder holder = DesignerHolder as ActionGroupDesignerHolder; try { holder.Actions.Name = this.Site.Name; holder.Actions.Description = this.Description; // holder.Actions.ActionList = ExportActions(); // /// Form f = this.FindForm(); if (f != null) { holder.Actions.EditorBounds = f.Bounds; } return(true); } catch (Exception e) { MathNode.Log(this.FindForm(), e); return(false); } }
private void miEditActions_Click(object sender, EventArgs e) { MethodDiagramViewer mv = this.DiagramViewer; if (mv != null) { AB_ForLoop loop = this.ActionObject as AB_ForLoop; MethodDesignerHolder holder = mv.DesignerHolder; MethodClass mc = loop.Method; DlgMethod dlg = mc.CreateSubMethodEditor(typeof(ActionGroupDesignerHolder), this.Parent.RectangleToScreen(this.Bounds), mv, loop.BranchId); try { mc.SubMethod.Push(loop); dlg.LoadActions(loop); if (dlg.ShowDialog(this.FindForm()) == DialogResult.OK) { UpdateAction(dlg.ActionResult); mv.Changed = true; } } catch (Exception err) { MathNode.Log(this.FindForm(), err); } finally { mc.SubMethod.Pop(); mc.CurrentSubEditor = null; } } }
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value) { if (context != null && context.Instance != null && provider != null) { IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (service != null) { IWithProject mc = context.Instance as IWithProject; if (mc == null) { MathNode.Log(new DesignerException("{0} does not implement IWithProject", context.Instance.GetType())); } else { if (mc.Project == null) { MathNode.Log(new DesignerException("Project not set for {0} [{1}]", mc, mc.GetType())); } else { Rectangle rc = new Rectangle(System.Windows.Forms.Cursor.Position, new Size(20, 60)); IMathExpression im = value as IMathExpression; if (im == null) { im = new MathNodeRoot(); } } } } } return(value); }
private void btTest_Click(object sender, EventArgs e) { btTest.Enabled = false; try { //check if compilation is needed _testData = null; IObjectTypeUnitTester uc = (IObjectTypeUnitTester)MathNode.GetService(typeof(IObjectTypeUnitTester)); if (uc != null) { _testData = uc.UseMemberTest(this); } if (_testData == null) { // CompileResult result = mathExpCtrl1.CreateMethodCompilerUnit("TestMathExpression", "Test", "TestMathExpression"); // thTest = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(test)); thTest.SetApartmentState(System.Threading.ApartmentState.STA); _testData = new TestData(result); //"Test", "TestMathExpression", variables, pointerList, code, imports); thTest.Start(_testData); } timer1.Enabled = true; } catch (Exception err) { MathNode.Log(this.FindForm(), err); } // timer1.Enabled = true; }
protected override void PerformLoad(IDesignerSerializationManager serializationManager) { ComponentFactory o = new ComponentFactory(); o.DesignerLoaderHost = this.LoaderHost; _reader.ObjectList.ClearItems(); _reader.ObjectList.DocumentMoniker = _file; _rootComponent = (IComponent)_reader.ReadRootObject(o, _reader.ObjectList.XmlData); if (_reader.Errors != null && _reader.Errors.Count > 0) { MathNode.Log(_reader.Errors); _reader.ResetErrors(); } if (_rootComponent != null) { uint id = _reader.ObjectList.GetObjectID(_rootComponent); if (id == 0) { id = _reader.ObjectList.AddNewObject(_rootComponent); if (id != 1) { throw new Exception("Object ID 1 must be for the root object"); } XmlUtil.SetAttribute(_reader.ObjectList.XmlData, XmlTags.XMLATT_ComponentID, id); } this.LoaderHost.EndLoad(_rootComponent.Site.Name, true, null); } }
private void btCalculate_Click(object sender, EventArgs e) { if (mi != null) { try { object[] ps = new object[parameters.Properties.Count]; for (int i = 0; i < ps.Length; i++) { ps[i] = parameters[parameters.Properties[i].Name]; } object ret = mi.Invoke(obj, ps); if (mi.ReturnType == null || typeof(void).Equals(mi.ReturnType)) { txtResult.Text = ""; } else { if (ret == null) { txtResult.Text = "null"; } else { txtResult.Text = ret.ToString(); } } } catch (Exception err) { MathNode.Log(this, err); } } }
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); }
protected override void OnEditAction() { MethodDiagramViewer mv = this.DiagramViewer; if (mv != null) { AB_Squential av = this.ActionObject as AB_Squential; MethodDesignerHolder holder = mv.DesignerHolder; MethodClass mc = av.Method; DlgMethod dlg = mc.CreateSubMethodEditor(typeof(ActionGroupDesignerHolder), this.Parent.RectangleToScreen(this.Bounds), mv, av.BranchId); SubMethodInfoPointer smi = null; try { ISingleAction sa = av as ISingleAction; if (sa != null) { smi = sa.ActionData.ActionMethod as SubMethodInfoPointer; if (smi != null) { AB_SubMethodAction smb = this.ActionObject as AB_SubMethodAction; smi.CreateParameters(smb); av.Method.SubMethod.Push(smi); } } // dlg.LoadActions(av); if (_caller == null) { _caller = this.FindForm(); } if (dlg.ShowDialog(_caller) == DialogResult.OK) { AB_SubMethodAction abs = this.ActionObject as AB_SubMethodAction; abs.CopyActionsFrom(dlg.ActionResult, dlg.ComponentIcons); mv.Changed = true; } } catch (Exception err) { MathNode.Log(this.FindForm(), err); } finally { if (smi != null) { if (av.Method.SubMethod.Count > 0) { av.Method.SubMethod.Pop(); } } mc.CurrentSubEditor = null; } } }
private void btCopy_Click(object sender, EventArgs e) { try { copyToClipboard(); } catch (Exception err) { MathNode.Log(this.FindForm(), err); } }
private void btCut_Click(object sender, EventArgs e) { try { cutToClipboard(); root.Changed = true; } catch (Exception err) { MathNode.Log(this.FindForm(), err); } }
public static VirtualWebDir CreateWebSite(string webSiteName, LimnorProject project, Form caller) { try { return(LimnorWebApp.CreateWebSite(project, webSiteName, caller)); } catch (Exception err) { MathNode.Log(err, "Cannot create website [{0}] on {1}", webSiteName, project.WebPhysicalFolder(caller)); } return(null); }
private void btRedo_Click(object sender, EventArgs e) { try { Redo(); root.Changed = true; } catch (Exception err) { MathNode.Log(this.FindForm(), err); } }
public void OnFinishEdit(UInt32 actionBranchId, ILimnorDesignerLoader loader) { try { ILimnorDesignPane dp = loader.DesignPane; if (dp == null) { throw new DesignerException("ILimnorDesignPane not found for class {0}", loader.GetRootId()); } IEvent ep = _event; EventAction ea = null; //event-actions mapping ClassPointer a = loader.GetRootId(); if (a != null) { List <EventAction> lst = a.EventHandlers; if (lst != null) { foreach (EventAction e in lst) { if (e.GetAssignActionId() == actionBranchId && e.Event.IsSameObjectRef(ep)) { ea = e; break; } } } } if (ea == null) { ea = new EventAction(); ea.Event = ep; if (actionBranchId != 0) { ea.SetAssignActionId(actionBranchId); } } _handlerOwner = ea; ea.AddAction(this); a.SaveEventHandler(ea); dp.OnNotifyChanges(); dp.OnAssignAction(ea); } catch (Exception err) { MathNode.Log(TraceLogClass.MainForm, err); } finally { this.ExitEditor(); } }
public bool LoadObject(IDynamicProperties obj) { try { obj.SetPropertyGrid(propertyGrid1); propertyGrid1.SelectedObject = obj; return(true); } catch (Exception e) { MathNode.Log(this, e); } return(false); }
protected override void OnBeforeExpand(TreeViewCancelEventArgs e) { try { base.OnBeforeExpand(e); TreeNodeObject tne = e.Node as TreeNodeObject; if (tne != null) { ForceLoadNextLevel(tne); } } catch (Exception err) { MathNode.Log(this.FindForm(), err); } }
public void LoadUsedTypes(LimnorProject project, UInt32 scopeMethodId) { _project = project; _scopeMethodId = scopeMethodId; StringCollection sc = new StringCollection(); _types = _project.GetToolboxItems(sc); if (sc.Count > 0) { MathNode.Log(sc); } foreach (Type t in _types) { tvUsed.Nodes.Add(new TreeNodeClassType(tvUsed, t, scopeMethodId)); } }
public override bool Save() { try { if (!ReadOnly) { _group.ActionList = ExportActions(); } return(true); } catch (Exception e) { MathNode.Log(this.FindForm(), e); return(false); } }
public override bool Edit(UInt32 actionBranchId, Rectangle rcStart, ILimnorDesignerLoader loader, Form caller) { if (Owner == null) { Owner = loader.GetRootId(); } 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 = this.CreateMethodEditor(rcStart); dlg.LoadMethod(this, EnumParameterEditType.ReadOnly); if (dlg.EditSubAction(caller)) { IsNewMethod = false; loader.GetRootId().SaveAction(this, loader.Writer); loader.NotifyChanges(); return(true); } } catch (Exception err) { MathNode.Log(caller, err); } finally { ExitEditor(); VPLUtil.CurrentRunContext = _origiContext; } return(false); }
public void SetEventLink(IEvent e) { IEventPointer ep = e as IEventPointer; if (ep != null) { CompilerErrorCollection errors = DynamicLink.LinkEvent(ep, taskExecuter); if (errors != null && errors.Count > 0) { StringCollection sc = new StringCollection(); for (int i = 0; i < errors.Count; i++) { sc.Add(errors[i].ErrorText); } MathNode.Log(sc); } } }
private void timer1_Tick(object sender, EventArgs e) { timer1.Enabled = false; tvGac.LoadGac(); // StringCollection sc = new StringCollection(); List <Assembly> refs = _project.GetReferences(sc); if (sc.Count > 0) { MathNode.Log(sc); } foreach (Assembly a in refs) { tvGac.Nodes.Add(new TreeNodeAssembly(a)); } //add an empty node to make sure all nodes are visible tvGac.Nodes.Add(new TreeNodeDummy()); }
public void DeleteSelectedComponents() { try { bool bSaved = false; ISelectionService ss = (ISelectionService)dsf.GetService(typeof(ISelectionService)); if (ss != null) { ICollection cc = ss.GetSelectedComponents(); if (cc != null) { IDesignerHost host = (IDesignerHost)dsf.GetService(typeof(IDesignerHost)); if (host != null) { CreateUndoTransaction("deleteSelectedComponent"); foreach (object v in cc) { if (v is System.ComponentModel.IComponent) { if (v != host.RootComponent) { if (!bSaved) { bSaved = true; bLoading = true; bLoading = false; } host.DestroyComponent((System.ComponentModel.IComponent)v); } } } root.Changed = true; CommitUndoTransaction("deleteSelectedComponent"); } } } } catch (Exception err) { MathNode.Log(this.FindForm(), err); RollbackUndoTransaction("deleteSelectedComponent"); } }
/// <summary> /// edit this action /// </summary> /// <param name="exp"></param> private void showEditor(IMathExpression exp) { try { Rectangle rc = this.Parent.RectangleToScreen(this.Bounds); IMathEditor dlg = exp.CreateEditor(rc); IMathDesigner md = this.Parent as IMathDesigner; if (md.TestDisabled) { dlg.DisableTest(); } if (((Form)dlg).ShowDialog(this.FindForm()) == DialogResult.OK) { setChanged(); } } catch (Exception err) { MathNode.Log(this.FindForm(), err); } }
private void loadNextLevel(TreeNodeObject tne) { if (!tne.NextLevelLoaded) { this.Cursor = System.Windows.Forms.Cursors.WaitCursor; lblInfo.Location = new System.Drawing.Point( (this.Width - lblInfo.Width) / 2, (this.Height - lblInfo.Height) / 2); lblInfo.Visible = true; lblInfo.Refresh(); tne.NextLevelLoaded = true; try { List <TreeNodeLoader> loaders = new List <TreeNodeLoader>(); for (int i = 0; i < tne.Nodes.Count; i++) { TreeNodeLoader loader = tne.Nodes[i] as TreeNodeLoader; if (loader != null) { loaders.Add(loader); } } foreach (TreeNodeLoader l in loaders) { TreeNodeObject p = l.Parent as TreeNodeObject; l.Remove(); if (p != null) { l.LoadNextLevel(p); } } } catch (Exception err) { MathNode.Log(this.FindForm(), err); } lblInfo.Visible = false; this.Cursor = System.Windows.Forms.Cursors.Default; } }
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 void OnWebPageLoaded(StringCollection sc) { if (!string.IsNullOrEmpty(_filepath)) { if (File.Exists(_filepath)) { try { Image img = Image.FromFile(_filepath); if (img != null) { sc.Add("\r\n"); sc.Add(string.Format(CultureInfo.InvariantCulture, "JsonDataBinding.setButtonImage(document.getElementById('{0}'),'{1}/{2}',{3}, {4});\r\n", CodeName, WebResourceFile.WEBFOLDER_Images, Path.GetFileName(_filepath), img.Width, img.Height)); } } catch (Exception err) { MathNode.Log(this.FindForm(), err); } } } }
protected virtual void loadEventAction() { if (_eventAction == null) { //it is public because event-handler does not belong to the scope method of this action branch. XmlNode node = _class.XmlData.SelectSingleNode(string.Format(CultureInfo.InvariantCulture, "{0}/{1}[@{2}='{3}']", XmlTags.XML_HANDLERLISTS, XmlTags.XML_HANDLER, XmlTags.XMLATT_ActionID, this.ActionId)); if (node != null) { Guid g = Guid.NewGuid(); XmlObjectReader xr = _class.ObjectList.Reader; xr.ResetErrors(); xr.ClearDelayedInitializers(g); _eventAction = (EventAction)xr.ReadObject(node, null); xr.OnDelayedInitializeObjects(g); if (xr.Errors != null && xr.Errors.Count > 0) { MathNode.Log(xr.Errors); } } } }