/// <summary>
        /// The code that stringifies build information and update the UI so it's displayed in the dialog.
        /// </summary>
        /// <param name="build">The WebTVBuildInfo object that contains the header information from the build.</param>
        /// <param name="pane_prefix">The prefix to use when looking up UI objects.  This is only useful if you have multiple panes of build information in one dialog.</param>
        /// <param name="filename">The full file path to the build image.</param>
        /// <param name="file_size_bytes">The size of the build image file.</param>
        /// <param name="file_offset_bytes">The offset within the build image file that the first byte of the build is located.  Useful if using disk image files.</param>
        /// <param name="collation">The format (byte-swap type) of the build image file.</param>
        public void style_build_pane(WebTVBuildInfo build, string pane_prefix, string filename = "", ulong file_size_bytes = 0, ulong file_offset_bytes = 0, DiskByteTransform collation = DiskByteTransform.NOSWAP)
        {
            reset_build_page(pane_prefix);

            var build_header = build.get_build_info();
            this.calculated_romfs_checksum = 0;
            this.calculated_code_checksum = 0;

            if (pane_prefix == "new")
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_file_path")).Text = filename;
                ((TextBox)this.main_window.FindName(pane_prefix + "_file_size")).Text = BytesToString.bytes_to_iec(file_size_bytes);

                var collation_description = "";
                switch (collation)
                {
                    case DiskByteTransform.BIT16SWAP:
                        collation_description = "16-bit swapped";
                        break;

                    case DiskByteTransform.BIT1632SWAP:
                        collation_description = "16+32-bit swapped";
                        break;

                    case DiskByteTransform.BIT32SWAP:
                        collation_description = "32-bit swapped";
                        break;

                    case DiskByteTransform.NOSWAP:
                    default:
                        collation_description = "no swapping";
                        break;
                }

                ((TextBox)this.main_window.FindName(pane_prefix + "_build_collation")).Text = collation_description;
            }

            var build_flags = new List<string>();

            if ((build_header.build_flags & 0x04) != 0)
            {
                build_flags.Add("Debug");
            }
            if ((build_header.build_flags & 0x20) != 0)
            {
                build_flags.Add("Satellite?");
            }
            if ((build_header.build_flags & 0x10) != 0)
            {
                build_flags.Add("Windows CE?");
            }
            if ((build_header.build_flags & 0x01) != 0)
            {
                build_flags.Add("Compressed Heap Data");
            }
            else
            {
                build_flags.Add("Raw Heap Data");
            }

            if (build_flags.Count > 0)
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_flags")).Text = String.Join(", ", build_flags);
            }
            else
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_flags")).Text = "-";
            }

            if (!build_header.is_classic_build && build_header.build_number > 0 && build_header.dword_code_length > 0 && build_header.jump_offset > 4)
            {
                this.calculated_code_checksum = build.calculate_code_checksum();
            }
            else if (pane_prefix == "new")
            {
                ((CheckBox)this.main_window.FindName(pane_prefix + "_build_use_calculated_code_checksum")).IsChecked = false;
                ((CheckBox)this.main_window.FindName(pane_prefix + "_build_use_calculated_romfs_checksum")).IsChecked = false;
            }

            if (build_header.build_number == 0)
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_number")).Text = "?";
            }
            else
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_number")).Text = build_header.build_number.ToString();
            }

            if (build_header.is_classic_build)
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_code_checksum")).Text = "Classic build?";
            }
            else
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_code_checksum")).Text = build_header.code_checksum.ToString("X");

                if (build_header.jump_offset > 4 && this.calculated_code_checksum != build_header.code_checksum)
                {
                    ((TextBox)this.main_window.FindName(pane_prefix + "_build_code_checksum")).Foreground = Brushes.Red;
                }
            }

            if (build_header.jump_offset == 4)
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_calculated_code_checksum")).Text = "Compressed build?";
            }
            else
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_calculated_code_checksum")).Text = this.calculated_code_checksum.ToString("X");
            }

            if (build_header.is_classic_build || build_header.dword_length == 0)
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_length")).Text = "?";
            }
            else
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_length")).Text = this.get_size_string(build_header.dword_length);
            }

            if (build_header.is_classic_build || build_header.dword_code_length == 0)
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_code_length")).Text = "?";
            }
            else
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_code_length")).Text = this.get_size_string(build_header.dword_code_length);
            }

            ((TextBox)this.main_window.FindName(pane_prefix + "_build_jump_offset")).Text = this.get_offset_string((build_header.build_base_address + build_header.jump_offset), build_header.build_base_address, file_offset_bytes);

            ((TextBox)this.main_window.FindName(pane_prefix + "_build_base")).Text = this.get_offset_string(build_header.build_base_address, build_header.build_base_address, file_offset_bytes);

            if (build_header.romfs_base_address == 0)
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_romfs_base")).Text = "No ROMFS";

                if (pane_prefix == "new")
                {
                    ((CheckBox)this.main_window.FindName(pane_prefix + "_build_use_calculated_romfs_checksum")).IsChecked = false;
                }
            }
            else if(!build_header.is_classic_build)
            {
                this.calculated_romfs_checksum = build.calculate_romfs_checksum();

                ((TextBox)this.main_window.FindName(pane_prefix + "_build_romfs_base")).Text = this.get_offset_string(build_header.romfs_base_address, build_header.build_base_address, file_offset_bytes);

                ((TextBox)this.main_window.FindName(pane_prefix + "_build_romfs_checksum")).Text = build_header.romfs_checksum.ToString("X");
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_calculated_romfs_checksum")).Text = this.calculated_romfs_checksum.ToString("X");
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_romfs_size")).Text = this.get_size_string(build_header.dword_romfs_size);

                if (this.calculated_romfs_checksum != build_header.romfs_checksum)
                {
                    ((TextBox)this.main_window.FindName(pane_prefix + "_build_romfs_checksum")).Foreground = Brushes.Red;
                }
            }

            if (!build_header.is_classic_build)
            {
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_heap_size")).Text = this.get_size_string(build_header.dword_heap_data_size + build_header.dword_heap_free_size);
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_heap_data_offset")).Text = this.get_offset_string(build_header.heap_data_address, build_header.build_base_address, file_offset_bytes);
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_heap_data_compressed_size")).Text = this.get_size_string(build_header.dword_heap_compressed_data_size);
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_heap_data_size")).Text = this.get_size_string(build_header.dword_heap_data_size);

                ((TextBox)this.main_window.FindName(pane_prefix + "_build_code_shrunk_offset")).Text = this.get_offset_string(build_header.code_compressed_address, build_header.build_base_address, file_offset_bytes);
                ((TextBox)this.main_window.FindName(pane_prefix + "_build_code_shrunk_size")).Text = this.get_size_string(build_header.dword_code_compressed_size);
            }
        }
        /// <summary>
        /// Fetches the build data from this.new_build_filename and displays it on the main_window.
        /// </summary>
        public void set_new_build_info()
        {
            if (this.new_build_filename != null && this.new_build_filename != "")
            {
                try
                {
                    var build = new WebTVBuildInfo(this.new_build_filename);

                    style_build_pane(build, "new", this.new_build_filename, (ulong)build.reader.Length, 0, build.byte_converter.byte_transform);

                    build.Close();
                }
                catch (Exception e)
                {
                    MessageBox.Show("Error! " + e.Message);
                }
            }
        }