private async Task <bool> ShouldLightBeSwitchedOn()
        {
            var laptopEthernet = await connector.LoadEntityFromStates <Sensor>(Sensor.Name.LaptopEthernet.GetEntityId());

            var businessLaptop = await connector.LoadEntityFromStates <Sensor>(Sensor.Name.BusinessLaptopWifi.GetEntityId());

            var computer = await connector.LoadEntityFromStates <Sensor>(Sensor.Name.DesktopComputer.GetEntityId());

            var sunlight = await connector.LoadEntityFromStates <Sensor>(Sensor.Name.Sunlight.GetEntityId());

            var minimumLightForLight = await InputNumber.LoadFromEntityId(connector, InputNumber.Name.MinimumLightForLight);

            if (laptopEthernet.State == "on" || businessLaptop.State == "on" || computer.State == "on")
            {
                if (!int.TryParse(sunlight.State, out var result))
                {
                    return(false);
                }

                var minimumSunState = minimumLightForLight.Value;
                if (dateTimeHelper.Now.TimeOfDay > new TimeSpan(12, 0, 0))
                {
                    minimumSunState = minimumLightForLight.Value - 5;
                }

                return(result <= minimumSunState);
            }

            return(false);
        }
Ejemplo n.º 2
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_canUpdate)
     {
         int id = comboBox1.SelectedIndex;
         if (id >= 0)
         {
             comboBox1.SelectedIndex = -1;
             if (chooseTable != null && chooseTable.Table.TableStatus == true)
             {
                 InputNumber form = new InputNumber();
                 //chooseTable.ListFood.Add(listFood[id]);
                 int num = 1;
                 if (form.ShowDialog(this) == DialogResult.OK)
                 {
                     num = form.getNum();
                 }
                 chooseTable.addFood(listFood[id], num);
                 updateListChoose();
             }
             else
             {
                 MessageBox.Show("Chưa chọn hoặc bàn còn trống!");
             }
         }
     }
     else
     {
         _canUpdate = true;
     }
 }
Ejemplo n.º 3
0
Archivo: Slot.cs Proyecto: ImGMin/team2
    void Start()


    {
        theItemEffectDatabase = FindObjectOfType <ItemEffectDatabase>();
        baseRect       = transform.parent.GetComponent <RectTransform>().rect;
        theInputNumber = FindObjectOfType <InputNumber>();
    }
 private static string AddInputNumberToOutput(InputNumber inputNumber)
 {
     if (!inputNumber.Number.Contains("."))
     {
         return(string.Format("{0}{1}", inputNumber.Number, ".00"));
     }
     return(inputNumber.Number);
 }
Ejemplo n.º 5
0
        public void Save(XmlDocument xml, XmlNode parent)
        {
            var node = parent.AppendChild(xml.CreateElement("Input"));

            node.AppendChild(xml.CreateElement("VisibleName")).InnerText     = VisibleName;
            node.AppendChild(xml.CreateElement("Key")).InnerText             = Key.ToString();
            node.AppendChild(xml.CreateElement("InputNumber")).InnerText     = InputNumber.ToString();
            node.AppendChild(xml.CreateElement("ConnectedOutput")).InnerText = ConnectedOutput;
        }
Ejemplo n.º 6
0
        public void InputNumberIntegerTypeTestPass()
        {
            var input = new StringReader("15216");

            Console.SetIn(input);

            var userInput = InputNumber.InputValidNumber();

            Assert.IsInstanceOfType(userInput, typeof(Int32));
        }
Ejemplo n.º 7
0
        public void IsNumberMultipleOf5Test() //S3.1.4.2: Test if number is multiple of 5
        {
            InputNumber inputNumber = new InputNumber()
            {
                Number = 10
            };

            bool isNumberMultipleOf5 = numericCalculation.IsNumberMultipleOf(inputNumber.Number, 5);

            Assert.IsTrue(isNumberMultipleOf5);
        }
Ejemplo n.º 8
0
        public void IsNumberMultipleOf3Test() //S3.1.4.1: Test if number is multiple of 3
        {
            InputNumber inputNumber = new InputNumber()
            {
                Number = 9
            };

            bool isNumberMultipleOf3 = numericCalculation.IsNumberMultipleOf(inputNumber.Number, 3);

            Assert.IsTrue(isNumberMultipleOf3);
        }
Ejemplo n.º 9
0
        public void IsNumberEvenTest() //S3.1.3: Test if number is even
        {
            InputNumber inputNumber = new InputNumber()
            {
                Number = 2
            };

            bool isNumberEven = numericCalculation.IsNumberEven(inputNumber.Number);

            Assert.IsTrue(isNumberEven);
        }
Ejemplo n.º 10
0
        public void IsNumberOddTest() //S3.1.2: Test if number is odd
        {
            InputNumber inputNumber = new InputNumber()
            {
                Number = 1
            };

            bool isNumberEven = numericCalculation.IsNumberEven(inputNumber.Number);

            Assert.IsTrue(!isNumberEven);
        }
Ejemplo n.º 11
0
 static public void ClearInput(Transform t)
 {
     if (t != null)
     {
         InputNumber i = t.GetComponent <InputNumber>();
         if (i != null)
         {
             i.Clear();
         }
     }
 }
Ejemplo n.º 12
0
        public void ShouldNotAcceptAlphaValue()
        {
            var message       = "Message";
            var name          = "Name";
            var consoleRender = Substitute.For <IScreenManager>();
            var inputNumber   = new InputNumber(name, message, consoleRender);
            var aString       = "Answer";

            var valid = inputNumber.IsValidAnswer(aString);

            valid.Should().BeFalse();
        }
Ejemplo n.º 13
0
        public void ShouldAcceptNegativeValue()
        {
            var message          = "Message";
            var name             = "Name";
            var consoleRender    = Substitute.For <IScreenManager>();
            var inputNumber      = new InputNumber(name, message, consoleRender);
            var aNegativeNumeric = "-94";

            var valid = inputNumber.IsValidAnswer(aNegativeNumeric);

            valid.Should().BeTrue();
        }
Ejemplo n.º 14
0
        private static Controller SetupController(string input)
        {
            //Arrange
            var controller = new HomeController();
            //Act
            var inputNumber = new InputNumber {
                Number = input
            };
            var result = controller.Index(inputNumber).WithSuccess("", "") as AlertDecoratorResult;

            return(controller);
        }
Ejemplo n.º 15
0
 public IHttpActionResult GetNumberToWord(string name, decimal number)
 {
     try
     {
         InputNumber word = numToWord.ConvertNumberToWord(name, number);
         return(Ok(word));
     }
     catch (Exception ex)
     {
         return(InternalServerError(ex));
     }
 }
Ejemplo n.º 16
0
        public async Task Activated(CancellationToken cancellationToken = default)
        {
            var lightsToSwitchOn = await Light.LoadFromEntitiesId(connector, Light.Name.Halogen2, Light.Name.Halogen3);

            var allLights = await Light.LoadAllLights(connector, Light.Name.Halogen2, Light.Name.Halogen3);

            var allRgbLights = await RgbLight.LoadAllLights(connector);

            var allSwitches = await Switch.LoadAllLights(connector);

            var stairsLight = await InputNumber.LoadFromEntityId(connector, InputNumber.Name.StairsMinimumBrightness);

            var mediaPlayers = await MediaPlayer.LoadAll(connector);

            var cover = await Cover.LoadFromEntityId(connector, Cover.Name.Salon);

            await lightsToSwitchOn.TurnOnAll();

            await stairsLight.SetValue(30);

            await cover.CloseCover();

            await mediaPlayers.TurnOffAll();

            await allLights.TurnOffAll();

            await allRgbLights.TurnOffAll();

            await allSwitches.TurnOffAll();

            await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken);

            await allRgbLights.TurnOffAll();

            await Task.Delay(TimeSpan.FromMinutes(5), cancellationToken);

            await lightsToSwitchOn.TurnOffAll();

            await stairsLight.SetValue(0);

            await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken);

            await allLights.TurnOffAll();

            await allRgbLights.TurnOffAll();

            await lightsToSwitchOn.TurnOffAll();

            await stairsLight.SetValue(0);
        }
Ejemplo n.º 17
0
        public void Execute()
        {
            ProgressChanged(0, 100);

            if (InputNumber != null)
            {
                Output = InputNumber.IsProbablePrime();
            }
            else
            {
                Output = false;
            }

            ProgressChanged(100, 100);
        }
Ejemplo n.º 18
0
        public void InputNumberIntegerTypeTestFail()
        {
            var output = new StringWriter();

            Console.SetOut(output);

            var input = new StringReader("badInput");

            Console.SetIn(input);

            var expectedOutput = "Enter decryption key as integer number:\r\nWe can not convert input: 'badInput' \nto an integer number, please try again\r\n";

            InputNumber.InputValidNumber();

            Assert.AreEqual(expectedOutput, output.ToString());
        }
        private static void ValidateInput(InputNumber inputNumber)
        {
            if (string.IsNullOrWhiteSpace(inputNumber.Number))
            {
                throw new Exception(Language.InputEmptyError);
            }
            if (inputNumber.Number.Split('.').Length > 2)
            {
                throw new Exception(Language.InvalidInput);
            }

            if (inputNumber.Number.StartsWith("."))
            {
                inputNumber.Number = inputNumber.Number.Insert(0, "0");
            }
        }
Ejemplo n.º 20
0
        public async Task Activated(CancellationToken cancellationToken = default)
        {
            var lightsToSwitchOn = await Light.LoadFromEntitiesId(connector, Light.Name.Halogen2, Light.Name.Halogen3, Light.Name.ExternalLight);

            var allLights = await Light.LoadAllLights(connector, Light.Name.Halogen2, Light.Name.Halogen3);

            var allRgbLights = await RgbLight.LoadAllLights(connector);

            var allSwitches = await Switch.LoadAllLights(connector, Switch.Name.GardenLight);

            var stairsLight = await InputNumber.LoadFromEntityId(connector, InputNumber.Name.StairsMinimumBrightness);

            var mediaPlayers = await MediaPlayer.LoadAll(connector);

            var cover = await Cover.LoadFromEntityId(connector, Cover.Name.Salon);

            var gardenLight = await Switch.LoadFromEntityId(connector, Switch.Name.GardenLight);

            await lightsToSwitchOn.TurnOnAll();

            await gardenLight.TurnOn();

            var sunlight = await connector.LoadEntityFromStates <Sensor>(Sensor.Name.Sunlight.GetEntityId());

            if (int.TryParse(sunlight.State, out var result) && result < 4)
            {
                await cover.CloseCover();
            }

            await mediaPlayers.TurnOffAll();

            await allLights.TurnOffAll();

            await allRgbLights.TurnOffAll();

            await allSwitches.TurnOffAll();

            await stairsLight.SetValue(0);

            await Task.Delay(TimeSpan.FromMinutes(15), cancellationToken);

            await lightsToSwitchOn.TurnOffAll();

            await gardenLight.TurnOff();
        }
        public async Task Activated(CancellationToken cancellationToken = default)
        {
            var mushroom = await RgbLight.LoadFromEntityId(connector, RgbLight.Name.Mushroom);

            var tvleds = await RgbLight.LoadFromEntityId(connector, RgbLight.Name.TvLEDs);

            var stairs = await InputNumber.LoadFromEntityId(connector, InputNumber.Name.StairsMinimumBrightness);

            var lights = await Light.LoadFromEntitiesId(connector, Light.Name.Halogen1);

            await tvleds.TurnOnStandardWhite();

            await lights.TurnOnAll();

            await stairs.SetValueBasedOnTvState();

            await mushroom.TurnOnWithRandomColor();
        }
Ejemplo n.º 22
0
        public void Given19DollarsReturnNineteen()
        {
            //Arrange
            var controller = new HomeController();

            //Act
            var inputNumber = new InputNumber {
                Number = "19"
            };
            var result   = controller.Index(inputNumber) as ViewResult;
            var expected = "NINETEEN DOLLARS";

            //Assert
            if (result != null)
            {
                var actual = result.ViewBag.Output;
            }
        }
Ejemplo n.º 23
0
        public void Given30DollarsReturnThirty()
        {
            //Arrange
            var controller = new HomeController();

            //Act
            var inputNumber = new InputNumber {
                Number = "30"
            };
            var result   = controller.Index(inputNumber) as ViewResult;
            var expected = "THIRTEE";

            //Assert
            if (result != null)
            {
                var actual = result.ViewBag.Output;
            }
        }
Ejemplo n.º 24
0
        public void Given80DollarsReturnEightee()
        {
            //Arrange
            var controller = new HomeController();

            //Act
            var inputNumber = new InputNumber {
                Number = "80"
            };
            var result   = controller.Index(inputNumber) as ViewResult;
            var expected = "EIGHTY DOLLARS";

            //Assert
            if (result != null)
            {
                var actual = result.ViewBag.Output;
            }
        }
Ejemplo n.º 25
0
        public void IsNumberMultipleOf3And5Test() //S3.1.4.3: Test if number is multiple of 3 and 5
        {
            InputNumber inputNumber = new InputNumber()
            {
                Number = 15
            };

            bool isNumberMultipleOf3     = numericCalculation.IsNumberMultipleOf(inputNumber.Number, 3);
            bool isNumberMultipleOf5     = numericCalculation.IsNumberMultipleOf(inputNumber.Number, 5);
            bool isNumberMultipleOf3And5 = false;

            if (isNumberMultipleOf3 && isNumberMultipleOf5)
            {
                isNumberMultipleOf3And5 = true;
            }

            Assert.IsTrue(isNumberMultipleOf3And5);
        }
Ejemplo n.º 26
0
        public void FibonacciSequenceTest() //S3.1.5: Test if Fibonacci function returns a List object with values
        {
            InputNumber inputNumber = new InputNumber()
            {
                Number = 34
            };

            List <int> fibonacciNumbers = numericListGenerator.FibonacciSequence(inputNumber.Number);

            bool hasPassedTest = false;

            if (fibonacciNumbers != null && fibonacciNumbers.Count > 0)
            {
                hasPassedTest = true;
            }

            Assert.IsTrue(hasPassedTest);
        }
Ejemplo n.º 27
0
        //打印优惠券
        private void btnCoupon_Click(object sender, EventArgs e)
        {
            InputNumber inputNumber = new InputNumber("输入账单号", false);

            if (inputNumber.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var act_id = inputNumber.number;
            var act    = db.Account.FirstOrDefault(x => x.id == act_id);

            if (act == null)
            {
                return;
            }

            //if (BathClass.ToBool(act.couponPrinted))
            //{
            //    InformationDlg dlg = new InformationDlg("该账单号已经打印");
            //    dlg.ShowDialog();
            //    return;
            //}

            var act_money = BathClass.get_account_money(act);

            if (db.Coupon.Any(x => x.minAmount != null && act_money >= x.minAmount))
            {
                var coupons = db.Coupon.Where(x => x.minAmount != null && act_money >= x.minAmount);
                var coupon  = coupons.OrderByDescending(x => x.money).FirstOrDefault();

                PrintCoupon.Print_Coupon((byte[])coupon.img.ToArray());

                //act.couponPrinted = true;
                db.SubmitChanges();
            }
            else
            {
                InformationDlg dlg = new InformationDlg("未达到最低赠送消费金额");
                dlg.ShowDialog();
            }
        }
Ejemplo n.º 28
0
        public ActionResult InputNumber()
        {
            var container = new Dictionary <string, BaseControl>();

            var basic = new InputNumber()
            {
                name = "basic",
                min  = 1,
                max  = 10,
            };

            container.Add("basic", basic);

            var disabled = new InputNumber()
            {
                name     = "disabled",
                disabled = true,
            };

            container.Add("disabled", disabled);

            var step = new InputNumber()
            {
                name  = "step",
                step  = 5,
                value = "1",
            };

            container.Add("step", step);

            var precision = new InputNumber()
            {
                name      = "precision",
                step      = 0.1f,
                max       = 10,
                precision = 2,
            };

            return(Json(container, JsonRequestBehavior.AllowGet));
        }
        public override void OnInspectorGUI()
        {
            InputNumber input = target as InputNumber;

            input.Type = (InputNumber.NumberType)EditorGUILayout.EnumPopup("Type", input.Type);
            EditorGUILayout.HelpBox("ScrollValueを0にするとスクロール時の変動が無効化されます", MessageType.Info, true);
            input.IsUseMin = EditorGUILayout.Toggle("IsUseMin", input.IsUseMin);
            if (input.IsUseMin)
            {
                if (input.Type == InputNumber.NumberType.Integer)
                {
                    input.MinInt = EditorGUILayout.IntField("Min", input.MinInt);
                }
                else if (input.Type == InputNumber.NumberType.Float)
                {
                    input.MinFloat = EditorGUILayout.FloatField("Min", input.MinFloat);
                }
            }
            input.IsUseMax = EditorGUILayout.Toggle("IsUseMax", input.IsUseMax);
            if (input.IsUseMax)
            {
                if (input.Type == InputNumber.NumberType.Integer)
                {
                    input.MaxInt = EditorGUILayout.IntField("Max", input.MaxInt);
                }
                else if (input.Type == InputNumber.NumberType.Float)
                {
                    input.MaxFloat = EditorGUILayout.FloatField("Max", input.MaxFloat);
                }
            }
            if (input.Type == InputNumber.NumberType.Integer)
            {
                input.ScrollValueInt = EditorGUILayout.IntField("ScrollValue", input.ScrollValueInt);
            }
            else if (input.Type == InputNumber.NumberType.Float)
            {
                input.ScrollValueFloat = EditorGUILayout.FloatField("ScrollValue", input.ScrollValueFloat);
            }
            EditorUtility.SetDirty(target);
        }
Ejemplo n.º 30
0
 private void listView1_DoubleClick(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count > 0)
     {
         int id = listView1.Items.IndexOf(listView1.SelectedItems[0]);
         if (chooseTable != null && chooseTable.Table.TableStatus == true)
         {
             InputNumber form = new InputNumber();
             //chooseTable.ListFood.Add(listFood[id]);
             int num = 1;
             if (form.ShowDialog(this) == DialogResult.OK)
             {
                 num = form.getNum();
                 chooseTable.addFood(listFoodCategory[id], num);
                 updateListChoose();
             }
         }
         else
         {
             MessageBox.Show("Chưa chọn hoặc bàn còn trống!");
         }
     }
 }