public void Update()
        {
            string[,] biggestResults = dailyUseOfApplication_db.GetBiggestResults();
            double[] partOfResults = GetDoubleBiggestResults(biggestResults);

            double sumpartOfResults = 0;

            for (int i = 0; i < 4; i++)
            {
                if (i > 0)
                {
                    sumpartOfResults += partOfResults[i - 1];
                }
                if (partOfResults[i] > 0)
                {
                    UpdateSegment(partOfResults[i], sumpartOfResults, i, biggestResults[i, 0]);
                }
                else
                {
                    labels[i].Opacity(0);
                }
            }

            int sum = 0;

            int[] valueTable = new int[4];
            for (int i = 0; i < 4; i++)
            {
                sum          += Convert.ToInt32(biggestResults[i, 1]);
                valueTable[i] = Convert.ToInt32(biggestResults[i, 1]);
            }
            double allPercent = partOfResults[0] + partOfResults[1] + partOfResults[2] + partOfResults[3];

            if ((1.00 < allPercent || allPercent < 0.99) && sum > 0)
            {
                int[] partOfResultsTableInt = ActionOnNumbers.EqualizePercentages(valueTable, sum);
                for (int i = 0; i < 4; i++)
                {
                    labels[i].SetContent(partOfResultsTableInt[i] + " %");
                }
            }
        }
Esempio n. 2
0
        public void Update()
        {
            int[]      tableTime      = new int[4];
            int[]      tableTime_copy = new int[4];
            List <int> numbers        = new List <int>();

            numbers.Add(2);
            for (int i = 0; i < 4; i++)
            {
                tableTime[i] = 0;
            }
            tableTime[0] = dailyUseOfApplication_db.GetTimeForTitle("'Wył. komputer'");
            tableTime[1] = dailyUseOfApplication_db.GetTimeForTitle("'Brak Aktyw.'");
            tableTime[2] = dailyUseOfApplication_db.GetTimeForNumberActivity(numbers);
            numbers.Add(-2); numbers.Add(-1);
            tableTime[3] = dailyUseOfApplication_db.GetTimeForNumberActivity(numbers, true);

            int sum = 0;

            for (int i = 0; i < 4; i++)
            {
                sum += tableTime[i];
            }
            for (int i = 0; i < 4; i++)
            {
                tableTime_copy[i] = tableTime[i];
                if (sum > 0)
                {
                    tableTime[i] = Convert.ToInt32(Math.Round(ActionOnNumbers.DivisionD(tableTime[i], sum) * 100));
                }
                UpdateSegment(i, tableTime[i]);
            }

            if (tableTime[0] + tableTime[1] + tableTime[2] + tableTime[3] != 100 && sum > 0)
            {
                tableTime = ActionOnNumbers.EqualizePercentages(tableTime_copy, sum);
                for (int i = 0; i < 4; i++)
                {
                    UpdateSegment(i, tableTime[i]);
                }
            }
        }