Beispiel #1
0
        private void closeB_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to close the current file?", "Close - Confirm", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                return;
            this.ClearItems();
            this.itemView.Enabled = false;
            this.closeB.Enabled = false;
            this.saveCurrentB.Enabled = false;
            this.saveNewB.Enabled = false;
            this.exportB.Enabled = false;
            this.Text = "VPC GXT2 Editor";
            IsNewFile = false;
            this.currentFileName = string.Empty;
            if (MainGXTStream != null)
            {
                try
                {
                    this.MainGXTStream.Close();
                    this.MainGXTStream = null;
                }
                catch
                {

                }
            }
            this.MainGXTFile = null;
        }
Beispiel #2
0
 private void CloseFile()
 {
     ClearItems();
     itemView.Enabled = false;
     closeB.Enabled = false;
     exportB.Enabled = false;
     MainGXTFile = null;
     MainGXTStream.Close();
     MainGXTStream = null;
 }
Beispiel #3
0
 private void saveNewB_Click(object sender, EventArgs e)
 {
     SaveFileDialog SFD = new SaveFileDialog();
     SFD.Title = "Choose output file...";
     SFD.Filter = "|*.gxt2";
     if (SFD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         this.MainGXTStream = File.Create(SFD.FileName);
         this.MainGXTFile = new GXT2();
         foreach (BetterListViewItem blvi in this.itemView)
         {
             if (blvi.Text.StartsWith("0x"))
             {
                 uint hash = uint.Parse(blvi.Text.Substring(2), System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture);
                 this.MainGXTFile.AddStringItem(hash, blvi.SubItems[1].Text);
             }
             else
                 this.MainGXTFile.AddStringItem(blvi.Text, blvi.SubItems[1].Text);
         }
         this.MainGXTFile.WriteToStream(MainGXTStream);
         IsNewFile = false;
         exportB.Enabled = true;
         saveCurrentB.Enabled = true;
         saveNewB.Enabled = true;
         closeB.Enabled = true;
         MessageBox.Show("File Written!", "File Write - Success", MessageBoxButtons.OK);
     }
 }
Beispiel #4
0
        private void saveCurrentB_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you would like to overwrite the current file?", "Overwrite - Confirm", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
                return;
            MainGXTStream.SetLength(0);

            this.MainGXTFile = new GXT2();
            foreach (BetterListViewItem blvi in this.itemView)
            {
                if (blvi.Text.StartsWith("0x"))
                {
                    uint hash = uint.Parse(blvi.Text.Substring(2), System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture);
                    this.MainGXTFile.AddStringItem(hash, blvi.SubItems[1].Text);
                }
                else
                    this.MainGXTFile.AddStringItem(blvi.Text, blvi.SubItems[1].Text);
            }
            this.MainGXTFile.WriteToStream(MainGXTStream);
            ClearItems();
            LoadItems();
            MessageBox.Show("File Written!", "File Write - Success", MessageBoxButtons.OK);
        }
Beispiel #5
0
        private void OpenGXT(string fileName)
        {
            Stream xIn = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);

            this.MainGXTStream = xIn;
            this.MainGXTFile = new GXT2(xIn);

            LoadItems();

            closeB.Enabled = true;
            IsNewFile = false;
            saveCurrentB.Enabled = true;
            saveNewB.Enabled = true;
            exportB.Enabled = true;

            currentFileName = System.IO.Path.GetFileName(fileName);
            this.Text = string.Format("VPC GXT2 Editor - {0}", currentFileName);
        }
Beispiel #6
0
        private void newB_Click(object sender, EventArgs e)
        {
            IsNewFile = true;
            ClearItems();
            itemView.Enabled = true;
            MainGXTFile = null;
            MainGXTStream = null;
            saveCurrentB.Enabled = false;
            saveNewB.Enabled = false;
            closeB.Enabled = true;
            exportB.Enabled = false;
            this.Text = "VPC GXT2 Editor";
            this.currentFileName = string.Empty;
            if (MainGXTStream != null)
            {
                try
                {
                    this.MainGXTStream.Close();
                    this.MainGXTStream = null;

                }
                catch
                {

                }
            }
            this.MainGXTFile = null;
        }
Beispiel #7
0
        private void importCsv(string fileName)
        {
            try
            {
                MainGXTFile = new GXT2();
                MainGXTStream = null;

                var dictionary = CSV.ReadCSV(fileName);

                if (dictionary == null)
                {
                    MessageBox.Show("the CSV is Empty!", "File Read - Failure", MessageBoxButtons.OK);
                    return;
                }

                foreach (var GxtEntry in dictionary)
                {
                    MainGXTFile.AddStringItem(GxtEntry.Key, GxtEntry.Value);
                }

                LoadItems();

                closeB.Enabled = true;
                IsNewFile = false;
                saveCurrentB.Enabled = true;
                saveNewB.Enabled = true;
                exportB.Enabled = true;

                currentFileName = System.IO.Path.GetFileName(fileName);
                this.Text = string.Format("VPC GXT2 Editor - {0}", currentFileName);
            }
            catch (IOException)
            {
                MessageBox.Show("Unable to Read the CSV!", "File Read - Failure", MessageBoxButtons.OK);
            }
            catch (CsvMissingFieldException)
            {
                MessageBox.Show("invalid CSV has been loaded!", "File Read - Failure", MessageBoxButtons.OK);
            }
        }