Ejemplo n.º 1
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs exxx)
        {
            BrakeReading = false;
            list_id      = 0;
            bool isParse = int.TryParse(textBox2.Text, out list_id);

            if (!isParse)
            {
                MessageBox.Show("Please specify the list!");
                return;
            }
            LastList = list_id;
            bool tryparse2 = int.TryParse(textBox4.Text, out int version);

            if (!tryparse2)
            {
                MessageBox.Show("Please specify an element version!");
                return;
            }

            bool tryparse3 = int.TryParse(textBox3.Text, out int countx);

            OpenFileDialog eLoad = new OpenFileDialog
            {
                Filter           = "Elements File (*.data)|*.data|All Files (*.*)|*.*",
                RestoreDirectory = false
            };

            if (eLoad.ShowDialog() == System.Windows.Forms.DialogResult.OK && File.Exists(eLoad.FileName))
            {
                GC.Collect();
                sameFile = eLoad.FileName;
                try
                {
                    Blocked           = true;
                    LastAddress       = textBox1.Text;
                    eLC               = new eListCollection();
                    eLC.progress_bar += Progress_bar;
                    eList[] Li = new eList[0];
                    Li        = eLC.LoadEmptyConfigs(version);
                    eLC.Lists = Li;
                    listBox_items.Rows.Clear();
                    using (FileStream fs = File.OpenRead(eLoad.FileName))
                    {
                        using (BinaryReader br = new BinaryReader(fs))
                        {
                            int pos = Convert.ToInt32(textBox1.Text.ToUpper().Trim().Normalize(), 16);
                            br.BaseStream.Seek(pos, SeekOrigin.Begin);
                            for (int l = list_id; l < list_id + 1; l++)
                            {
                                eLC.Lists[l].elementValues   = new SortedList <int, SortedList <int, object> >();
                                eLC.Lists[l].elementPosition = new SortedList <int, int>();

                                for (int e = 0; e < (tryparse3 && countx > 0 ? countx : 999999); e++)
                                {
                                    eLC.Lists[l].elementValues[e] = new SortedList <int, object>();
                                    Application.DoEvents();
                                    Progress_bar("Read :" + e + "/" + 99999, e, 99999);
                                    try
                                    {
                                        for (int f = 0; f < eLC.Lists[l].elementTypes.Length; f++)
                                        {
                                            eLC.Lists[l].elementValues[e][f] = eLC.ReadValue(br, eLC.Lists[l].elementTypes[f]);

                                            if (eLC.Lists[l].elementFields[f] == "Name")
                                            {
                                                int  id         = Int32.Parse(eLC.Lists[l].elementValues[e][0].ToString());
                                                bool isNegative = (id & (1 << 31)) != 0;
                                                if (isNegative)
                                                {
                                                    break;
                                                }
                                                listBox_items.Rows.Add(new object[] { id.ToString(), eLC.Lists[l].GetValue(e, f) });

                                                if (checkBox1.Checked)
                                                {
                                                    Application.DoEvents();
                                                    listBox_items.Rows[e].Selected = true;
                                                    listBox_items.CurrentCell      = listBox_items.Rows[e].Cells[0];
                                                }
                                            }
                                        }

                                        eLC.Lists[l].elementPosition[e] = (Int32)br.BaseStream.Position;
                                        textBox5.Text = eLC.Lists[l].elementPosition[e].ToString("X4").ToUpper();
                                    }
                                    catch
                                    {
                                        break;
                                    }

                                    if (BrakeReading)
                                    {
                                        break;
                                    }
                                }
                            }

                            BrakeReading = false;
                            Blocked      = false;
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }
        }
Ejemplo n.º 2
0
        private void OpenSameFile()
        {
            list_id = 0;
            bool isParse = int.TryParse(textBox2.Text, out list_id);

            if (!isParse)
            {
                MessageBox.Show("Please specify the list!");
                return;
            }

            bool tryparse2 = int.TryParse(textBox4.Text, out int version);

            if (!tryparse2)
            {
                MessageBox.Show("Please specify an element version!");
                return;
            }

            bool tryparse3 = int.TryParse(textBox3.Text, out int countx);


            if (sameFile != null)
            {
                GC.Collect();
                try
                {
                    Blocked = true;
                    eLC     = new eListCollection();
                    eList[] Li = new eList[0];
                    Li        = eLC.LoadEmptyConfigs(version);
                    eLC.Lists = Li;
                    listBox_items.Rows.Clear();


                    using (FileStream fs = File.OpenRead(sameFile))
                    {
                        using (BinaryReader br = new BinaryReader(fs))
                        {
                            int pos = Convert.ToInt32(textBox1.Text.ToUpper().Trim().Normalize(), 16);
                            br.BaseStream.Seek(pos, SeekOrigin.Begin);
                            for (int l = list_id; l < list_id + 1; l++)
                            {
                                eLC.Lists[l].elementValues   = new SortedList <int, SortedList <int, object> >();
                                eLC.Lists[l].elementPosition = new SortedList <int, int>();

                                for (int e = 0; e < (tryparse3 && countx > 0 ? countx : 999999); e++)
                                {
                                    eLC.Lists[l].elementValues[e] = new SortedList <int, object>();
                                    Application.DoEvents();
                                    Progress_bar("Read :" + e + "/" + 99999, e, 99999);
                                    try
                                    {
                                        for (int f = 0; f < eLC.Lists[l].elementTypes.Length; f++)
                                        {
                                            eLC.Lists[l].elementValues[e][f] = eLC.ReadValue(br, eLC.Lists[l].elementTypes[f]);

                                            if (eLC.Lists[l].elementFields[f] == "Name")
                                            {
                                                int  id         = Int32.Parse(eLC.Lists[l].elementValues[e][0].ToString());
                                                bool isNegative = (id & (1 << 31)) != 0;
                                                if (isNegative)
                                                {
                                                    break;
                                                }
                                                listBox_items.Rows.Add(new object[] { id.ToString(), eLC.Lists[l].GetValue(e, f) });



                                                if (checkBox1.Checked)
                                                {
                                                    Application.DoEvents();
                                                    listBox_items.Rows[e].Selected = true;
                                                    listBox_items.CurrentCell      = listBox_items.Rows[e].Cells[0];
                                                }
                                            }
                                        }

                                        eLC.Lists[l].elementPosition[e] = (Int32)br.BaseStream.Position;
                                        textBox5.Text = eLC.Lists[l].elementPosition[e].ToString("X4").ToUpper();
                                    }
                                    catch
                                    {
                                        break;
                                    }

                                    if (BrakeReading)
                                    {
                                        break;
                                    }
                                }
                            }

                            BrakeReading = false;
                            Blocked      = false;
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }
        }