예제 #1
0
        private void ReplaceFromFile(bool cpuData, bool gpuData)
        {
            int    entryIndex  = int.Parse(listView1.FocusedItem.SubItems[0].Text);
            string cpuDataPath = null;
            string gpuDataPath = null;

            using (OpenFileDialog fileDialog = new OpenFileDialog()
            {
                Multiselect = false, InitialDirectory = lastDataOpenPath
            })
            {
                if (cpuData)
                {
                    fileDialog.Title = "Select CPU data file";
                    if (fileDialog.ShowDialog() == DialogResult.OK)
                    {
                        cpuDataPath = fileDialog.FileName;
                    }
                    else
                    {
                        return;
                    }
                }
                if (gpuData)
                {
                    fileDialog.Title = "Select GPU data file";
                    if (fileDialog.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    gpuDataPath = fileDialog.FileName;
                }

                CpuFile tmpCpuFile = null;
                if (cpuData)
                {
                    tmpCpuFile = new CpuFile(cpuDataPath); // Read in data to find how many entries it contains
                    cpuFile.ReplaceCpuData(entryIndex, tmpCpuFile.msCpuFile, updateHeader: tmpCpuFile.Count == 1);
                }
                if (gpuData)
                {
                    cpuFile.ReplaceGpuData(entryIndex, gpuDataPath, updateHeader: tmpCpuFile == null || tmpCpuFile.Count == 1);
                }

                cpuFile.Reload();
                if (cpuData)
                {
                    RefreshCpuEntryList();
                    RefreshEntryStatus();
                    RefreshDataTypeChoices();
                }
                RefreshDetailsText();
                button3.Enabled  = true;
                lastDataOpenPath = Path.GetDirectoryName(fileDialog.FileName);
            }
        }
예제 #2
0
        private void insertDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int entryIndex = int.Parse(listView1.FocusedItem.SubItems[0].Text);

            using (OpenFileDialog fileDialog = new OpenFileDialog()
            {
                Multiselect = false, InitialDirectory = lastDataOpenPath
            })
            {
                CpuFile tmpCpuFile;
                fileDialog.Title = "Select CPU data file";
                if (fileDialog.ShowDialog() == DialogResult.OK)
                {
                    tmpCpuFile = new CpuFile(fileDialog.FileName);
                }
                else
                {
                    return;
                }
                Asset lastEntry = tmpCpuFile.entriesList.Last();
                if (lastEntry.gpuOffsetData + lastEntry.gpuRelativeOffsetNextEntry > 0)
                {
                    fileDialog.Title = "Select GPU data file";
                    if (fileDialog.ShowDialog() != DialogResult.OK)
                    {
                        return;
                    }
                    cpuFile.InsertCpuData(entryIndex, tmpCpuFile.msCpuFile);
                    int length = cpuFile.InsertGpuData(entryIndex, fileDialog.FileName);
                    if (tmpCpuFile.Count == 1)
                    {
                        cpuFile.ChangeGpuDataInfo(entryIndex, length, length);
                    }
                }
                else
                {
                    cpuFile.InsertCpuData(entryIndex, tmpCpuFile.msCpuFile);
                }

                cpuFile.Reload();
                RefreshCpuEntryList();
                RefreshEntryStatus();
                RefreshDataTypeChoices();
                RefreshDetailsText();
                button3.Enabled  = true;
                lastDataOpenPath = Path.GetDirectoryName(fileDialog.FileName);
            }
        }
예제 #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog fileDialog = new OpenFileDialog()
     {
         Filter = "CPU Files|*.cpu.***", Multiselect = false, Title = "Select a CPU file", InitialDirectory = lastCpuFilePath
     })
     {
         if (fileDialog.ShowDialog() == DialogResult.OK)
         {
             cpuFile = new CpuFile(fileDialog.FileName);
             toolStripStatusLabel1.Text = string.Format("Current file: {0} (Sumo tool v{2}, {1}-endian)", fileDialog.FileName, cpuFile.isLittleEndian ? "Little" : "Big", cpuFile[1].toolVersion);
             RefreshCpuEntryList();
             RefreshEntryStatus();
             RefreshDetailsText();
             RefreshDataTypeChoices();
             lastCpuFilePath = Path.GetDirectoryName(fileDialog.FileName);
             button2.Enabled = button4.Enabled = textBox1.Enabled = comboBox1.Enabled = true;
             button3.Enabled = false;
         }
     }
 }