public SwitchBase AddComponent(SwitchBase sourceComponent, PointF pt) { SwitchBase switchBase = Activator.CreateInstance(sourceComponent.GetType()) as SwitchBase; if (sourceComponent is VariableSwitch && switchBase is VariableSwitch) { var variableComponent = switchBase as VariableSwitch; variableComponent.VariableKey = ((VariableSwitch)sourceComponent).VariableKey; } var sourcePrefabSwitch = sourceComponent as PrefabSwitch; if (sourcePrefabSwitch != null && switchBase is PrefabSwitch) { var prefabSwitch = switchBase as PrefabSwitch; prefabSwitch.Prefab = sourcePrefabSwitch.Prefab; } if (switchBase != null) { switchBase.Position = pt; CurrentProject.Add(this, switchBase); return(switchBase); } return(null); }
public void AddComponent(SwitchBase sourceComponent) { SwitchBase switchBase = Activator.CreateInstance(sourceComponent.GetType()) as SwitchBase; PointF pt = RenderingEngine.TranslatePoint(PointToClient(MousePosition)); // this.PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y)); //.Divide(CurrentProject.Zoom, CurrentProject.Zoom).Add(-CurrentProject.Translation.X, -CurrentProject.Translation.Y); if (switchBase != null) { switchBase.Position = pt; RenderingEngine.CurrentProject.Add(RenderingEngine, switchBase); } }