Esempio n. 1
0
 public Input()
 {
     vals = new List<double>();
     vals2 = new List<string>();
     preAnalysis = new InputPreAnalysis();
     conversionDict = new Dictionary<string, double>();
     type = new InputType();
 }
Esempio n. 2
0
        //Method triggered when the popUp form is closed (because of clicking on the upper closing button or on btnPopUp). It calls the method in charge of updating the information for calculations/display
        private void popUp_FormClosing(object sender, FormClosingEventArgs e)
        {
            InputType newType = new InputType();
            newType.mainType = MainTypes.Blank;
            if (cmbBxPopUp.SelectedIndex == 0)
            {
                newType.mainType = MainTypes.Categorical;
            }
            else if (cmbBxPopUp.SelectedIndex == 1)
            {
                //In case of being DateTime, cmbBx2 would also be considered to determine the secondary type
                newType.mainType = MainTypes.DateTime;
                newType.secType = ((List<DateTimeTypes>)cmbBx2.Tag)[cmbBx2.SelectedIndex];
            }

            Modifications curModif = (Modifications)this.Tag; //Current instance of the Modifications class, stored in the Tag of the form when it was created
            curModif.updateNonNumerical(allInputs, curCol, newType); //Method updating the corresponding variables (i.e., list of "Input") on account of the inputs from the user
        }
Esempio n. 3
0
        //Method called after the popup has been closed, taking as argument the new type input by the user
        public void updateNonNumerical(AllInputs allInputs, int curCol, InputType newType)
        {
            if (allInputs.inputs[curCol].vals2.Count >= allInputs.inputs[curCol].vals.Count)
            {
                if (newType.mainType == MainTypes.Blank)
                {
                    allInputs.inputs[curCol].vals = new List<double>();
                    allInputs.inputs[curCol].vals2 = new List<string>();
                    allInputs.inputs[curCol].type.mainType = MainTypes.Blank;
                }
                else
                {
                    if (newType.mainType == MainTypes.DateTime)
                    {
                        //The current column has to be converted to DateTime (if possible)
                        allInputs.inputs[curCol] = updateTime(allInputs.inputs[curCol], newType.secType);
                    }
                    else if (newType.mainType == MainTypes.Categorical)
                    {
                        //The current column has to be converted to categorical (i.e., made-up scale starting from 0 assigning unique IDs to every values)
                        allInputs.inputs[curCol] = updateCategorical(allInputs.inputs[curCol]);
                    }

                    allInputs = lastActionsNewNonNumerical(allInputs, curCol, newType);
                }
            }

            if (curCol < allInputs.inputs.Count)
            {
                //There are still some non-numerical columns requiring an input from the user
                checkNextColumn(allInputs, curCol);
            }
            else
            {
                allInputs0 = allInputs;
                allInputs0.updateCompleted = true;
                completed = true; //All the columns have been updated by the user and thus the inputs can be shown in the corresponding controls; this flag tells the BGW to stop waiting
            }
        }
Esempio n. 4
0
        //Method called after the corresponding conversion (to categorical/DateTime) has been completed to perform some final actions
        private AllInputs lastActionsNewNonNumerical(AllInputs allInputs, int curCol, InputType newType)
        {
            if (allInputs.inputs[curCol].wrongRowsCount > 0)
            {
                allInputs.inputs[curCol].vals = new List<double>();
                allInputs.inputs[curCol].vals2 = new List<string>();
                allInputs.inputs[curCol].type.mainType = MainTypes.Blank;

                string nameToShow = "\"" + allInputs.inputs[curCol].displayedName + "\"";
                string typeToShow = newType.mainType.ToString();
                if (newType.mainType == MainTypes.DateTime)
                {
                    if (newType.secType == DateTimeTypes.Time)
                    {
                        typeToShow = typeToShow + " (expected format: hh:mm:ss or equivalent)";
                    }
                    else
                    {
                        typeToShow = typeToShow + " (expected format: dd-mm-yyyy or equivalent)";
                    }
                }
                MessageBox.Show("Some values in " + nameToShow + " cannot be converted into " + typeToShow + "." + Environment.NewLine + "This column will not be considered during the calculations.");
            }
            else
            {
                allInputs.inputs[curCol].type = newType;
            }

            return allInputs;
        }