示例#1
0
文件: BnkForm.cs 项目: djey47/tdumt2
        private void extractAllButton_Click(object sender, EventArgs e)
        {
            if (_Bank != null)
            {
                try
                {
                    // All items selected
                    contentsLst.SelectedIndices.Clear();

                    for (int i = 0; i < contentsLst.Items.Count; i++)
                    {
                        contentsLst.SelectedIndices.Add(i);
                    }

                    _ExtractSelectedFiles();

                    MessageBox.Show(this, "Unpack Everything Succeeded!");
                }
                catch (Exception ex)
                {
                    _Log.Error(FailureHandler.GetStackTrace(ex));
                    MessageBox.Show(this, ex.Message);
                }
            }
        }
示例#2
0
文件: BnkForm.cs 项目: djey47/tdumt2
        private void loadBtn_Click(object sender, EventArgs ea)
        {
            try
            {
                if (string.IsNullOrEmpty(fileTxt.Text))
                {
                    throw new Exception("A Bnk file is required.");
                }

                Cursor = Cursors.WaitCursor;

                // File loading
                _LoadBnk(fileTxt.Text);

                // Updates bnk contents
                _UpdateList();

                // Updates info labels
                _UpdateBnkInfo();
                _UpdatePackedInfo();
            }
            catch (Exception e)
            {
                _Log.Error(FailureHandler.GetStackTrace(e));
                MessageBox.Show(this, e.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
示例#3
0
        public void GetStackTraceTest()
        {
            Exception ex     = new Exception();
            string    actual = FailureHandler.GetStackTrace(ex);

            Assert.IsFalse(string.IsNullOrEmpty(actual));
        }
示例#4
0
文件: XmbForm.cs 项目: djey47/tdumt2
        private void loadBtn_Click(object sender, EventArgs ea)
        {
            try
            {
                if (string.IsNullOrEmpty(fileTxt.Text))
                {
                    throw new Exception("A Xmb file is required.");
                }

                Cursor = Cursors.WaitCursor;

                // File loading
                _CurrentVolumeEntry = new Xmb.VolumeEntry();
                _LoadXmb(fileTxt.Text);

                // Updates info labels
                _UpdateXmbInfo();
                _UpdateInstructions();
            }
            catch (Exception e)
            {
                _Log.Error(FailureHandler.GetStackTrace(e));
                MessageBox.Show(this, e.Message);
            }
            finally
            {
                Cursor = Cursors.Default;
            }
        }
示例#5
0
文件: BnkForm.cs 项目: djey47/tdumt2
        private void repackBtn_Click(object sender, EventArgs ea)
        {
            if (_Bank != null)
            {
                folderBrowserDlg.Description = "Select a directory to repack...";

                DialogResult dr = folderBrowserDlg.ShowDialog(this);

                if (dr == DialogResult.OK)
                {
                    string   bnkDir         = folderBrowserDlg.SelectedPath;
                    string[] splittedPath   = bnkDir.Split('\\');
                    string   bnkDefaultName = splittedPath[splittedPath.Length - 1];

                    // Target BNK selection
                    saveFileDialog.Filter   = "TDU banks (*.bnk)|*.bnk";
                    saveFileDialog.Title    = "Repack to BNK file...";
                    saveFileDialog.FileName = bnkDefaultName;

                    dr = saveFileDialog.ShowDialog(this);

                    if (dr == DialogResult.OK)
                    {
                        try
                        {
                            Cursor = Cursors.WaitCursor;

                            // Updates Bnk contents
                            _Bank.Repack(bnkDir);
                            // Commit to disk
                            _Bank.SaveAs(saveFileDialog.FileName);
                            // Reloads current file
                            _Bank.Read();

                            MessageBox.Show(this, "Repack Succeeded!");
                        }
                        catch (Exception e)
                        {
                            _Log.Error(FailureHandler.GetStackTrace(e));
                            MessageBox.Show(this, e.Message);
                        }
                        finally
                        {
                            Cursor = Cursors.Default;
                        }
                    }
                }
            }
        }
示例#6
0
文件: BnkForm.cs 项目: djey47/tdumt2
 private void openDirBtn_Click(object sender, EventArgs ea)
 {
     if (!string.IsNullOrEmpty(wDirTxt.Text))
     {
         try
         {
             Process.Start(wDirTxt.Text);
         }
         catch (Exception e)
         {
             _Log.Error(FailureHandler.GetStackTrace(e));
             MessageBox.Show(this, e.Message);
         }
     }
 }
示例#7
0
        public void HandleTest2()
        {
            // Failure report
            try
            {
                new ExceptionGenerator().NullPointer();
            }
            catch (Exception ex)
            {
                // Critical exception catched here
                FailureHandler.Handle("TEST_APP", ex);

                logger.Error(FailureHandler.GetStackTrace(ex));
            }
        }
示例#8
0
文件: BnkForm.cs 项目: djey47/tdumt2
        private void dumpButton_Click(object sender, EventArgs e)
        {
            if (_Bank != null)
            {
                try
                {
                    Cursor = Cursors.WaitCursor;

                    _Bank.Dump();
                    MessageBox.Show(this, "BNK now dumped. Have a look at corresponding log file (DjeLib-dump.log).");
                }
                catch (Exception ex)
                {
                    _Log.Error(FailureHandler.GetStackTrace(ex));
                    MessageBox.Show(this, ex.Message);
                }
                finally
                {
                    Cursor = Cursors.Default;
                }
            }
        }
示例#9
0
文件: BnkForm.cs 项目: djey47/tdumt2
        private void extractBtn_Click(object sender, EventArgs ea)
        {
            if (_Bank != null)
            {
                try
                {
                    if (contentsLst.SelectedIndices.Count == 0)
                    {
                        throw new Exception("At least 1 packed file must be selected for extraction.");
                    }

                    _ExtractSelectedFiles();


                    MessageBox.Show(this, "Unpack Succeeded!");
                }
                catch (Exception e)
                {
                    _Log.Error(FailureHandler.GetStackTrace(e));
                    MessageBox.Show(this, e.Message);
                }
            }
        }