Beispiel #1
0
        private async void delayFunc()
        {
            await Task.Delay(1000);

            switch (getCBoxDB2Text())
            {
            case "itemdisplayinfo":
                db2.ListeItemDisplayInfo(db2CustomPath, getCBoxDB2Text() + "_custom.csv");
                break;

            case "itemdisplayinfomaterialres":
                db2.ListeItemDisplayInfoMaterialRes(db2CustomPath, getCBoxDB2Text() + "_custom.csv");
                break;

            case "modelfiledata":
                db2.ListeModelFileData(db2CustomPath, getCBoxDB2Text() + "_custom.csv");
                break;

            case "texturefiledata":
                db2.ListeTextureFileData(db2CustomPath, getCBoxDB2Text() + "_custom.csv");
                break;

            default:
                break;
            }
        }
        private void textureFiledata()
        {
            sb.Clear();
            sb.AppendLine("\"FileDataID\",\"MaterialResourcesID\",\"UsageType\",\"RelationshipData\"");

            string header = sb.ToString();

            sb.Clear();

            string pathCSVGen = Path.Combine(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "texturefiledata.csv");

            if (File.Exists(pathCSVGen))
            {
                File.Delete(pathCSVGen);
            }
            File.AppendAllText(pathCSVGen, header);

            if (File.Exists(Path.Combine(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "texturefiledataGen.csv")))
            {
                File.Delete(Path.Combine(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "texturefiledataGen.csv"));
            }

            db2.ListeTextureFileData(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "texturefiledataGen.csv");

            int maxMaterialID = 0;

            string pathDB2Read = Path.Combine(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "texturefiledataGen.csv");

            if (File.Exists(pathDB2Read))
            {
                string[] temp = File.ReadAllLines(pathDB2Read);
                sb.Clear();
                for (int i = 0; i < temp.Length; i++)
                {
                    sb.AppendLine(temp[i].Split(',')[1]);
                }
                File.WriteAllText(pathDB2Read, sb.ToString());
                sb.Clear();
                maxMaterialID = File.ReadAllLines(pathDB2Read).Select(int.Parse).Max() + 1;
                string file1 = File.ReadAllText(pathDB2Read);
                if (dataGridView1.DataSource != null)
                {
                    for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                    {
                        if (!file1.Contains(dataGridView1.Rows[i].Cells[1].Value.ToString()) && dataGridView1.Rows[i].Cells[0].Value.ToString().Contains(".blp"))
                        {
                            sb.AppendLine("\"" + dataGridView1.Rows[i].Cells[1].Value + "\",\"" + maxMaterialID + "\",\"" + 0 + "\",\"" + maxMaterialID + "\"");
                            maxMaterialID++;
                        }
                    }
                }
                File.AppendAllText(pathCSVGen, sb.ToString());
                sb.Clear();
            }
            else
            {
                db2.ListeTextureFileDataLastOffi(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "texturefiledataLastOffi.csv");
                string PathCSV = Path.Combine(System.Reflection.Assembly.GetEntryAssembly().Location.Substring(0, System.Reflection.Assembly.GetEntryAssembly().Location.LastIndexOf('\\')), "texturefiledataLastOffi.csv");
                string temp    = File.ReadAllText(PathCSV);
                maxMaterialID = int.Parse(temp.Split(',')[1]) + 1;
                if (dataGridView1.DataSource != null)
                {
                    for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)
                    {
                        if (dataGridView1.Rows[i].Cells[0].Value.ToString().Contains(".blp"))
                        {
                            sb.AppendLine("\"" + dataGridView1.Rows[i].Cells[1].Value + "\",\"" + maxMaterialID + "\",\"" + 0 + "\",\"" + maxMaterialID + "\"");
                            maxMaterialID++;
                        }
                    }
                }
                File.AppendAllText(pathCSVGen, sb.ToString());
                sb.Clear();
            }
        }