📄 bytelistdialog.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace MPEGBuilder1UI
{
/// <summary>
/// Summary description for ByteListDialog.
/// </summary>
public class ByteListDialog : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public ByteListDialog()
{
InitializeComponent();
}
public ByteListDialog(byte[] bits, int length)
{
// Format bits[] array into bytes and write into list box
InitializeComponent();
int i, j;
int tempint;
int nbytes, nremainder;
double compress;
nbytes = length/8;
nremainder = length%8;
if (nbytes > 0)
listBox1.Items.Add("Bytes:");
for (i=0; i<nbytes; i++)
{
tempint = 0;
for (j=0; j<8; j++)
{
tempint = tempint*2 + bits[i*8 + j];
}
listBox1.Items.Add("0x" + tempint.ToString("X2"));
}
if (nremainder>0)
listBox1.Items.Add("Leftover Bits:");
for (i=nbytes*8; i<length; i++)
listBox1.Items.Add(bits[i].ToString());
textBox1.Text = length.ToString();
compress = 100.0 - ((double) length / 64.0 / 9.0 * 100.0);
textBox2.Text = compress.ToString("f");
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.textBox2 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(48, 280);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 32);
this.button1.TabIndex = 0;
this.button1.Text = "Close";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// listBox1
//
this.listBox1.Location = new System.Drawing.Point(16, 40);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(144, 212);
this.listBox1.TabIndex = 1;
//
// label1
//
this.label1.Location = new System.Drawing.Point(24, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(128, 23);
this.label1.TabIndex = 2;
this.label1.Text = "Encoded AC Values";
//
// label2
//
this.label2.Location = new System.Drawing.Point(184, 16);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(56, 16);
this.label2.TabIndex = 3;
this.label2.Text = "Total Bits";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(180, 40);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(64, 20);
this.textBox1.TabIndex = 4;
this.textBox1.Text = "textBox1";
//
// label3
//
this.label3.Location = new System.Drawing.Point(176, 96);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 32);
this.label3.TabIndex = 5;
this.label3.Text = "Percent Compression";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(176, 136);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(72, 20);
this.textBox2.TabIndex = 6;
this.textBox2.Text = "textBox2";
//
// ByteListDialog
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(256, 333);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.textBox2,
this.label3,
this.textBox1,
this.label2,
this.label1,
this.listBox1,
this.button1});
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ByteListDialog";
this.Text = "ByteListDialog";
this.ResumeLayout(false);
}
#endregion
private void button1_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -