frminput.cs
来自「用C#写的USB数据采集程序」· CS 代码 · 共 105 行
CS
105 行
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MCA
{
public partial class FrmInput : Form
{
internal FrmMain frmmain;
#region "构造函数"
/// <summary>
/// 构造函数
/// </summary>
public FrmInput()
{
InitializeComponent();
}
#endregion
#region "移动窗体"
private bool moveenable;
private int px;
private int py;
private void panelCaption_MouseDown(object sender, MouseEventArgs e)
{
moveenable = true;
//保存原始的坐标点,便于移动时计算相对距离
px = e.X;
py = e.Y;
}
private void panelCaption_MouseMove(object sender, MouseEventArgs e)
{
if (moveenable)
{
this.Left += e.X - px;
this.Top += e.Y - py;
this.Refresh();
frmmain.Refresh();
}
}
private void panelCaption_MouseUp(object sender, MouseEventArgs e)
{
moveenable = false;
}
#endregion
#region "取消"
/// <summary>
/// 取消参数输入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ibtCancel_MouseUp(object sender, MouseEventArgs e)
{
this.DialogResult = DialogResult.Cancel;
this.Close();
}
#endregion
#region "完成参数输入"
/// <summary>
/// 完成参数输入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ibtOK_MouseUp(object sender, MouseEventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Close();
}
#endregion
#region "初始化"
/// <summary>
/// 窗口载入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void FrmInput_Load(object sender, EventArgs e)
{
this.Top = Screen.PrimaryScreen.Bounds.Top + (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2;
this.Left = Screen.PrimaryScreen.Bounds.Left + (Screen.PrimaryScreen.Bounds.Width - this.Width) / 2;
}
#endregion
#region "控制输入面板"
private void tBRemark_GotFocus(object sender, EventArgs e)
{
inputPanel.Enabled = true;
}
private void tBRemark_LostFocus(object sender, EventArgs e)
{
inputPanel.Enabled = false;
}
#endregion
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?