public void DeleteObject(MoveGizmo gizmo) { game.level.EvalExpression(String.Format("del {0}", gizmo.visual.source.name)); game.level.EntityDestroyed(gizmo.visual); game.level.RemoveEntitiesSource(String.Format("{0} = \\w+\\(.*\\)", gizmo.visual.source.name)); }
public void CopyObjectUnderGizmo(MoveGizmo gizmo, double shiftx, double shifty) { visualToBeSelected = null; game.level.OnEntityCreated += new EventHandler<EntityCreatedArgs>(level_OnEntityCreated); if (gizmo.editable is RectangleSurface) { string name = game.level.GenerateUniqueName(); RectangleSurface o = (RectangleSurface)gizmo.editable; string code = String.Format("{0} = Rectangle({1:g}, {2:g}, {3:g}, {4:g})", name, o.Center.X + shiftx, o.Center.Y + shifty, o.Width, o.Height); game.level.EvalExpression(code); game.level.AddEntitiesSource(code); } if (gizmo.editable is CircleSurface) { string name = game.level.GenerateUniqueName(); CircleSurface o = (CircleSurface)gizmo.editable; string code = String.Format("{0} = Circle({1:g}, {2:g}, {3:g})", name, o.Center.X + shiftx, o.Center.Y + shifty, o.Radius); game.level.EvalExpression(code); game.level.AddEntitiesSource(code); } if (gizmo.editable is LineSurface) { string name = game.level.GenerateUniqueName(); LineSurface o = (LineSurface)gizmo.editable; string code = String.Format("{0} = Line({1:g}, {2:g}, {3:g}, {4:g})", name, o.OP1.X + shiftx, o.OP1.Y + shifty, o.OP2.X + shiftx, o.OP2.Y + shifty); game.level.EvalExpression(code); game.level.AddEntitiesSource(code); } game.level.OnEntityCreated -= new EventHandler<EntityCreatedArgs>(level_OnEntityCreated); if (visualToBeSelected != null) { InitMainGizmo(visualToBeSelected); InitAdditionalGizmos(visualToBeSelected); visualToBeSelected = null; } }