Exemplo n.º 1
0
        // IMC calculation.
        /// <summary>
        /// Calculate an IMC for metric height and weight value
        /// </summary>
        /// <param name="height">the user height in cm</param>
        /// <param name="weight"> the user weight in kg</param>
        /// <returns></returns>
        private double calculateMetricIMC(double height, double weight)
        {
            IMCCalculatorManager manager = new IMCCalculatorManager();
            double imc = manager.calculateMetricIMC(height, weight);

            displayIMCinfo(imc);

            String s_imc = Math.Round(imc, 2).ToString("R"); // On prend toutes les valeurs de décimal. Si on ne les veut pas, il suffit de mettre F0 à la place de R.
            int nbDecimal = s_imc.Length - s_imc.IndexOf(",");

            s_imc = "Votre IMC est de " + s_imc + "\n" + manager.infoFromIMC(imc);

            if (imc < 18.5)
            {
                displayGainWeightTextBlockFromIMC(imc, height, weight);
                s_imc = s_imc + "\n" + manager.weightToGainFromIMC(imc, height, weight);
            }
            else if (imc > 25)
            {
                displayLoseWeightTextBlockFromIMC(imc, height, weight);
                s_imc = s_imc + "\n" + manager.weightToLoseFromIMC(imc, height, weight);
            }
            metricIMCResultTextBlock.Text = s_imc;

            return imc;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Manage the Tile. Change its count, backTitle and backContent.
        /// </summary>
        /// <param name="count">The tile count</param>
        /// <param name="backTitle">The tile backTitle</param>
        /// <param name="backContent">The tile backContent</param>
        public void changeBackTile(double imc, double currentHeight, double currentWeight, string backContent)
        {
            IMCCalculatorManager imcManager = new IMCCalculatorManager();
            string backTitle = "";
            string backBackgroundImageName = "";
            if (imc < 18.5)
            {
                backTitle = imcManager.weightToGainFromIMC(imc, currentHeight, currentWeight);
                backBackgroundImageName = "thumbs-down.png";
            }
            if (imc > 25)
            {
                backTitle = imcManager.weightToLoseFromIMC(imc, currentHeight, currentWeight);
                backBackgroundImageName = "thumbs-down.png";
            }
            if (18.5 <= imc && imc <= 25)
            {
                backTitle = "Ne changez rien.";
                backBackgroundImageName = "thumbs-up.png";
            }

            // Application Tile is always the first Tile, even if it is not pinned to Start.
            ShellTile TileToFind = ShellTile.ActiveTiles.First();

            // Application should always be found
            if (TileToFind != null)
            {
                createImageForBackTile();

                // Set the properties to update for the Application Tile.
                // Empty strings for the text values and URIs will result in the property being cleared.
                StandardTileData NewTileData = new StandardTileData
                {
                    // Title = "Mon title",
                    // BackgroundImage = new Uri(textBoxBackgroundImage.Text, UriKind.Relative),
                    Count = Convert.ToInt32(imc),
                    BackTitle = backTitle,
                    BackBackgroundImage = new Uri("isostore:/Shared/ShellContent/tile.jpg", UriKind.Absolute),
                    BackContent = backContent
                };

                // Update the Application Tile
                TileToFind.Update(NewTileData);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Display info on how many kilo to lose in order to be in normal zone.
 /// </summary>
 /// <param name="currentImc">The current imc</param>
 /// <param name="currentHeight">The current height in cm</param>
 /// <param name="currentWeight">The current weight in kg</param>
 private void displayLoseWeightTextBlockFromIMC(double currentImc, double currentHeight, double currentWeight)
 {
     IMCCalculatorManager manager = new IMCCalculatorManager();
     LoseKilosToNormalWeightTextBlock.Text = manager.weightToLoseFromIMC(currentImc, currentHeight, currentWeight);
     LoseKilosToNormalWeightTextBlock.Visibility = Visibility.Visible;
 }