Beispiel #1
0
        public async void TS_Load_Data_Click(object sender, EventArgs e)
        {
            if (!structLoaded)
            {
                MessageBox.Show("You can not do that until a structure has been loaded!", "Structure Exception", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            dCore                  = new DataCore.Core(Encodings.GetByName(ts_enc_list.Text));
            Paths.Title            = "Select client data.000";
            Paths.DefaultDirectory = OPT.GetString("data.load.directory");
            string dataPath = Paths.FilePath;

            if (Paths.FileResult == DialogResult.OK)
            {
                lManager.Enter(Logs.Sender.RDB, Logs.Level.NOTICE, "RDB Tab: {0} attempting load file selection from index at path:\n\t- {1}", tManager.Text, dataPath);

                List <DataCore.Structures.IndexEntry> results = null;

                await Task.Run(() =>
                {
                    dCore.Load(dataPath);
                    results = dCore.GetEntriesByExtensions("rdb", "ref");
                });

                lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "File list retrived successfully!\n\t- Selections available: {0}", results.Count);

                using (Grimoire.GUI.ListSelect selectGUI = new GUI.ListSelect("Select RDB", results))
                {
                    selectGUI.FormClosing += (o, x) =>
                    {
                        if (selectGUI.DialogResult == DialogResult.OK)
                        {
                            string fileName = selectGUI.SelectedText;
                            DataCore.Structures.IndexEntry finalResult = results.Find(i => i.Name == fileName);
                            byte[] fileBytes = dCore.GetFileBytes(finalResult);

                            if (fileBytes.Length > 0)
                            {
                                load_file(fileName, fileBytes);
                            }
                        }
                        else
                        {
                            lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "User cancelled Data load on RDB Tab: {0}", tManager.Text);
                            return;
                        }
                    };
                    selectGUI.ShowDialog(Grimoire.GUI.Main.Instance);
                }
            }
        }
Beispiel #2
0
        private async void load_data_file(string filePath)
        {
            dCore = new DataCore.Core(Encodings.GetByName(ts_enc_list.Text));

            lManager.Enter(Logs.Sender.RDB, Logs.Level.NOTICE, "RDB Tab: {0} attempting load file selection from index at path:\n\t- {1}", tManager.Text, filePath);

            List <DataCore.Structures.IndexEntry> results = null;

            actionSW.Reset();
            actionSW.Start();

            await Task.Run(() =>
            {
                dCore.Load(filePath);
                results = dCore.GetEntriesByExtensions("rdb", "ref");
            });

            lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "File list retrived successfully! ({0}ms)\n\t- Selections available: {1}",
                           actionSW.ElapsedMilliseconds.ToString("D4"),
                           results.Count);

            using (Grimoire.GUI.ListSelect selectGUI = new GUI.ListSelect("Select RDB", results))
            {
                selectGUI.ShowDialog(Grimoire.GUI.Main.Instance);

                if (selectGUI.DialogResult == DialogResult.OK)
                {
                    string fileName = selectGUI.SelectedText;
                    DataCore.Structures.IndexEntry finalResult = results.Find(i => i.Name == fileName);
                    byte[] fileBytes = dCore.GetFileBytes(finalResult);

                    lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "User selected rdb: {0}", fileName);

                    if (fileBytes.Length > 0)
                    {
                        load_file(fileName, fileBytes);
                    }
                }
                else
                {
                    lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "User cancelled Data load on RDB Tab: {0}", tManager.Text);
                    return;
                }
            }
        }