📄 form1.cs
字号:
this.involume.Minimum = indtl.Min;
this.involume.Maximum = indtl.Max;
this.involume.Value = this.indtl.Volume;
wf = new WAVEFORMATEX();
wf.cbSize = 0;
wf.nChannels = 1;
wf.nSamplesPerSec = 8000;
wf.wBitsPerSample = 16;
wf.nBlockAlign = 2;
wf.nAvgBytesPerSec = 16000;
wf.wFormatTag = 1;//pcm
wo = new WaveOut(this.cbwaveOut.SelectedIndex, wf, 1600, 20);
wo.WaveOutError += new WaveErrorEventHandler(wo_WaveOutError);
this.wo.Start();
wi = new WaveIn(this.cbwaveIn.SelectedIndex, wf, 1600, 20);
wi.WaveInError += new WaveErrorEventHandler(wi_WaveInError);
wi.WaveCaptured += new WaveBufferEventHandler(wi_WaveCaptured);
this.wi.Start();
}
catch (Exception ex)
{
MessageBox.Show("ZX Messenger AVPhone 初始化遇到一个错误,该错误可能导致本插件不可用。\n 错误描述:" + ex.Message,
"ZX Messenger AVPhone", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
return;
string[] ss=System.IO.Directory.GetFiles(@"C:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\gowk\bin\skins\default\新建文件夹");
foreach(string f in ss)
{
string ex=System.IO.Path.GetExtension(f);
if(ex!=".png")continue;
Bitmap bm=new Bitmap(f,false);
int w=(int)(bm.Width /2);
int h=(int)(bm.Height /2);
if(h<1)h=1;if(w<1)w=1;
Image img=bm.GetThumbnailImage(w,h,null,IntPtr.Zero);
//pre_av.ConnectDevice();
string f2=(string)f.Clone();
f2=f2.Replace("\\新建文件夹","");
try
{
if(System.IO.File.Exists(f2))System.IO.File.Delete(f2);
}
catch(System.Exception eex)
{
MessageBox.Show(eex.Message);
}
img.Save(f2,System.Drawing.Imaging.ImageFormat.Png);
}
* */
}
void wi_WaveCaptured(object sender, WAVEHDR hdr)
{
try
{
//throw new Exception("The method or operation is not implemented.");
byte[] data = new byte[hdr.dwBytesRecorded];
System.Runtime.InteropServices.Marshal.Copy(hdr.lpData, data, 0, data.Length);
gowk.multimedia.UT.LowPassWave(this.wf, data, 0, 5000);
this.wo.Write(data);
Bitmap bm = new Bitmap(this.pictureBox2.Width, this.pictureBox2.Height);
Graphics g = Graphics.FromImage(bm);
// g.Clear(Color.White);
Pen pen = new Pen(this.ForeColor);
int xi = (int)(this.pictureBox2.Width * 16 / data.Length);
int ys = (int)(this.pictureBox2.Height / 2);
int h = this.pictureBox2.Height;
int x = -xi, y = ys, x2, y2;
if (xi < 1) xi = 1;
for (int i = 0; i < data.Length; i += 16)
{
x2 = x + xi;
y2 = ys + (int)(System.BitConverter.ToInt16(data, i) / h);
g.DrawLine(pen, x, y, x2, y2);
x = x2;
y = y2;
}
g.Dispose();
this.pictureBox2.BackgroundImage = bm;
}
catch
{
}
}
void wi_WaveInError(object sender, MultimediaException e)
{
//throw new Exception("The method or operation is not implemented.");
Debug.Print("wave in error " + e.Message);
}
void wo_WaveOutError(object sender, MultimediaException e)
{
//throw new Exception("The method or operation is not implemented.");
Debug.Print("wave out error "+e.Message);
}
void mixer_MixerControlChange(object sender, EventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
try
{
SyncVolumn();
}
catch
{
}
}
private void SyncVolumn()
{
this.involume.Value = this.indtl.Volume;
this.outvolume.Value = this.outdtl.Volume;
}
private void button3_Click(object sender, EventArgs e)
{
//se.ShowFormat();
av.ShowFormat();
Application.DoEvents();
BITMAPINFO bni;
bni = av.vc_BITMAPINFO;
bni.bmiHeader.biWidth = 176;
bni.bmiHeader.biHeight = 144;
bni.bmiHeader.biBitCount = 24;
bni.bmiHeader.biPlanes = 1;
bni.bmiHeader.biSizeImage = 76032;
av.vc_BITMAPINFO = bni;
}
void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
try
{
//se.Dispose();
if (av != null)
{
if (av.Chanel.Connected)
{
av.Chanel.Disconnect();
}
av.Dispose();
}
wi.Stop();
wo.Stop();
mixer.Close();
}
catch (Exception ex)
{
Debug.Print(ex.Message);
}
if (canExit)
{
Application.Exit();
}
}
private void button6_Click(object sender, EventArgs e)
{
//se.ShowSource();
av.ShowSource();
}
private void button7_Click(object sender, EventArgs e)
{
canExit = true;
this.Close();
}
private void tmrRefresh_Tick(object sender, EventArgs e)
{
/*try
{
if (se.GetBitmapHeight() != 0 && se.GetBitmapWidth() != 0)
{
this.pictureBox1.Width = se.GetBitmapWidth();
this.pictureBox1.Height = se.GetBitmapHeight();
}
}
catch (Exception ex)
{
Debug.Print(ex.Message);
}*/
if (av.HasCam)
{
if (!av.HasEncoder)
{
pictureBox3.Image = avt.Properties.Resources.stop;
label8.Text = "编码器不可用!";
label9.Text = "您的编码器不可用。它可能没有正确安装,请重新安装 ZX Messenger。否则对方" +
"无法看到您的图像。";
}
if (!av.HasDecoder)
{
pictureBox1.Image = avt.Properties.Resources.stop;
label3.Text = "解码器不可用!";
label6.Text = "您的解码器不可用。它可能没有正确安装,请重新安装 ZX Messenger。否则您" +
"无法看到对方的图像。";
label7.Visible = false;
pictureBox1.Refresh();
}
}
else
{
pictureBox3.Image = avt.Properties.Resources.stop;
pictureBox1.Image = avt.Properties.Resources.stop;
label8.Text = label3.Text="摄像头不存在。";
label9.Text = label6.Text = "摄像头不存在或没有正确安装或不支持所需要的格式,对方无法看到您的视频。";
}
}
void involume_MouseUp(object sender, MouseEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
if (e.X < 0 || e.X > this.involume.Width) return;
int v = (int)(e.X * this.involume.Maximum / this.involume.Width);
this.indtl.Volume = v;
this.involume.Value = this.indtl.Volume;
}
void involume_MouseMove(object sender, MouseEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
if (this.involume.Capture) involume_MouseUp(sender, e);
}
void outvolume_MouseUp(object sender, MouseEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
if (e.X < 0 || e.X > this.outvolume.Width) return;
int v = (int)(e.X * this.outvolume.Maximum / this.outvolume.Width);
this.outdtl.Volume = v;
this.outvolume.Value = this.outdtl.Volume;
}
void outvolume_MouseMove(object sender, MouseEventArgs e)
{
//throw new Exception("The method or operation is not implemented.");
if (this.outvolume.Capture) outvolume_MouseUp(sender, e);
}
private void button1_Click(object sender, EventArgs e)
{
canExit = false;
this.Close();
//Application.DoEvents();
frmChat chat = new frmChat();
chat.Show();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -