📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Filter
{
public partial class Form1 : Form
{
double[] winit = new double[16] { 300000, 4096, //采样频率||采样点数
1000, 0.5, 2000, 0.5, //基带波1频率、幅度 基带波2 F/A
5000, 0, 7000, 0, 90000, 0, //基带波3 F/A 基带波4 F/A 基带波5 F/A
100000, 300000, 0.03, 5000}; //载波频率 跟随频率 跟随速度 低通频率
int num = 0, wave = 0; //NUM是按键号 WAVE是波形号
bool heng; //表示是纵向调整还是横,纵是FALSE,横是TRUE
double X1 = 1, Y1 = 1, X2 = 1, Y2 = 1, X3 = 1,
Y3 = 1, X4 = 1, Y4 = 1, X5 = 1, Y5 = 1; //放大倍数X1是波形一的横坐标
int N = 256;
Graphics g;
public Form1()
{
InitializeComponent();
ShowWave();
}
private void pictureBox3_Click(object sender, EventArgs e)
{
num = 3;
pictureBox3.Hide();
timer1.Enabled = true;
}
private void pictureBox4_Click(object sender, EventArgs e)
{
num = 4;
pictureBox4.Hide();
timer1.Enabled = true;
}
private void pictureBox5_Click(object sender, EventArgs e)
{
Form form2 = new Form2(winit);
if (form2.ShowDialog() == DialogResult.Cancel)
{
this.Activate();
timer2.Enabled = true;
}
}
private void pictureBox6_Click(object sender, EventArgs e)
{
pictureBox6.Hide();
this.Close();
}
private void pictureBox7_Click(object sender, EventArgs e)
{
num = 7;
pictureBox7.Hide();
timer1.Enabled = true;
}
private void pictureBox8_Click(object sender, EventArgs e)
{
num = 8;
pictureBox8.Hide();
timer1.Enabled = true;
}
private void pictureBox9_Click(object sender, EventArgs e)
{
num = 9;
pictureBox9.Hide();
timer1.Enabled = true;
}
private void pictureBox10_Click(object sender, EventArgs e)
{
num = 10;
pictureBox10.Hide();
timer1.Enabled = true;
}
private void pictureBox11_Click(object sender, EventArgs e)
{
num = 11;
pictureBox11.Hide();
timer1.Enabled = true;
}
private void pictureBox12_Click(object sender, EventArgs e)
{
num = 12;
pictureBox12.Hide();
timer1.Enabled = true;
}
private void pictureBox13_Click(object sender, EventArgs e)
{
num = 13;
pictureBox13.Hide();
timer1.Enabled = true;
}
private void pictureBox14_Click(object sender, EventArgs e)
{
num = 14;
pictureBox14.Hide();
timer1.Enabled = true;
}
private void pictureBox15_Click(object sender, EventArgs e)
{
num = 15;
pictureBox15.Hide();
timer1.Enabled = true;
}
private void pictureBox16_Click(object sender, EventArgs e)
{
num = 16;
pictureBox16.Hide();
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
KeyUse();
}
private void KeyUse()
{
if (num == 3)
{
Fangda(2); //写入放大倍数
pictureBox3.Show();
}
else if (num == 4)
{
Fangda(0.5); //写入放大倍数
pictureBox4.Show();
}
else if (num == 7)
{
wave = 1;
heng = true;
pictureBox7.Show();
}
else if (num == 8)
{
wave = 1;
heng = false;
pictureBox8.Show();
}
else if (num == 9)
{
wave = 2;
heng = true;
pictureBox9.Show();
}
else if (num == 10)
{
wave = 2;
heng = false;
pictureBox10.Show();
}
else if (num == 11)
{
wave = 3;
heng = true;
pictureBox11.Show();
}
else if (num == 12)
{
wave = 3;
heng = false;
pictureBox12.Show();
}
else if (num == 13)
{
wave = 4;
heng = true;
pictureBox13.Show();
}
else if (num == 14)
{
wave = 4;
heng = false;
pictureBox14.Show();
}
else if (num == 15)
{
wave = 5;
heng = true;
pictureBox15.Show();
}
else if (num == 16)
{
wave = 5;
heng = false;
pictureBox16.Show();
}
ShowWave();
num = 0;
}
private void Fangda(double n)
{
if (heng)
{
if (wave == 1)
X1 *= n;
else if (wave == 2)
X2 *= n;
else if (wave == 3)
X3 *= n;
else if (wave == 4)
X4 *= n;
else if (wave == 5)
X5 *= n;
}
else if(!heng)
{
if (wave == 1)
Y1 *= n;
else if (wave == 2)
Y2 *= n;
else if (wave == 3)
Y3 *= n;
else if (wave == 4)
Y4 *= n;
else if (wave == 5)
Y5 *= n;
}
}
private void ShowWave() //计算并画出波形
{
double SamplingF = winit[0], SamplingN = winit[1]; //获取波形设置数据
double BaseF1 = winit[2], BaseA1 = winit[3], BaseF2 = winit[4], BaseA2 = winit[5],
BaseF3 = winit[6], BaseA3 = winit[7], BaseF4 = winit[8], BaseA4 = winit[9],
BaseF5 = winit[10], BaseA5 = winit[11];
double CarryF = winit[12];
double FlowF = winit[13], FlowA = winit[14];
double LowpassF = winit[15];
int i, j; //用来循环
int x = 10, y = 70, p = 70,N = (int)SamplingN; //(x,y)起始坐标 p第一个y的值方便画图 将SamplingF转化为INT
int m, n, q; //m\n放大倍数的设置 q起始Y坐标设置
int c = (int)(Math.Log(N)/Math.Log(2)); //N的次数
double[] FFT = new double[N]; //存储波形的数组
int FlowN = (int)(FlowF / 5000);
double[] FFT1 = new double[N];
double[] FFT2 = new double[N];
double[] FFT3 = new double[N];
double[] Base1 = new double[N];
double[] Base2 = new double[N];
double[] Mou = new double[N];
double[] Mou1 = new double[N];
double[] Mou2 = new double[N];
double[] Carry = new double[N];
double[] Baoluo = new double[N];
for (j = 0; j < N; j++)
{
FFT[j] = 0;
}
for (j = 0; j < N; j++)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -