1 Star 0 Fork 5

重庆0212/myIPC

forked from 13799673123/myIPC 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
MainMenu.cs 5.71 KB
一键复制 编辑 原始数据 按行查看 历史
13799673123 提交于 2023-05-18 10:11 . 美化了菜单栏
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace UltrasonicTDPlatform
{
/**
* 主菜单窗口类
*/
public partial class MainMenu : Form
{
[DllImport("dllTest.dll", CallingConvention = CallingConvention.Cdecl)]
extern static int Sum(int a, int b);
/**
* 子窗体变量
*/
//1.欢迎页窗体
public static WelcomeForm welcomeForm = new WelcomeForm();
//2.扫描窗体(这里不能直接初始化,否则Mainmenu的值传递不过去,等到按下“阻抗测量”时,再初始化,就可把以及设置好的值传递给SweepForm)
public static SweepForm sweepForm = new SweepForm();
//3.监控界面窗体
public static Monitor monitor = new Monitor();
//4.驱动窗体
public static DriverForm driverForm = new DriverForm();
//5.硬件连接窗体
public static ConnectionForm connectionForm = new ConnectionForm();
/**
* 所有窗体共用变量
*/
//1.串口模式
public static String comMode = "";
//2.串口号
public static String comName = "";
//3.串口波特率
public static int comBodeRate = 9600;
//4. 串口对象(重要!!!所有子窗口都要用这个serialPort1成员变量!)
public static System.IO.Ports.SerialPort serialPort1 = null;
public MainMenu()
{
InitializeComponent();
}
/**
* 初始化函数,一些初始化控件的操作
*/
private void Form1_Load(object sender, EventArgs e)
{
// 1. 主窗体初始化
//this.WindowState = FormWindowState.Maximized; //最大化主窗体
// 主容器初始化
panel2.Width = this.Width;
panel2.Height = this.Height;
// 2. 子窗体初始化
//sweepForm.WindowState = FormWindowState.Maximized; //最大化窗体
sweepForm.StartPosition = FormStartPosition.CenterScreen;
//connectionForm.WindowState = FormWindowState.Maximized; //最大化窗体
connectionForm.StartPosition = FormStartPosition.CenterScreen;
//monitor.WindowState = FormWindowState.Maximized; //最大化窗体
monitor.StartPosition = FormStartPosition.CenterScreen;
//driverForm.WindowState = FormWindowState.Maximized; //最大化窗体
driverForm.StartPosition = FormStartPosition.CenterScreen;
statusStrip1.Items[0].Text = "版本号:0.0.0 ";
statusStrip1.Items[1].Text = "硬件状态:正常/异常 ";
statusStrip1.Items[2].Text = "当前操作: ";
}
private void button8_Click(object sender, EventArgs e)
{
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
statusStripChange(button1);
buttonColorRefresh(button1);
// 切换界面
panel2.Controls.Clear();
panel2.Controls.Add(connectionForm);
connectionForm.Show();
}
private void button2_Click(object sender, EventArgs e)
{
statusStripChange(button2);
buttonColorRefresh(button2);
// 切换界面
panel2.Controls.Clear() ;
panel2.Controls.Add(sweepForm);
sweepForm.Show();
}
private void button5_Click(object sender, EventArgs e)
{
statusStripChange(button5);
buttonColorRefresh(button5);
// 切换界面
panel2.Controls.Clear();
panel2.Controls.Add(monitor);
monitor.Show();
}
private void button7_Click(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
statusStripChange(button4);
buttonColorRefresh(button4);
panel2.Controls.Clear();
panel2.Controls.Add(driverForm);
driverForm.Show();
}
private void button3_Click(object sender, EventArgs e)
{
statusStripChange(button3);
buttonColorRefresh(button3);
}
/**
* 改变按下的按钮的颜色,突出显示
*/
private void buttonColorRefresh(Button button)
{
button1.BackColor = Color.DarkGray;
button2.BackColor = Color.DarkGray;
button3.BackColor = Color.DarkGray;
button4.BackColor = Color.DarkGray;
button5.BackColor = Color.DarkGray;
button6.BackColor = Color.DarkGray;
button.BackColor = Color.Black;
}
private void button6_Click(object sender, EventArgs e)
{
statusStripChange(button6);
buttonColorRefresh(button6);
}
public void statusStripChange(Button button)
{
statusStrip1.Items[2].Text = "当前操作:"+button.Text;
}
private void MainMenu_SizeChanged(object sender, EventArgs e)
{
/*welcomeForm.Width = this.Width;
welcomeForm.Height = this.Height-40;
sweepForm.Width = this.Width;
sweepForm.Height = this.Height - 40;*/
}
private void button3_Click_1(object sender, EventArgs e)
{
//button3.Text = Sum(1, 3).ToString();
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/btsc/my-ipc.git
git@gitee.com:btsc/my-ipc.git
btsc
my-ipc
myIPC
master

搜索帮助