Пример #1
0
 private static void UpdateFrom(this InserterBaseViewModel vm, BaseInserter m)
 {
     vm.Id        = m.Id;
     vm.Position  = new System.Windows.Media.Media3D.Point3D(m.Position.X, m.Position.Y, m.Position.Z);
     vm.Direction = new System.Windows.Media.Media3D.Vector3D(m.Direction.X, m.Direction.Y, m.Direction.Z);
     vm.Color     = m.Color.Convert();
 }
        public static BaseInserter ToModel(this InserterBaseViewModel vm)
        {
            BaseInserter m = null;

            if (vm is InserterViewModel insVm)
            {
                var ins = new Inserter
                {
                    Diameter         = insVm.Diameter,
                    Length           = insVm.Length,
                    LoaderLinkId     = insVm.LoaderLinkId,
                    DischargerLinkId = insVm.DischargerLinkId
                };

                m = ins;
            }
            else if (vm is InjectorViewModel injVm)
            {
                m = new Injector();
            }

            m?.UpdateFrom(vm);

            return(m);
        }
        public static MachineElementViewModel ToViewModel(this BaseInserter m, MachineElementViewModel parent = null)
        {
            InserterBaseViewModel vm = null;

            if (m is Inserter ins)
            {
                var insVm = new InserterViewModel()
                {
                    Length           = ins.Length,
                    Diameter         = ins.Diameter,
                    LoaderLinkId     = ins.LoaderLinkId,
                    DischargerLinkId = ins.DischargerLinkId
                };

                vm = insVm;
            }
            else if (m is Injector inj)
            {
                vm = new InjectorViewModel();
            }

            vm?.UpdateFrom(m);
            if (vm != null && parent != null)
            {
                vm.Parent = parent;
            }

            return(vm);
        }
Пример #4
0
        public static void UpdateFrom(this InserterBaseViewModel vm, BaseInserter m)
        {
            vm.InserterId = m.Id;
            vm.Position   = new System.Windows.Media.Media3D.Point3D(m.Position.X, m.Position.Y, m.Position.Z);
            vm.Direction  = new System.Windows.Media.Media3D.Vector3D(m.Direction.X, m.Direction.Y, m.Direction.Z);
            var material = PhongMaterials.Glass;

            material.DiffuseColor = PhongMaterials.ToColor(m.Color.R / 255.0, m.Color.G / 255.0, m.Color.B / 255.0, 1.0);
            vm.Material           = material;
        }
 private static void UpdateFrom(this BaseInserter m, InserterBaseViewModel vm)
 {
     m.Id       = vm.Id;
     m.Position = new MachineModels.Models.Vector()
     {
         X = vm.Position.X, Y = vm.Position.Y, Z = vm.Position.Z
     };
     m.Direction = new MachineModels.Models.Vector()
     {
         X = vm.Direction.X, Y = vm.Direction.Y, Z = vm.Direction.Z
     };
     m.Color = vm.Color.Convert();
 }
Пример #6
0
        public static InserterBaseViewModel ToViewModel(this BaseInserter m)
        {
            InserterBaseViewModel vm = null;

            if (m is Injector inj)
            {
                vm = new InjectorViewModel();
            }
            else if (m is Inserter ins)
            {
                var insVm = new InserterViewModel
                {
                    Diameter         = ins.Diameter,
                    Length           = ins.Length,
                    LoaderLinkId     = ins.LoaderLinkId,
                    DischargerLinkId = ins.DischargerLinkId
                };
                vm = insVm;
            }

            vm?.UpdateFrom(m);

            return(vm);
        }