private void toolStripButton4_Click(object sender, EventArgs e)
        {
            msg4u newMsg = new msg4u();

            newMsg.Create(Utils.getSeries(cb_method.SelectedIndex), "VarNew_" + rnd.Next(824, 9000), "", true);

            Program.mainPP.addSelectedfile(newMsg.GetMSGData());
            Program.mainXBB.setSelectedfile(cb_xbb.SelectedIndex, Program.mainPP.Data);
            RefreshLViewList((int)Program.mainPP.Count - 2);
        }
Exemple #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            Ookii.Dialogs.VistaFolderBrowserDialog folderdialog = new Ookii.Dialogs.VistaFolderBrowserDialog();
            VistaSaveFileDialog folderdialog2 = new VistaSaveFileDialog();
            string filename = "";

            GameSeries indexcombo = Utils.getSeries(Program.mainf.cb_method.SelectedIndex);

            switch (comboBox1.SelectedIndex)
            {
            case 6:
                folderdialog.SelectedPath = Program.AConfig.FilePath[0];

                if (folderdialog.ShowDialog() == DialogResult.OK)
                {
                    uxTabControl1.Enabled = false;
                    string pathe = folderdialog.SelectedPath + @"\" + Path.GetFileName(Program.AConfig.FilePath[0]).Replace(Path.GetExtension(Program.AConfig.FilePath[0]), "") + @"\";

                    if (!Directory.Exists(pathe))
                    {
                        Directory.CreateDirectory(pathe);
                    }

                    progressBar1.Value   = 0;
                    progressBar1.Maximum = (int)Program.mainXBB.getCount();

                    Thread nTh = new Thread(
                        new ThreadStart(() =>
                    {
                        for (int i = 0; i < Program.mainXBB.getCount(); i++)
                        {
                            filename     = Program.mainXBB.getFileName(i).Replace("\0", "");
                            papa tempapa = new papa(Program.mainXBB.getSelectedfile(i));

                            StringBuilder buildstr = new StringBuilder();

                            for (int j = 0; j < tempapa.Count - 1; j++)
                            {
                                msg4u newMsg = new msg4u(tempapa.getSelectedData(j), indexcombo);

                                buildstr.AppendLine("============================================");
                                buildstr.AppendLine(newMsg.GetVariableSection()).Append("\n");
                                buildstr.AppendLine("--------------------------------------------");
                                buildstr.AppendLine(newMsg.GetTextSection()).Append("\n");
                            }

                            progressBar1.BeginInvoke(new Action(() =>
                            {
                                progressBar1.Value += 1;
                            }));

                            label11.BeginInvoke(new Action(() =>
                            {
                                label11.Text = "Progress : " + (i + 1) + " of " + Program.mainXBB.getCount();
                            }));

                            File.WriteAllText(pathe + @"\" + filename + ".txt", buildstr.ToString(), Encoding.UTF8);
                        }

                        label11.BeginInvoke(new Action(() =>
                        {
                            label11.Text = "";
                        }));

                        progressBar1.BeginInvoke(new Action(() =>
                        {
                            progressBar1.Value = 0;
                        }));
                        uxTabControl1.BeginInvoke(new Action(() =>
                        {
                            uxTabControl1.Enabled = true;
                        }));
                        GC.Collect(9, GCCollectionMode.Forced);
                    }));

                    nTh.Start();
                }
                break;

            case 0:
                folderdialog.SelectedPath = Program.AConfig.FilePath[0];

                if (folderdialog.ShowDialog() == DialogResult.OK)
                {
                    uxTabControl1.Enabled = false;

                    string pathe = folderdialog.SelectedPath + @"\" + Path.GetFileName(Program.AConfig.FilePath[0]).Replace(Path.GetExtension(Program.AConfig.FilePath[0]), "") + @"\";

                    if (!Directory.Exists(pathe))
                    {
                        Directory.CreateDirectory(pathe);
                    }

                    progressBar1.Value   = 0;
                    progressBar1.Maximum = (int)Program.mainXBB.getCount();

                    Thread nTh = new Thread(
                        new ThreadStart(() =>
                    {
                        for (int i = 0; i < Program.mainXBB.getCount(); i++)
                        {
                            File.WriteAllBytes(pathe + Program.mainXBB.getFileName(i).Replace("\0", "") + ".pp", Program.mainXBB.getSelectedfile(i));

                            progressBar1.BeginInvoke(new Action(() =>
                            {
                                progressBar1.Value += 1;
                            }));

                            label11.BeginInvoke(new Action(() =>
                            {
                                progressBar1.Text = "Progress : " + i + " of " + Program.mainXBB.getCount();
                            }));
                        }

                        label11.BeginInvoke(new Action(() =>
                        {
                            label11.Text = "";
                        }));

                        progressBar1.BeginInvoke(new Action(() =>
                        {
                            progressBar1.Value = 0;
                        }));
                        uxTabControl1.BeginInvoke(new Action(() =>
                        {
                            uxTabControl1.Enabled = true;
                        }));
                        GC.Collect(9, GCCollectionMode.Forced);
                    }));

                    nTh.Start();
                }
                break;

            case 1:
                folderdialog.SelectedPath = Program.AConfig.FilePath[0];

                if (folderdialog.ShowDialog() == DialogResult.OK)
                {
                    uxTabControl1.Enabled = false;
                    string pathe = folderdialog.SelectedPath + @"\" + Path.GetFileName(Program.AConfig.FilePath[0]).Replace(Path.GetExtension(Program.AConfig.FilePath[0]), "") + @"\";

                    if (!Directory.Exists(pathe))
                    {
                        Directory.CreateDirectory(pathe);
                    }

                    progressBar1.Value   = 0;
                    progressBar1.Maximum = (int)Program.mainXBB.getCount();

                    Thread nTh = new Thread(
                        new ThreadStart(() =>
                    {
                        for (int i = 0; i < Program.mainXBB.getCount(); i++)
                        {
                            filename     = Program.mainXBB.getFileName(i).Replace("\0", "");
                            papa tempapa = new papa(Program.mainXBB.getSelectedfile(i));

                            ppmsg4 newtempjson  = new ppmsg4();
                            newtempjson.Date    = DateTime.Now;
                            newtempjson.Author  = "BokujoMessage4 JSON generated files";
                            newtempjson.Content = new pmsg4[tempapa.Count - 1];

                            for (int j = 0; j < tempapa.Count - 1; j++)
                            {
                                msg4u newMsg = new msg4u(tempapa.getSelectedData(j), indexcombo);

                                newtempjson.Content[j].VardId = newMsg.GetVariableSection();
                                newtempjson.Content[j].Text   = newMsg.GetTextSection();
                            }

                            progressBar1.BeginInvoke(new Action(() =>
                            {
                                progressBar1.Value += 1;
                            }));

                            label11.BeginInvoke(new Action(() =>
                            {
                                label11.Text = "Progress : " + i + " of " + Program.mainXBB.getCount();
                            }));

                            File.WriteAllText(pathe + @"\" + filename + ".json", JsonConvert.SerializeObject(newtempjson, Formatting.Indented), Encoding.UTF8);
                        }

                        label11.BeginInvoke(new Action(() =>
                        {
                            label11.Text = "";
                        }));

                        progressBar1.BeginInvoke(new Action(() =>
                        {
                            progressBar1.Value = 0;
                        }));
                        uxTabControl1.BeginInvoke(new Action(() =>
                        {
                            uxTabControl1.Enabled = true;
                        }));
                        GC.Collect(9, GCCollectionMode.Forced);
                    }));

                    nTh.Start();
                }
                break;

            case 2:
                filename = Program.mainf.cb_xbb.Text;
                folderdialog.SelectedPath = Program.AConfig.FilePath[0];

                if (folderdialog.ShowDialog() == DialogResult.OK)
                {
                    uxTabControl1.Enabled = false;
                    string pathe = folderdialog.SelectedPath + @"\" + filename + @"\";

                    if (!Directory.Exists(pathe))
                    {
                        Directory.CreateDirectory(pathe);
                    }

                    progressBar1.Value   = 0;
                    progressBar1.Maximum = (int)Program.mainPP.Count;

                    Thread nTh = new Thread(
                        new ThreadStart(() =>
                    {
                        for (int i = 0; i < Program.mainPP.Count - 1; i++)
                        {
                            msg4u newMsg = new msg4u(Program.mainPP.getSelectedData(i), indexcombo);

                            File.WriteAllText(pathe + newMsg.GetVariableSection() + ".txt", newMsg.GetTextSection(), Encoding.UTF8);

                            progressBar1.BeginInvoke(new Action(() =>
                            {
                                progressBar1.Value += 1;
                            }));

                            label11.BeginInvoke(new Action(() =>
                            {
                                label11.Text = "Progress : " + i + " of " + Program.mainPP.Count;
                            }));
                        }

                        label11.BeginInvoke(new Action(() =>
                        {
                            label11.Text = "";
                        }));

                        progressBar1.BeginInvoke(new Action(() =>
                        {
                            progressBar1.Value = 0;
                        }));
                        uxTabControl1.BeginInvoke(new Action(() =>
                        {
                            uxTabControl1.Enabled = true;
                        }));
                        GC.Collect(9, GCCollectionMode.Forced);
                    }));

                    nTh.Start();
                }
                break;

            case 3:
                filename     = Program.mainf.cb_xbb.Text;
                folderdialog = new Ookii.Dialogs.VistaFolderBrowserDialog();
                folderdialog.SelectedPath = Program.AConfig.FilePath[0];

                if (folderdialog.ShowDialog() == DialogResult.OK)
                {
                    uxTabControl1.Enabled = false;
                    string pathe = folderdialog.SelectedPath + @"\" + filename + @"\";

                    if (!Directory.Exists(pathe))
                    {
                        Directory.CreateDirectory(pathe);
                    }

                    progressBar1.Value   = 0;
                    progressBar1.Maximum = (int)Program.mainPP.Count;

                    Thread nTh = new Thread(
                        new ThreadStart(() =>
                    {
                        for (int i = 0; i < Program.mainPP.Count - 1; i++)
                        {
                            msg4u newMsg = new msg4u(Program.mainPP.getSelectedData(i), indexcombo);

                            File.WriteAllBytes(pathe + newMsg.GetVariableSection() + ".msg4", newMsg.GetMSGData());

                            progressBar1.BeginInvoke(new Action(() =>
                            {
                                progressBar1.Value += 1;
                            }));

                            label11.BeginInvoke(new Action(() =>
                            {
                                label11.Text = "Progress : " + i + " of " + Program.mainPP.Count;
                            }));
                        }

                        label11.BeginInvoke(new Action(() =>
                        {
                            label11.Text = "";
                        }));

                        progressBar1.BeginInvoke(new Action(() =>
                        {
                            progressBar1.Value = 0;
                        }));
                        uxTabControl1.BeginInvoke(new Action(() =>
                        {
                            uxTabControl1.Enabled = true;
                        }));
                        GC.Collect(9, GCCollectionMode.Forced);
                    }));

                    nTh.Start();
                }
                break;

            case 5:
                folderdialog.SelectedPath = Program.AConfig.FilePath[0];

                if (folderdialog.ShowDialog() == DialogResult.OK)
                {
                    uxTabControl1.Enabled = false;
                    string pathe = folderdialog.SelectedPath + @"\" + Path.GetFileName(Program.AConfig.FilePath[0]).Replace(Path.GetExtension(Program.AConfig.FilePath[0]), "") + @"\";

                    if (!Directory.Exists(pathe))
                    {
                        Directory.CreateDirectory(pathe);
                    }

                    progressBar1.Value   = 0;
                    progressBar1.Maximum = (int)Program.mainXBB.getCount();

                    Thread nTh = new Thread(
                        new ThreadStart(() =>
                    {
                        for (int i = 0; i < Program.mainXBB.getCount(); i++)
                        {
                            filename     = Program.mainXBB.getFileName(i).Replace("\0", "");
                            papa tempapa = new papa(Program.mainXBB.getSelectedfile(i));

                            FileInfo newFile = new FileInfo(pathe + @"\" + filename + ".xlsx");
                            ExcelPackage pck = new ExcelPackage(newFile);

                            if (File.Exists(newFile.FullName))
                            {
                                File.Delete(newFile.FullName);
                            }

                            var ws = pck.Workbook.Worksheets.Add(filename);

                            for (int j = 0; j < tempapa.Count - 1; j++)
                            {
                                msg4u newMsg = new msg4u(tempapa.getSelectedData(j), indexcombo);

                                ws.Cells["A" + (j + 1)].Value = newMsg.GetVariableSection();
                                ws.Cells["B" + (j + 1)].Value = newMsg.GetTextSection();
                            }

                            progressBar1.BeginInvoke(new Action(() =>
                            {
                                progressBar1.Value += 1;
                            }));

                            label11.BeginInvoke(new Action(() =>
                            {
                                label11.Text = "Progress : " + (i + 1) + " of " + Program.mainXBB.getCount();
                            }));

                            pck.Save();
                        }

                        label11.BeginInvoke(new Action(() =>
                        {
                            label11.Text = "";
                        }));

                        progressBar1.BeginInvoke(new Action(() =>
                        {
                            progressBar1.Value = 0;
                        }));
                        uxTabControl1.BeginInvoke(new Action(() =>
                        {
                            uxTabControl1.Enabled = true;
                        }));
                        GC.Collect(9, GCCollectionMode.Forced);
                    }));

                    nTh.Start();
                }
                break;

            case 4:
                filename = Program.mainf.cb_xbb.Text;
                folderdialog2.FileName         = filename + ".json";
                folderdialog2.Filter           = "JSON files (*.json) | *.json";
                folderdialog2.InitialDirectory = Program.AConfig.FilePath[0];

                if (folderdialog2.ShowDialog() == DialogResult.OK)
                {
                    uxTabControl1.Enabled = false;
                    string pathe = Path.GetDirectoryName(folderdialog2.InitialDirectory) + @"\";

                    if (!Directory.Exists(pathe))
                    {
                        Directory.CreateDirectory(pathe);
                    }

                    ppmsg4 newtempjson = new ppmsg4();
                    newtempjson.Date    = DateTime.Now;
                    newtempjson.Author  = "BokujoMessage4 JSON generated files";
                    newtempjson.Content = new pmsg4[Program.mainPP.Count - 1];

                    progressBar1.Value   = 0;
                    progressBar1.Maximum = (int)Program.mainPP.Count;

                    Thread nTh = new Thread(
                        new ThreadStart(() =>
                    {
                        for (int i = 0; i < Program.mainPP.Count - 1; i++)
                        {
                            msg4u newMsg = new msg4u(Program.mainPP.getSelectedData(i), indexcombo);

                            newtempjson.Content[i].VardId = newMsg.GetVariableSection();
                            newtempjson.Content[i].Text   = newMsg.GetTextSection();

                            progressBar1.BeginInvoke(new Action(() =>
                            {
                                progressBar1.Value += 1;
                            }));

                            label11.BeginInvoke(new Action(() =>
                            {
                                label11.Text = "Progress : " + i + " of " + Program.mainPP.Count;
                            }));
                        }

                        uxTabControl1.BeginInvoke(new Action(() =>
                        {
                            uxTabControl1.Enabled = true;
                        }));


                        GC.Collect(9, GCCollectionMode.Forced);
                    }));

                    nTh.Start();

                    File.WriteAllText(folderdialog2.FileName, JsonConvert.SerializeObject(newtempjson, Formatting.Indented), Encoding.UTF8);
                }

                break;
            }
        }
        private void ip_mes_tx_changed(object sender, FastColoredTextBoxNS.TextChangedEventArgs e)
        {
            if (Program.mainMSG != null)
            {
                lb_txcount_0.Text = ip_mes.Text.Length + checknum(ip_mes.Text.Length - Program.mainMSG.GetTextSection().Length) + " character";


                msg4u mainMSG0 = new msg4u();

                if (cb_method.SelectedIndex == 2)
                {
                    mainMSG0.Create(Utils.getSeries(cb_method.SelectedIndex), ip_var.Text, ip_mes.Text, true);


                    textBox1.Text = BitConverter.ToInt32(mainMSG0.GetEUSection(), 0) + "";
                    textBox2.Text = Program.mainMSG.isHaveMessage + "";
                }
                else
                {
                    mainMSG0.Create(Utils.getSeries(cb_method.SelectedIndex), ip_var.Text, ip_mes.Text, true);
                    textBox1.Text = "";
                    textBox2.Text = Program.mainMSG.isHaveMessage + "";
                }

                DynamicFileByteProvider dynamicFileByteProvider = null;

                try
                {
                    dynamicFileByteProvider = new DynamicFileByteProvider(new MemoryStream(mainMSG0.GetMSGData()));
                }
                catch
                {
                }

                ip_hexview.ByteProvider = dynamicFileByteProvider;

                lb_txpos_0.Text = "Position: " + ip_mes.SelectionStart + " | " + ip_mes.LinesCount + " Line | " + mainMSG0.GetMSGData().Length + "/" + Program.mainMSG.GetMSGData().Length + " byte";
            }
        }