private void buttonExportImport_Click(object sender, EventArgs e) { DataTable combDT = new DataTable(); if (exportState) { DataColumn dc = new DataColumn("savePath", typeof(string)); combDT.Columns.Add(dc); dc = new DataColumn("saveName", typeof(string)); combDT.Columns.Add(dc); dc = new DataColumn("NewName", typeof(string)); combDT.Columns.Add(dc); string tempData = "CCpositions"; if (listBox2.DataSource != null) { combDT = (DataTable)listBox2.DataSource; } int CustomInc = 0; //Save number toolStripProgressBar.Maximum = combDT.Rows.Count; foreach (DataRow temp in combDT.Rows) { //Load and scan save files for truck position string[] tSF = MainForm.NewDecodeFile(temp[0].ToString() + @"\game.sii", this, statusStripCCpositions.Name, statusStripCCpositions.Items[0].Name); string[] chunkOfline; string truckPosition = ""; for (int line = 0; line < tSF.Length; line++) { if (tSF[line].StartsWith(" truck_placement:")) { chunkOfline = tSF[line].Split(new char[] { ':' }); truckPosition = chunkOfline[1].TrimStart(' '); break; } } //Clear memory tSF = null; GC.Collect(); // //Save name string SaveName = ""; if (radioButtonNamesOriginal.Checked) { SaveName = temp[1].ToString(); } else if (radioButtonNamesCustom.Checked) { SaveName = temp["NewName"].ToString(); //textBoxCustomName.Text + CustomInc.ToString(); //CustomInc++; } else if (radioButtonNamesNone.Checked) { SaveName = ""; } tempData += "\r\nName:" + SaveName + "\r\nPosition:" + truckPosition; CustomInc++; toolStripProgressBar.Value = CustomInc; } string Converted = BitConverter.ToString(MainForm.zipText(tempData)).Replace("-", ""); Clipboard.SetText(Converted); toolStripProgressBar.Value = 0; MessageBox.Show("Positions has been copied."); } else { //listBox2.MouseDown += listBox2_MouseDown; //listBox2.SelectedIndexChanged -= listBox2_SelectedIndexChanged; //listBox2.SelectionMode = SelectionMode.One; DataColumn dc = new DataColumn("truckPosition", typeof(string)); combDT.Columns.Add(dc); dc = new DataColumn("saveName", typeof(string)); combDT.Columns.Add(dc); dc = new DataColumn("NewName", typeof(string)); combDT.Columns.Add(dc); if (listBox2.DataSource != null) { combDT = (DataTable)listBox2.DataSource; } try { string inputData = MainForm.unzipText(Clipboard.GetText()); string[] Lines = inputData.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); if (Lines[0] == "CCpositions") { string Name = ""; for (int i = 1; i < Lines.Length; i++) { if (Lines[i].StartsWith("Name")) { Name = Lines[i].Split(new char[] { ':' }, 2)[1]; } else if (Lines[i].StartsWith("Position")) { combDT.Rows.Add(Lines[i].Split(new char[] { ':' }, 2)[1], Name); } } listBox2.DataSource = combDT; listBox2.ValueMember = "truckPosition"; listBox2.DisplayMember = "saveName"; listBox2.SelectedIndex = 0; radioButtonMove.Checked = true; buttonMoveSaves.Enabled = true; radioButtonMove.Checked = true; radioButtonMove.Enabled = true; radioButtonSelect.Enabled = true; MessageBox.Show("Position data has been inserted."); } else { MessageBox.Show("Wrong data. Expected Position data but\r\n" + Lines[0] + "\r\nwas found."); } } catch { MessageBox.Show("Something gone wrong."); } } }
private void buttonImportColors_Click(object sender, EventArgs e) { if (ImportColorsB.Length > 0) { foreach (Button t in ImportColorsB) { t.Dispose(); } foreach (CheckBox t in ImportColorsCB) { t.Dispose(); } } ImportedColors.Clear(); try { string inputData = MainForm.unzipText(Clipboard.GetText()); string[] Lines = inputData.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); if (Lines[0] == "UserColors") { List <string> paintstr = new List <string>(); for (int i = 1; i < Lines.Length; i++) { ImportedColors.Add(Color.FromArgb(Int32.Parse(Lines[i]))); } int impColors = Lines.Length - 1; CreateImportColorsButtons(impColors); foreach (CheckBox colorCB in UserColorsCB) { colorCB.Checked = false; } int g = 0; foreach (Button t in UserColorsB) { if (MainForm.UserColorsList[g].A == 0 && impColors > 0) { UserColorsCB[g].Checked = true; impColors--; if (impColors == 0) { break; } } g++; } this.Size = new Size(this.Size.Width, 323); groupBoxImportedColors.Visible = true; buttonReplaceColors.Enabled = true; foreach (CheckBox colorCB in UserColorsCB) { colorCB.Enabled = true; } buttonExport.Enabled = false; MessageBox.Show("Color data has been inserted."); } else { MessageBox.Show("Wrong data. Expected Color data but\r\n" + Lines[0] + "\r\nwas found."); } } catch { MessageBox.Show("Something gone wrong."); } }