Ejemplo n.º 1
0
        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);
        }