Beispiel #1
0
 /// <summary>
 /// A method that calculates the average balance of the documents in our current list.
 /// </summary>
 /// <param name="list">
 /// The cells binding list.
 /// </param>
 /// <returns>
 /// The <see cref="float"/>.
 /// Returns the value of the average of our current documents.
 /// </returns>
 /// <exception cref="ArgumentException"> Fired when given list is empty.</exception>
 public virtual float CalculateAverageBalance(BindingList <Document> list)
 {
     if (list.Count > 0)
     {
         return(list.Average(document => document.Balance));
     }
     else
     {
         throw new NullReferenceException(DocumentListEmptyErrorMessage);
     }
 }
Beispiel #2
0
 public void refreshStats()
 {
     if (history.Count == 0)
     {
         bestLabel.Text    = "Best: n/a";
         averageLabel.Text = "Average: n/a";
     }
     else
     {
         bestLabel.Text    = "Best: " + history.Min();
         averageLabel.Text = "Average: " + String.Format("{0:0.00}", history.Average());
     }
 }
Beispiel #3
0
        private void paintGomb_Click(object sender, EventArgs e)
        {
            label3.Show();
            label4.Show();
            label5.Show();
            dataGridView1.Hide();
            atlagFok = homerseklet.Average(t => t.kozepfok);
            maxFok   = homerseklet.Max(t => t.maxfok);
            minFok   = homerseklet.Min(t => t.minfok);
            felhom   = homerseklet.Average(t => t.felhomeret);

            label3.Text = "Maximum hőmérséklet: (C) " + Math.Round(maxFok).ToString();
            label4.Text = "Minimum hőmérséklet: (C) " + Math.Round(minFok).ToString();
            label5.Text = "Felhőtakarót: (%) " + Math.Round(felhom).ToString();
            pictureBox1.Show();
            pictureBox2.Show();

            if (atlagFok > 10)
            {
                pictureBox1.Image = new Bitmap("C:/Users/Matu/source/repos/IRF_Project/Irf_project/Irf_project/Képek/meleg.png");
            }
            else
            {
                pictureBox1.Image = new Bitmap("C:/Users/Matu/source/repos/IRF_Project/Irf_project/Irf_project/Képek/hideg.png");
            }

            if (felhom > 70)
            {
                pictureBox2.Image = new Bitmap("C:/Users/Matu/source/repos/IRF_Project/Irf_project/Irf_project/Képek/felho.png");
            }
            else if (felhom < 40)
            {
                pictureBox2.Image = new Bitmap("C:/Users/Matu/source/repos/IRF_Project/Irf_project/Irf_project/Képek/nap.png");
            }
            else
            {
                pictureBox2.Image = new Bitmap("C:/Users/Matu/source/repos/IRF_Project/Irf_project/Irf_project/Képek/naposfelhos.png");
            }
        }
Beispiel #4
0
        private void MixAndList()
        {
            Person[] array = persons.OrderBy(x => x.DrawCount).ToArray();
            int      limit = array.Length;

            if (rbBelowAvg.Checked)
            {
                double avg = persons.Average(x => x.DrawCount);
                limit = FindLimitIndex(avg);
            }
            else if (rbExcludeMost.Checked)
            {
                double min = persons.Min(x => x.DrawCount);
                limit = FindLimitIndex(min + 3);
            }
            else
            {
                limit = array.Length - 1;
            }

            int    target;
            Person temp;

            for (int i = 0; i < limit; i++)
            {
                target        = rnd.Next(i, limit);
                temp          = array[i];
                array[i]      = array[target];
                array[target] = temp;
            }

            lstResults.DataSource = array;
            lblResult.Text        = array.Length == 0 ? "?" : array[0].Name;

            if (array.Length > 0)
            {
                array[0].LastDrawnTime = DateTime.Now;
                array[0].DrawCount++;

                Person[] sorted = persons.OrderBy(x => x.DrawCount).ToArray();
                persons.Clear();
                foreach (Person item in sorted)
                {
                    persons.Add(item);
                }

                persons.ResetBindings();
            }
        }
Beispiel #5
0
        public void statistiques(Utilisateur unUtilisateur)
        {
            BindingList <Visite>   lesVisites            = Passerelle.Passerelle.returnAllVisite();
            BindingList <Visite>   lesVisitesUtilisateur = new BindingList <Visite>();
            BindingList <TimeSpan> lesTempsAttente       = new BindingList <TimeSpan>();
            BindingList <TimeSpan> tempsTotal            = new BindingList <TimeSpan>();
            TimeSpan tempsAttenteMoyen = TimeSpan.Zero;
            TimeSpan tempsPasseMoyen   = TimeSpan.Zero;

            foreach (Visite uneVisite in lesVisites)
            {
                if (uneVisite.getHeureDebut().Month == DateTime.Now.Month)
                {
                    if (uneVisite.getVisiteur().getId() == unUtilisateur.getId())
                    {
                        lesVisitesUtilisateur.Add(uneVisite);
                        lesTempsAttente.Add(uneVisite.getHeureDepart() - uneVisite.getHeureDebut());
                        tempsTotal.Add(uneVisite.getHeureDepart() - uneVisite.getHeureArrivee());
                    }
                }
            }
            lblStat2.Text = lesVisitesUtilisateur.Count.ToString();
            try
            {
                tempsAttenteMoyen = TimeSpan.FromMilliseconds(lesTempsAttente.Average(i => i.TotalMilliseconds));
            } catch
            {
                tempsAttenteMoyen = TimeSpan.Zero;
            }
            try
            {
                tempsPasseMoyen = TimeSpan.FromMilliseconds(tempsTotal.Average(i => i.TotalMilliseconds));
            } catch
            {
                tempsPasseMoyen = TimeSpan.Zero;
            }
            lblStat3.Text = tempsPasseMoyen.Hours + " h " + tempsPasseMoyen.Minutes + " min " + tempsPasseMoyen.Seconds + " sec";;
            lblStat4.Text = tempsAttenteMoyen.Hours + " h " + tempsAttenteMoyen.Minutes + " min " + tempsAttenteMoyen.Seconds + " sec";
        }
 private string CalcoloMedia(BindingList <TimeTable> timeTables)
 {
     return(timeTables.Average(x => x.ProcessWaitingTime).ToString());
 }