示例#1
0
        private void ReadDldFile(FileInfo dldFile)
        {
            DataLearnDecription dld = Tools.DeSerializeObject <DataLearnDecription>(dldFile.FullName);

            if (ElementCount == dld.InputQuantity + dld.OutputQuantity)
            {
                nudInputQuantity.Value  = (Decimal)dld.InputQuantity;
                nudOutputQuantity.Value = (Decimal)dld.OutputQuantity;

                cbInputDimensions.SelectedIndex  = dld.InputDimensionIndex;
                cbOutputDimensions.SelectedIndex = dld.OutputDimensionIndex;

                dgvInputMapping.Rows.Clear();

                foreach (MappedValue mappValue in dld.MappedInputs)
                {
                    dgvInputMapping.Rows.Add(new String[] { mappValue.OriginalValue, mappValue.NewValue });
                }

                dgvOutputMapping.Rows.Clear();

                foreach (MappedValue mappValue in dld.MappedOutputs)
                {
                    dgvOutputMapping.Rows.Add(new String[] { mappValue.OriginalValue, mappValue.NewValue });
                }
            }
        }
示例#2
0
        private void BCreate_Click(object sender, EventArgs e)
        {
            String path     = file.FullName.Replace(file.Name, "");
            String fileName = file.Name.Replace(file.Extension, "") + ".dld";
            String dldFile  = path + fileName;

            // TODO: !IMPLEMENTED: Validation on not filled data - mapped.
            List <MappedValue> inputMappedValues = new List <MappedValue>();

            foreach (DataGridViewRow row in dgvInputMapping.Rows)
            {
                if (row.Cells[0].Value != null)
                {
                    if (row.Cells[0].Value.ToString() != "")
                    {
                        MappedValue mappedValue = new MappedValue()
                        {
                            OriginalValue = row.Cells[0].Value.ToString(),
                            NewValue      = row.Cells[1].Value == null ? "" : row.Cells[1].Value.ToString()
                        };

                        inputMappedValues.Add(mappedValue);
                    }
                }
            }

            List <MappedValue> outputMappedValues = new List <MappedValue>();

            foreach (DataGridViewRow row in dgvOutputMapping.Rows)
            {
                if (row.Cells[0].Value != null)
                {
                    if (row.Cells[0].Value.ToString() != "")
                    {
                        MappedValue mappedValue = new MappedValue()
                        {
                            OriginalValue = row.Cells[0].Value.ToString(),
                            NewValue      = row.Cells[1].Value == null ? "" : row.Cells[1].Value.ToString()
                        };

                        outputMappedValues.Add(mappedValue);
                    }
                }
            }


            DataLearnDecription dld = new DataLearnDecription()
            {
                InputQuantity            = (int)nudInputQuantity.Value,
                OutputQuantity           = (int)nudOutputQuantity.Value,
                InputPossibleDimensions  = inputPossibleDimensions,
                OutputPossibleDimensions = outputPossibleDimensions,
                InputDimensionIndex      = cbInputDimensions.SelectedIndex,
                OutputDimensionIndex     = cbOutputDimensions.SelectedIndex,
                MappedInputs             = inputMappedValues,
                MappedOutputs            = outputMappedValues
            };

            try
            {
                Tools.SerializeObject(dld, dldFile);
                MessageBox.Show(this, "File " + fileName + " created successfully!", "File created", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Error while creating dld file: " + ex.Message, "Something went wrong...", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }