protected override PropertyDescriptor OnProcessProperty(PropertyDescriptor p) { if (string.CompareOrdinal(p.Name, "OutputType") == 0) { ISingleAction av = this.ActionObject as ISingleAction; if (av != null && av.ActionData != null && av.ActionData.ActionMethod != null) { GetterClass gc = av.ActionData.ActionMethod as GetterClass; if (gc != null) { PropertyDescriptor p0 = new ReadOnlyPropertyDesc(p); return(p0); } else { SetterClass sc = av.ActionData.ActionMethod as SetterClass; if (sc != null) { PropertyDescriptor p0 = new ReadOnlyPropertyDesc(p); return(p0); } } } } return(p); }
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 ResetDisplay() { ISingleAction av = ActionObject as ISingleAction; if (av.ActionData != null) { av.ActionData.ResetDisplay(); this.Refresh(); } }
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; } } }
protected virtual void OnPaintAction(PaintEventArgs e) { int nLeft = 0; //draw action ISingleAction av = this.ActionObject as ISingleAction; Bitmap img = ActionImage; if (img != null) { switch (av.IconLayout) { case EnumIconDrawType.Fill: if (this.Size.Width > 4 && this.Size.Height > 4) { e.Graphics.DrawImage(img, 1, 1, this.Size.Width - 4, this.Size.Height - 4); nLeft = 1; } break; case EnumIconDrawType.Left: e.Graphics.DrawImage(img, 1, (this.Size.Height - img.Height) / 2, img.Size.Width, img.Size.Height); nLeft = 1 + img.Width; break; case EnumIconDrawType.Center: e.Graphics.DrawImage(img, (this.Size.Width - img.Width) / 2, (this.Size.Height - img.Height) / 2, img.Size.Width, img.Size.Height); nLeft = 1; break; } } if (av.ShowText) { SizeF sz = e.Graphics.MeasureString(this.ActionDisplay, TextFont); float x = (Size.Width - sz.Width - nLeft) / 2 + nLeft; float y = (Size.Height - sz.Height) / 2; if (x < 0) { x = 0; } if (y < 0) { y = 0; } e.Graphics.DrawString(this.ActionDisplay, TextFont, TextBrush, x, y); } }
public void OnLocalVariableRename(LocalVariable lv) { ISingleAction av = ActionObject as ISingleAction; if (av.ActionData != null) { if (av.ActionData.ReturnReceiver != null) { if (lv.IsSameObjectRef(av.ActionData.ReturnReceiver)) { LocalVariable lv2 = av.ActionData.ReturnReceiver as LocalVariable; lv2.Name = lv.Name; av.ActionData.ResetDisplay(); this.Refresh(); } } } }
protected override void OnReplaceAction() { MethodDiagramViewer mv = this.Parent as MethodDiagramViewer; if (mv != null) { ISingleAction av = this.ActionObject as ISingleAction; List <IAction> actReplaceList = DesignUtil.SelectAction(mv.DesignerHolder.Loader, av.ActionData, null, false, mv.DesignerHolder.Method, mv.ActionsHolder, this.FindForm()); if (actReplaceList != null && actReplaceList.Count > 0) { av.ActionId = new TaskID(actReplaceList[0].WholeActionId); av.ActionData = actReplaceList[0]; IMethodDiagram p = this.Parent as IMethodDiagram; if (p != null) { p.OnActionNameChanged(av.ActionData.ActionName, av.ActionId.WholeTaskId); } } } }
public ServerLoadUpdater( TimeSpan updateInterval, ServerManager serverManager, IScheduler scheduler, IEventAggregator eventAggregator, IMainWindowState mainWindowState, IApiServers apiServers, ISingleActionFactory singleActionFactory, ILastServerLoadTimeProvider lastServerLoadTimeProvider) { _lastServerLoadTimeProvider = lastServerLoadTimeProvider; eventAggregator.Subscribe(this); _updateInterval = updateInterval; _mainWindowState = mainWindowState; _serverManager = serverManager; _apiServers = apiServers; _timer = scheduler.Timer(); _timer.Interval = updateInterval.RandomizedWithDeviation(0.2); _timer.Tick += TimerOnTick; _updateAction = singleActionFactory.GetSingleAction(UpdateLoads); }
protected override void OnEditAction() { MethodDiagramViewer mv = this.DiagramViewer; if (mv != null) { ILimnorDesignerLoader loader = mv.DesignerHolder.Designer as ILimnorDesignerLoader; ISingleAction av = this.ActionObject as ISingleAction; string name = av.ActionData.ActionName; FormProgress.HideProgress(); if (av.ActionData.Edit(loader.Writer, mv.Method, this.FindForm(), false)) { if (name != av.ActionData.ActionName) { IMethodDiagram p = this.Parent as IMethodDiagram; if (p != null) { p.OnActionNameChanged(av.ActionData.ActionName, av.ActionId.WholeTaskId); } } mv.Changed = true; } } }
/// <summary> /// finish execute an action /// </summary> /// <param name="objectKey"></param> /// <param name="methodWholeId"></param> /// <param name="branchId"></param> /// <param name="executer"></param> public void AfterExecuteAction(string objectKey, UInt64 methodWholeId, UInt32 branchId, object executer) { if (_ComponentDebugger.Stopping) { return; } int threadId = System.Threading.Thread.CurrentThread.ManagedThreadId; _ComponentDebugger.DecrementStackLevel(threadId); //check if it is at a break point MethodClass mc = _ComponentDebugger.GetMethod(methodWholeId); if (mc != null) { IActionGroup g = mc; ActionBranch branch = mc.GetBranchByIdInGroup(branchId, ref g); if (branch != null) { IActionGroup g0 = branch as IActionGroup; if (g0 != null) { //finished calling a group of actions MethodDesignerHolder h = _ComponentDebugger.GetViewer(threadId, g0.GroupId); if (h != null) { h.ActionGroup.GroupFinished = true; _ComponentDebugger.UpdateViewersBackColor(); } } else { ISingleAction sa = branch as ISingleAction; if (sa != null) { CustomMethodPointer ac = sa.ActionData.ActionMethod as CustomMethodPointer; if (ac != null) { //finished calling a custom action MethodDesignerHolder h = _ComponentDebugger.GetViewer(threadId, ac.MethodDef.MethodID); if (h != null) { h.ActionGroup.GroupFinished = true; _ComponentDebugger.UpdateViewersBackColor(); } } } } EnumRunStatus status = _ComponentDebugger.GetRunStatus(threadId); bool b = (status == EnumRunStatus.Pause || status == EnumRunStatus.StepInto); if (!b) { if (status == EnumRunStatus.StepOver && _ComponentDebugger.ReachStepOver(threadId)) { b = true; } if (!b) { if (status == EnumRunStatus.StepOut && _ComponentDebugger.ReachStepOut(threadId)) { b = true; } } } if (b || branch.BreakAfterExecute) { _ComponentDebugger.SetSelectedObject(executer); _ComponentDebugger.SetAtBreak(threadId, true); _debugUI.ShowBreakPoint(_ComponentDebugger); branch.AtBreak = EnumActionBreakStatus.After; _ComponentDebugger.ShowBreakPointInMethod(threadId, mc, g, branch); waitForBreakPoint(threadId); branch.AtBreak = EnumActionBreakStatus.None; _ComponentDebugger.ShowBreakPointInMethod(threadId, mc, g, branch); } else { branch.AtBreak = EnumActionBreakStatus.None; _ComponentDebugger.ClearBreakPointInMethod(threadId, mc, g, branch); } } } }
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; }