示例#1
0
        private void buttonExportColors_Click(object sender, EventArgs e)
        {
            string tempData = "UserColors";
            int    i        = 0;
            bool   ready    = false;

            foreach (CheckBox temp in UserColorsCB)
            {
                if (temp.Checked)
                {
                    tempData    += "\r\n" + UserColorsB[i].BackColor.ToArgb().ToString();
                    temp.Checked = false;
                    ready        = true;
                }
                i++;
            }

            if (!ready)
            {
                return;
            }

            string asd = BitConverter.ToString(MainForm.zipText(tempData)).Replace("-", "");

            Clipboard.SetText(asd);
            MessageBox.Show("Color data has been copied.");
        }
示例#2
0
        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.");
                }
            }
        }