using System.Globalization; using System.Text; namespace RoboSpot_RSL_Editor { public partial class MainForm : Form { public MainForm() { InitializeComponent(); } private void btnLoadShowFile_Click(object sender, EventArgs e) { if (dlgOpenRSL.ShowDialog() == DialogResult.OK) { clearUI(); FileStream fs = new FileStream(dlgOpenRSL.FileName, FileMode.Open); List showfileContents = new List(); int hexIn; for (int i = 0; (hexIn = fs.ReadByte()) != -1; i++) { String hex = string.Format("{0:X2}", hexIn); showfileContents.Add(hex); } fs.Close(); String[] lines = showfileContents.ToArray(); if (lines.Length == 43438) { if (lines[0] != "02") { DialogResult result = MessageBox.Show("File header seems incorrect. Still try read the showfile ?", "Header incorrect", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { processFile(lines); } } else { processFile(lines); } } else { DialogResult result = MessageBox.Show("File size seems incorrect. Still try read the showfile ?", "Size incorrect", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { processFile(lines); } } } } private String rawToString(string input) { int value = Convert.ToInt32(input, 16); char charValue = (char)value; return charValue.ToString(); } private void clearUI() { txtCamIP.Clear(); listAllShowfiles.Items.Clear(); txtShowVersion.Clear(); this.Text = Application.ProductName; chkPosBtnShown.Checked = false; chkPosShowInScene.Checked = false; chkColorBtnShown.Checked = false; chkTargetCrossShown.Checked = false; chkTraceCursor.Checked = false; chkTracePanInvert.Checked = false; chkTraceTiltInvert.Checked = false; txtTraceType.Clear(); txtExportedFilename.Clear(); chkDmxDimmersShown.Checked = false; } private void btnClearUI_Click(object sender, EventArgs e) { clearUI(); } private void processFile(string[] input) { List all_showfile_chars_as_string = new List(); foreach (string hx in input[58..71]) { txtCamIP.AppendText(rawToString(hx)); } foreach (string hx in input[32812..32971]) { string value; if (hx == "00") { value = rawToString("20"); } else { value = rawToString(hx); } all_showfile_chars_as_string.Add(value); } if (input[2722].ToString() == "01") { chkPosBtnShown.Checked = true; } if (input[32976].ToString() == "01") { chkColorBtnShown.Checked = true; } if (input[32780].ToString() == "01") { chkTargetCrossShown.Checked = true; } if (input[2622].ToString() == "01") { chkTraceCursor.Checked = true; } if (input[2723].ToString() == "01") { chkPosShowInScene.Checked = true; } if (input[2623].ToString() == "01") { chkTracePanInvert.Checked = true; } if (input[2624].ToString() == "01") { chkTraceTiltInvert.Checked = true; } if (input[33248].ToString() == "01") { chkDmxDimmersShown.Checked = true; } if (input[2626].ToString() == "E7") { txtTraceType.AppendText("CAMERA"); } else { txtTraceType.AppendText("FOLLOWSPOT"); } foreach (string hx in input[31712..31742]) { txtExportedFilename.AppendText(rawToString(hx)); } string all_showfiles = String.Join("", all_showfile_chars_as_string); this.Text = Application.ProductName + " - " + dlgOpenRSL.FileName; txtShowVersion.AppendText(input[2]); for (int i = 0; i < 10; i++) { string showfile = all_showfiles.Substring(i * 16, 15); listAllShowfiles.Items.Add(showfile); } } } }