Ejemplo n.º 1
0
 public void UpdateControllerMouseChange()
 {
     for(int i = 0; i < 20; i++)
     {
         if(Input.GetKeyDown("joystick 1 button " + i))
         {
             peripheralType = PeripheralType.Controller;
             //Debug.Log("Mando");
             return;
         }
     }
     if (/*Input.GetAxis("Right Joystick X") > 0.01f || Input.GetAxis("Right Joystick X") < -0.01f  || Input.GetAxis("Right Joystick Y") > 0.01f || Input.GetAxis("Right Joystick Y") < -0.1f ||*/ Input.GetAxis("MovementControllerX") > 0.01f || Input.GetAxis("MovementControllerX") < -0.01f ||
         Input.GetAxis("MovementControllerY") > 0.01f || Input.GetAxis("MovementControllerY") < -0.01f || Input.GetAxis("RotateController") != 0.0f || Input.GetAxis("Mouse ScrollWheel Controller") > 0.01f || Input.GetAxis("Mouse ScrollWheel Controller") < -0.01f)
     {
         peripheralType = PeripheralType.Controller;
         //Debug.Log("MandoX");
     }
     else if(Input.anyKeyDown)
     {
         peripheralType = PeripheralType.MouseKeyboard;
         //Debug.Log("Teclado");
     }
     else if(Input.GetAxis("Mouse X") != 0.0f || Input.GetAxis("Mouse Y") != 0.0f || Input.mousePosition != lastMousePositon)
     {
         peripheralType = PeripheralType.MouseKeyboard;
         //Debug.Log("Raton");
     }
     lastMousePositon = Input.mousePosition;
 }
Ejemplo n.º 2
0
        public PeripheralType Update(int updatedBy, PeripheralType peripheralType)
        {
            var ePeripheralType = EPeripheralType(peripheralType);

            ePeripheralType.UpdatedDate = DateTime.Now;
            ePeripheralType.UpdatedBy   = updatedBy;
            ePeripheralType             = _iDPeripheralType.Update(EPeripheralType(peripheralType));
            return(PeripheralType(ePeripheralType));
        }
Ejemplo n.º 3
0
        public PeripheralType Create(int createdBy, PeripheralType peripheralType)
        {
            EPeripheralType ePeripheralType = EPeripheralType(peripheralType);

            ePeripheralType.CreatedDate = DateTime.Now;
            ePeripheralType.CreatedBy   = createdBy;
            ePeripheralType             = _iDPeripheralType.Create(ePeripheralType);
            return(PeripheralType(ePeripheralType));
        }
Ejemplo n.º 4
0
        private EPeripheralType EPeripheralType(PeripheralType peripheralType)
        {
            return(new EPeripheralType
            {
                CreatedDate = peripheralType.CreatedDate,
                UpdatedDate = peripheralType.UpdatedDate,

                CreatedBy = peripheralType.CreatedBy,
                PeripheralTypeId = peripheralType.PeripheralTypeId,
                UpdatedBy = peripheralType.UpdatedBy,

                Color = peripheralType.Color.Trim(new Char[] { '#' }),
                Name = peripheralType.Name
            });
        }
Ejemplo n.º 5
0
        public string AddPeripheral(int computerId, int id, string peripheralType, string manufacturer, string model, decimal price, double overallPerformance, string connectionType)
        {
            var type = new PeripheralType();

            var computer = computers.FirstOrDefault(c => c.Id == computerId);

            if (computer == null)
            {
                throw new ArgumentException(ExceptionMessages.NotExistingComputerId);
            }

            if (peripherals.Select(c => c.Id).Contains(id))
            {
                throw new ArgumentException(ExceptionMessages.ExistingPeripheralId);
            }

            IPeripheral peripheral = null;

            if (!Enum.TryParse(peripheralType, out type))
            {
                throw new ArgumentException(ExceptionMessages.InvalidPeripheralType);
            }
            else if (type == PeripheralType.Headset)
            {
                peripheral = new Headset(id, manufacturer, model, price, overallPerformance, connectionType);
            }
            else if (type == PeripheralType.Keyboard)
            {
                peripheral = new Keyboard(id, manufacturer, model, price, overallPerformance, connectionType);
            }
            else if (type == PeripheralType.Monitor)
            {
                peripheral = new Monitor(id, manufacturer, model, price, overallPerformance, connectionType);
            }
            else if (type == PeripheralType.Mouse)
            {
                peripheral = new Mouse(id, manufacturer, model, price, overallPerformance, connectionType);
            }

            peripherals.Add(peripheral);
            computer.AddPeripheral(peripheral);

            return(string.Format(SuccessMessages.AddedPeripheral, peripheralType, id, computerId));
        }
Ejemplo n.º 6
0
        public string AddPeripheral(int computerId, int id, string peripheralType,
                                    string manufacturer, string model, decimal price, double overallPerformance, string connectionType)
        {
            PeripheralType pType      = new PeripheralType();
            IPeripheral    peripheral = null;

            if (DoesComputerExist(computerId))
            {
                throw new ArgumentException(COMPUTER_DOESNT_EXIST);
            }
            else if (computers.Where(x => x.Id == computerId).Any(x => x.Peripherals.Any(x => x.Id == id)))
            {
                throw new ArgumentException("Peripheral with this id already exists.");
            }
            else if (!Enum.TryParse <PeripheralType>(peripheralType, out pType))
            {
                throw new ArgumentException("Peripheral type is invalid.");
            }
            else if (pType == PeripheralType.Headset)
            {
                peripheral = new Headset(id, manufacturer, model, price, overallPerformance, connectionType);
            }
            else if (pType == PeripheralType.Keyboard)
            {
                peripheral = new Keyboard(id, manufacturer, model, price, overallPerformance, connectionType);
            }
            else if (pType == PeripheralType.Monitor)
            {
                peripheral = new Monitor(id, manufacturer, model, price, overallPerformance, connectionType);
            }
            else if (pType == PeripheralType.Mouse)
            {
                peripheral = new Mouse(id, manufacturer, model, price, overallPerformance, connectionType);
            }

            peripherals.Add(peripheral);
            computers.Where(i => i.Id == computerId).FirstOrDefault().AddPeripheral(peripheral);

            return($"Peripheral {peripheral.GetType().Name} with id { peripheral.Id} added successfully in computer with id {computerId}.");
        }
Ejemplo n.º 7
0
        public ActionResult Update(PeripheralType peripheralType)
        {
            var createdPeripheralType = _iFPeripheralType.Update(UserId, peripheralType);

            return(RedirectToAction("Index"));
        }
        private static IPeripheral CreatePeripheral(int id, string manufacturer, string model, decimal price,
                                                    double overallPerformance, string connectionType, PeripheralType currentPeripheralType)
        {
            IPeripheral peripheral = currentPeripheralType switch
            {
                PeripheralType.Headset => new Headset(id, manufacturer, model, price, overallPerformance,
                                                      connectionType),
                PeripheralType.Keyboard => new Keyboard(id, manufacturer, model, price, overallPerformance,
                                                        connectionType),
                PeripheralType.Monitor => new Monitor(id, manufacturer, model, price, overallPerformance,
                                                      connectionType),
                PeripheralType.Mouse => new Mouse(id, manufacturer, model, price, overallPerformance, connectionType),
            };

            return(peripheral);
        }