Beispiel #1
0
        public void SaveActiveTable(bool IsQuickSave)
        {
            if (!IsQuickSave)
            {
                SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                saveFileDialog1.DefaultExt       = "act";
                saveFileDialog1.Title            = "Save ActiveTable File";
                saveFileDialog1.Filter           = "ACT files|*.act";
                saveFileDialog1.RestoreDirectory = true;

                if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    currentFilename = saveFileDialog1.FileName;
                }
                else
                {
                    return;
                }
            }

            ActiveTableObject act = new ActiveTableObject(ActiveTableGenerated);

            using (FileStream FS = File.Open(currentFilename, FileMode.OpenOrCreate))
            {
                XmlSerializer xs = new XmlSerializer(typeof(ActiveTableObject));
                //bformatter.Serialize(FS, act);
                xs.Serialize(FS, act);
                FS.Close();
            }
        }
Beispiel #2
0
        private void btnActiveTableLoad_Click(object sender, EventArgs e)
        {
            try
            {
                OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
                OpenFileDialog1.DefaultExt       = "act";
                OpenFileDialog1.Title            = "Open ActiveTable File";
                OpenFileDialog1.Filter           = "ACT files|*.act";
                OpenFileDialog1.RestoreDirectory = true;
                if (OpenFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    currentFilename = OpenFileDialog1.FileName.ToString();
                }
                else
                {
                    return;
                }

                using (FileStream FS = File.Open(currentFilename, FileMode.OpenOrCreate))
                {
                    XmlSerializer     xs  = new XmlSerializer(typeof(ActiveTableObject));
                    ActiveTableObject act = (ActiveTableObject)xs.Deserialize(FS);
                    FS.Close();
                    SetActiveTable(act);
                    ActLoadedFromFile = true;
                }
            }
            catch
            {
                MessageBox.Show($"The ACT xml file {currentFilename} could not be loaded.");
            }
        }
Beispiel #3
0
 public void SetActiveTable(ActiveTableObject act)
 {
     FirstInit              = true;
     ActiveTableGenerated   = act.Data;
     ActiveTableReady       = true;
     lbActiveTableSize.Text = "Active table size (0x" + ActiveTableGenerated.Length.ToString("X") + ")";
 }
Beispiel #4
0
        private void btnActiveTableAddFile_Click(object sender, EventArgs e)
        {
            try
            {
                string tempFilename;

                OpenFileDialog OpenFileDialog1 = new OpenFileDialog();
                OpenFileDialog1.DefaultExt       = "act";
                OpenFileDialog1.Title            = "Open ActiveTable File";
                OpenFileDialog1.Filter           = "ACT files|*.act";
                OpenFileDialog1.RestoreDirectory = true;
                if (OpenFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    tempFilename = OpenFileDialog1.FileName.ToString();
                }
                else
                {
                    return;
                }

                ActiveTableObject act = null;

                using (FileStream FS = File.Open(tempFilename, FileMode.OpenOrCreate))
                {
                    XmlSerializer xs = new XmlSerializer(typeof(ActiveTableObject));
                    act = (ActiveTableObject)xs.Deserialize(FS);
                    FS.Close();
                }
                long[] additiveActiveTable = act.Data;

                List <long> newActiveTable = new List <long>();


                foreach (long item in ActiveTableGenerated)
                {
                    if (additiveActiveTable.Contains(item))
                    {
                        newActiveTable.Add(item);
                    }
                }

                ActiveTableGenerated   = newActiveTable.ToArray();
                lbActiveTableSize.Text = "Active table size (0x" + ActiveTableGenerated.Length.ToString("X") + ")";
            }
            catch
            {
                MessageBox.Show($"Unable to add the active table! Are you sure an existing table was loaded?");
            }
        }