Пример #1
0
        private void Add()
        {
            if (NewName == null || NewName == "")
            {
                NewName = "新建组件";
            }
            if (SelectedTemplate != null)
            {
                switch (ComponentType)
                {
                case DeviceComponentType.Bearing:
                    Component.AddBearingComponent(new BearingComponent()
                    {
                        Name = NewName, Component = SelectedTemplate as BearingClass
                    });
                    break;

                case DeviceComponentType.Belt:
                    Component.AddBeltComponent(new BeltComponent()
                    {
                        Name = NewName, Component = SelectedTemplate as BeltClass
                    });
                    break;

                case DeviceComponentType.Gear:
                    Component.AddGearComponent(new GearComponent()
                    {
                        Name = NewName, Component = SelectedTemplate as GearClass
                    });
                    break;

                case DeviceComponentType.Impeller:
                    Component.AddImpellerComponent(new ImpellerComponent()
                    {
                        Name = NewName, Component = SelectedTemplate as ImpellerClass
                    });
                    break;

                case DeviceComponentType.Motor:
                    Component.AddMotorComponent(new MotorComponent()
                    {
                        Name = NewName, Component = SelectedTemplate as MotorClass
                    });
                    break;
                }
            }
        }