private void miSetProperty_Click(object sender, EventArgs e) { MenuItemDataProperty data = (MenuItemDataProperty)(((MenuItem)sender).Tag); MethodDiagramViewer mv = MethodViewer.GetCurrentViewer(); ActionClass act = OnCreateSetPropertyAction(data); if (act != null) { if (!(this.ClassPointer is LocalVariable)) { if (MethodEditContext.IsWebPage) { if (!MethodEditContext.CheckAction(act, this.FindForm())) { return; } } } act.SetScopeMethod(_methodClass); int x = (mv.Width / 4 - 20) / 2; int y = (mv.Height / 4 - 20) / 2; if (x < 30) { x = 30; } if (y < 30) { y = 30; } mv.AddNewAction(act, new Point(x, y)); } }
void miNewInstance_Click(object sender, EventArgs e) { MethodDiagramViewer mv = MethodViewer.GetCurrentViewer(); if (mv != null) { MemberComponentId lv = this.ClassPointer as MemberComponentId; ActionAssignComponent act = new ActionAssignComponent(MethodViewer.Method.RootPointer); act.ActionOwner = lv; act.ActionId = (UInt32)(Guid.NewGuid().GetHashCode()); act.ActionName = MethodViewer.RootClass.CreateNewActionName("Create" + lv.ObjectType.Name); Point p = mv.PointToClient(System.Windows.Forms.Cursor.Position); if (p.X < 0) { p.X = 10; } if (p.Y < 0) { p.Y = 10; } act.ValidateParameterValues(); mv.AddNewAction(act, p); } }