📄 frmsoundconvert.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace SoundConvert
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class frmSoundConvert : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnConvertFile;
private System.Windows.Forms.TextBox txtSoundFile;
private System.Windows.Forms.Button btnBrowseFile;
private System.Windows.Forms.ComboBox cmbFileType;
private System.Windows.Forms.OpenFileDialog openFileDialog;
private AxWMPLib.AxWindowsMediaPlayer axWindowsMediaPlayer1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public frmSoundConvert()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmSoundConvert));
this.btnConvertFile = new System.Windows.Forms.Button();
this.txtSoundFile = new System.Windows.Forms.TextBox();
this.btnBrowseFile = new System.Windows.Forms.Button();
this.cmbFileType = new System.Windows.Forms.ComboBox();
this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
this.axWindowsMediaPlayer1 = new AxWMPLib.AxWindowsMediaPlayer();
((System.ComponentModel.ISupportInitialize)(this.axWindowsMediaPlayer1)).BeginInit();
this.SuspendLayout();
//
// btnConvertFile
//
this.btnConvertFile.Location = new System.Drawing.Point(128, 72);
this.btnConvertFile.Name = "btnConvertFile";
this.btnConvertFile.Size = new System.Drawing.Size(88, 23);
this.btnConvertFile.TabIndex = 0;
this.btnConvertFile.Text = "转换";
this.btnConvertFile.Click += new System.EventHandler(this.btnConvertFile_Click);
//
// txtSoundFile
//
this.txtSoundFile.Location = new System.Drawing.Point(24, 32);
this.txtSoundFile.Name = "txtSoundFile";
this.txtSoundFile.Size = new System.Drawing.Size(144, 21);
this.txtSoundFile.TabIndex = 1;
this.txtSoundFile.Text = "";
//
// btnBrowseFile
//
this.btnBrowseFile.Location = new System.Drawing.Point(182, 32);
this.btnBrowseFile.Name = "btnBrowseFile";
this.btnBrowseFile.Size = new System.Drawing.Size(40, 21);
this.btnBrowseFile.TabIndex = 2;
this.btnBrowseFile.Text = "...";
this.btnBrowseFile.Click += new System.EventHandler(this.btnBrowseFile_Click);
//
// cmbFileType
//
this.cmbFileType.Location = new System.Drawing.Point(232, 32);
this.cmbFileType.Name = "cmbFileType";
this.cmbFileType.Size = new System.Drawing.Size(64, 20);
this.cmbFileType.TabIndex = 3;
//
// axWindowsMediaPlayer1
//
this.axWindowsMediaPlayer1.Enabled = true;
this.axWindowsMediaPlayer1.Location = new System.Drawing.Point(224, 72);
this.axWindowsMediaPlayer1.Name = "axWindowsMediaPlayer1";
this.axWindowsMediaPlayer1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWindowsMediaPlayer1.OcxState")));
this.axWindowsMediaPlayer1.TabIndex = 4;
//
// frmSoundConvert
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(336, 117);
this.Controls.Add(this.axWindowsMediaPlayer1);
this.Controls.Add(this.cmbFileType);
this.Controls.Add(this.btnBrowseFile);
this.Controls.Add(this.txtSoundFile);
this.Controls.Add(this.btnConvertFile);
this.Name = "frmSoundConvert";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "音频转换";
this.Load += new System.EventHandler(this.frmSoundConvert_Load);
((System.ComponentModel.ISupportInitialize)(this.axWindowsMediaPlayer1)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmSoundConvert());
}
private void frmSoundConvert_Load(object sender, System.EventArgs e)
{
this.MaximizeBox=false;
this.cmbFileType.Items.Add("");
this.cmbFileType.Items.Add(".mp3");
this.cmbFileType.Items.Add(".wma");
this.cmbFileType.SelectedIndex=0;
}
private void btnBrowseFile_Click(object sender, System.EventArgs e)
{
if(this.openFileDialog.ShowDialog()==DialogResult.OK)
{
string name = System.IO.Path.GetFileName(this.openFileDialog.FileName);
this.txtSoundFile.Text = name;
}
}
private void btnConvertFile_Click(object sender, System.EventArgs e)
{
string file = this.txtSoundFile.Text.Trim();
string name = this.openFileDialog.FileName;
this.axWindowsMediaPlayer1.URL=name;
this.axWindowsMediaPlayer1.openPlayer(name);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -