Example #1
0
        public DataTable TableFromStrings(string[] lines, DatFileConfig datFileConfig)
        {
            DataTable dt = new DataTable();

            int maxPar      = 0;
            int maxParFails = 0;

            if (lines.Length > 0)
            {
                foreach (string currentLine in lines)
                {
                    int maxParTmp = currentLine.Split(datFileConfig.Separators, StringSplitOptions.RemoveEmptyEntries).Length;
                    if (maxParTmp > maxPar)
                    {
                        maxPar = maxParTmp;
                        maxParFails++;
                    }
                }
            }

            if (maxParFails > 2)
            {
                MessageBox.Show("This file may not be entirely correct", Assembly.GetCallingAssembly().GetName().Name, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            for (int i = 0; i < maxPar; i++)
            {
                if (datFileConfig.FileHeaders != null && datFileConfig.FileHeaders.Length > i)
                {
                    dt.Columns.Add(new DataColumn(datFileConfig.FileHeaders[i]));
                }
                else
                {
                    dt.Columns.Add(new DataColumn("#" + i.ToString()));
                }
            }

            foreach (string currentLine in lines)
            {
                dt.NewRow();
                string[]      lineSplit   = currentLine.Split(datFileConfig.Separators, StringSplitOptions.RemoveEmptyEntries);
                List <string> lineColumns = new List <string>();
                foreach (string line in lineSplit)
                {
                    lineColumns.Add(line);
                }
                dt.Rows.Add(lineColumns.ToArray());
            }
            return(dt);
        }
Example #2
0
        public void GenerateTable(string[] FileContent, DataGridView dgContent, ConquerDatFile datCrypto, bool RAWMode = false)
        {
            DataTable     dt            = null;
            DatFileConfig datFileConfig = ConquerToolsHelper.CTools.CurrentConfig.DatFilesConfig.Where(x => x.Key == datCrypto.CurrentDatFileType).FirstOrDefault().Value;

            if (RAWMode)
            {
                dt = RAWTableFromStrings(FileContent);
            }
            else
            {
                dt = TableFromStrings(FileContent, datFileConfig);
            }
            dgContent.DataSource = dt;
        }
Example #3
0
        public void CustomDecrypt(string filename, string filenameOutput, ConquerDatFile.DatFileType datFileType)
        {
            ConquerDatFile dc = new ConquerDatFile(filename, datFileType);

            SelectedDatFile = dc;
            DatFileConfig datFileConfig = ConquerToolsHelper.CTools.CurrentConfig.DatFilesConfig.Where(x => x.Key == dc.CurrentDatFileType).FirstOrDefault().Value;

            if (datFileConfig != null)
            {
                if (Path.GetExtension(filename) == ".txt")
                {
                    dc.Open(true);
                }
                else
                {
                    dc.Open();
                }
            }
        }
Example #4
0
        private void BtnEncryptDat_Click(object sender, EventArgs e)
        {
            // Generate new list with all current data from DataGridView
            Dictionary <uint, DatFileLine> rowValuesGenerated = new Dictionary <uint, DatFileLine>();
            StringBuilder rowValues = new StringBuilder();
            DatFileConfig config    = ConquerToolsHelper.CTools.SelectedDatFile.GetCurrentConfig();

            foreach (DataGridViewRow row in dgvAdvanced.Rows)
            {
                rowValuesGenerated.Add((uint)row.Index, new DatFileLine()
                {
                    LineAttribute = new Dictionary <string, string>()
                });
                foreach (DataGridViewCell cell in row.Cells)
                {
                    if (cell.Value != null)
                    {
                        string cellValue = cell.Value.ToString();
                        if (cellValue == "")
                        {
                            cellValue = "0";
                        }
                        rowValuesGenerated[(uint)row.Index].LineAttribute.Add("#" + cell.ColumnIndex, cellValue);
                        rowValues.Append(cellValue);
                        if (cell.ColumnIndex < row.Cells.Count)
                        {
                            StringBuilder builder = new StringBuilder();
                            foreach (char value in config.Separators)
                            {
                                builder.Append(value);
                            }
                            string sep = builder.ToString();
                            rowValues.Append(sep);
                        }
                    }
                }
                rowValues.Append('\n');
            }
            ConquerToolsHelper.CTools.SelectedDatFile.CurrentFileContent    = rowValuesGenerated;
            ConquerToolsHelper.CTools.SelectedDatFile.CurrentRAWFileContent = rowValues.ToString().Split('\n');
            ConquerToolsHelper.CTools.SaveDat();
        }
Example #5
0
        public DatFileConfig GetCurrentConfig()
        {
            DatFileConfig datFileConfig = ConquerToolsHelper.CTools.CurrentConfig.DatFilesConfig.Where(x => x.Key == CurrentDatFileType).FirstOrDefault().Value;

            return(datFileConfig);
        }