Beispiel #1
0
        public Form1()
        {
            InitializeComponent();
            // Getting types of operations into combo box

            // this.operationsComboBox.DataSource = Enum.GetValues(typeof(Count.Operations));

            foreach (Enum e in Enum.GetValues(typeof(Count.Operations)))
            {
                this.operationsComboBox.Items.Add(EnumUtils.StringValueOf(e));
            }

            operationsComboBox.SelectedIndex = 0;

            foreach (Enum e in Enum.GetValues(typeof(Log.ErrorLogType)))
            {
                this.errorlogcomboBox.Items.Add(EnumUtils.StringValueOf(e));
            }
            errorlogcomboBox.SelectedIndex = 0;

            // "Mini user guide"
            this.resultsListBox.Items.Add("Aby rozpcząć:\n");
            this.resultsListBox.Items.Add("1. Kliknij \"Otwórz plik\" i wybierz plik *.xml.\n");
            this.resultsListBox.Items.Add("2. Wybierz działanie z listy rozwijalnej\n");
            this.resultsListBox.Items.Add("3. Podaj liczbę powtórzeń działań.\n");
        }
Beispiel #2
0
        /// <summary>
        /// Calculation and sending results to string
        /// </summary>
        /// <param name="numberA">#1 number</param>
        /// <param name="numberB">#2 number</param>
        /// <param name="operation">Type of operation</param>
        /// <param name="repeats">Number of repetitions</param>
        /// <returns></returns>
        public List <String> CalucaltionsAndReturningThemAsString(float numberA, float numberB, Operations operation, int repeats)
        {
            List <String> listResult = new List <String>();

            {
                listResult.Add("========================================");
                listResult.Add($"A = {numberA}, B = {numberB}, Działanie = {EnumUtils.StringValueOf(operation)}, Liczba działań = {repeats}\n");
            }
            for (int i = 0; i < repeats; i++)
            {
                // Switch loop with type of operations as argument used
                switch (operation)
                {
                case Operations.Addition:
                    listResult.Add($"[{numberA}] + [{numberB}] = [{numberA + numberB}]\n");
                    numberB = numberA + numberB;
                    break;

                case Operations.Subtraction:
                    listResult.Add($"[{numberA}] - [{numberB}] = [{numberA - numberB}]\n");
                    numberB = numberA - numberB;
                    break;

                case Operations.Multiplication:
                    listResult.Add($"[{numberA}] * [{numberB}] = [{numberA * numberB}]\n");
                    numberB = numberA * numberB;
                    break;

                case Operations.Division:
                    listResult.Add(
                        (String.Format("{0:0.##}", numberA) + " / " + (String.Format("{0:0.##}", numberB)) +
                         " = " + (String.Format("{0:0.##}", numberA / numberB)) + "\n"));
                    numberB = numberA / numberB;
                    break;

                case Operations.exponentiation:
                    listResult.Add($"[{numberA}] ^ [{numberB}] = [{Math.Pow(System.Convert.ToDouble(numberA), Convert.ToDouble(numberB))}]\n");
                    numberB = Convert.ToSingle(Math.Pow(System.Convert.ToDouble(numberA), Convert.ToDouble(numberB)));
                    break;


                case Operations.modulo:
                    listResult.Add($"[{numberA}] % [{numberB}] = [{numberA % numberB}]\n");
                    numberB = numberA % numberB;
                    break;
                }
            }
            return(listResult);
        }