📄 mainform.cs
字号:
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using Sun188.iSBus.Common;
using Sun188.iSBus.DataAccess;
namespace Sun188.iSBus.WinUI
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
#region 控件定义===============================================
private System.Windows.Forms.Panel plTop;
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.PictureBox pictureBox3;
private System.Windows.Forms.PictureBox pictureBox4;
private System.Windows.Forms.PictureBox pictureBox5;
private System.Windows.Forms.PictureBox pictureBox6;
private System.Windows.Forms.PictureBox pictureBox7;
private System.Windows.Forms.Panel plBotton;
private System.Windows.Forms.Panel plLeft;
private System.Windows.Forms.Panel plMain;
private System.Windows.Forms.Panel plRight;
private System.Windows.Forms.PictureBox pictureBox8;
private System.Windows.Forms.PictureBox pictureBox9;
private System.Windows.Forms.PictureBox pictureBox10;
private System.Windows.Forms.PictureBox pictureBox11;
private System.Windows.Forms.PictureBox pictureBox12;
private System.Windows.Forms.Panel plToolbar;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.StatusBar statusBar1;
private System.Windows.Forms.TreeView tVCityList;
private System.Windows.Forms.Splitter splitter1;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel6;
private System.Windows.Forms.ToolBar toolBar1;
private System.Windows.Forms.ToolBarButton tbtnSystemManage;
private System.Windows.Forms.ToolBarButton tbtnPrint;
private System.Windows.Forms.ToolBarButton tbtnAbout;
private System.Windows.Forms.ToolBarButton tbtnClose;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.StatusBarPanel statusBarPanel1;
private System.Windows.Forms.StatusBarPanel statusBarPanel2;
private System.Windows.Forms.StatusBarPanel statusBarPanel3;
private System.Windows.Forms.PictureBox btnFirst;
private System.Windows.Forms.PictureBox btnPrv;
private System.Windows.Forms.PictureBox btnNext;
private System.Windows.Forms.PictureBox btnLast;
private System.Windows.Forms.ImageList imageList2;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.Timer tmClock;
private System.Windows.Forms.ImageList imageList3;
private System.Windows.Forms.PictureBox btnMax;
private System.Windows.Forms.PictureBox btnMin;
private System.Windows.Forms.PictureBox btnClose;
private System.Windows.Forms.Panel panel7;
private System.Windows.Forms.Panel panel8;
private System.Windows.Forms.ListView lVBusList;
private System.Windows.Forms.ColumnHeader BusName;
private System.Windows.Forms.ColumnHeader BusType;
private System.Windows.Forms.ColumnHeader BusStartStop;
private System.Windows.Forms.ColumnHeader BusEndStop;
private System.Windows.Forms.ColumnHeader BusDescription;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.PictureBox btnSearch;
private System.Windows.Forms.Label lbFoot;
public System.Windows.Forms.TextBox txbStartStop;
public System.Windows.Forms.TextBox txbEndStop;
private System.Windows.Forms.PictureBox btnOpen1;
private System.Windows.Forms.Label lbTitle;
private System.Windows.Forms.PictureBox btnOpen2;
private System.Windows.Forms.ToolBarButton tbtnHelp;
#endregion
#region 字段定义===============================================
/// <summary>
/// 每页记录数
/// </summary>
private int pageSize = 0;
/// <summary>
/// 总的记录数
/// </summary>
private int totalRecordCount = 0;
/// <summary>
/// 总页数
/// </summary>
private int totalPageCount = 0;
/// <summary>
/// 当前页面
/// </summary>
private int pageIndex = 1;
/// <summary>
/// 城市ID
/// </summary>
private int mCityID = 0;
/// <summary>
/// 浏览类型
/// </summary>
private DataBrowseEnum.BrowseEnum mBrowseEnum = DataBrowseEnum.BrowseEnum.First;
/// <summary>
/// 当前数据集最后一条记录的ID
/// </summary>
private int mLastBusID = 0;
/// <summary>
/// 所选的城市名称
/// </summary>
private string mCityName = "";
/// <summary>
/// 创建BUS对象实例
/// </summary>
private iSBus.DataAccess.Bus Bus = new iSBus.DataAccess.Bus();
/// <summary>
/// 鼠标的位置
/// </summary>
private int xPos,yPos;
/// <summary>
/// 鼠标偏移坐标
/// </summary>
private Point m_pOffset;
/// <summary>
/// 窗体的位置
/// </summary>
private Point locationMain = new Point(200,200);
/// <summary>
/// 最小按钮图片
/// </summary>
private Bitmap btnMinBmp;
/// <summary>
/// 关闭按钮图片
/// </summary>
private Bitmap btnCloseBmp;
/// <summary>
/// 最小按钮是否是MouseOver事件
/// </summary>
private bool btnMinMouseOver = false;
/// <summary>
/// 最小按钮是否是MouseDown事件
/// </summary>
private bool btnMinMouseDown = false;
/// <summary>
/// 关闭按钮是否是MouseOver事件
/// </summary>
private bool btnCloseMouseOver = false;
/// <summary>
/// 关闭按钮是否是MouseDown事件
/// </summary>
private bool btnCloseMouseDown = false;
/// <summary>
/// 第一页按钮是否是MouseOver事件
/// </summary>
private bool btnBrowseFirstMouseOver = false;
/// <summary>
/// 第一页按钮是否是MouseDown事件
/// </summary>
private bool btnBrowseFirstMouseDown = false;
/// <summary>
/// 上一页按钮是否是MouseOver事件
/// </summary>
private bool btnBrowsePrvMouseOver = false;
/// <summary>
/// 上一页按钮是否是MouseDown事件
/// </summary>
private bool btnBrowsePrvMouseDown = false;
/// <summary>
/// 下一页按钮是否是MouseOver事件
/// </summary>
private bool btnBrowseNextMouseOver = false;
/// <summary>
/// 下一页按钮是否是MouseDown事件
/// </summary>
private bool btnBrowseNextMouseDown = false;
/// <summary>
/// 最末页按钮是否是MouseOver事件
/// </summary>
private bool btnBrowseLastMouseOver = false;
/// <summary>
/// 最末页按钮是否是MouseDown事件
/// </summary>
private bool btnBrowseLastMouseDown = false;
/// <summary>
/// 翻页按钮图片
/// </summary>
private Bitmap btnFirstBmp,btnPrvBmp,btnNextBmp,btnLastBmp;
/// <summary>
/// 搜索按钮图片
/// </summary>
private Bitmap btnSerachBmp;
/// <summary>
/// 搜索按钮鼠标事件
/// </summary>
private bool btnSearchOver = false;
private bool btnSearchDown = false;
/// <summary>
/// 数据集
/// </summary>
public static DataSet ds ;
/// <summary>
///
/// </summary>
private bool btnOpen1Over = false;
/// <summary>
///
/// </summary>
private bool btnOpen1Down = false;
/// <summary>
///
/// </summary>
private bool btnOpen2Over = false;
/// <summary>
///
/// </summary>
private bool btnOpen2Down = false;
/// <summary>
///
/// </summary>
private Bitmap btnOpen1Bmp,btnOpen2Bmp;
/// <summary>
///
/// </summary>
public static int busID;
/// <summary>
///
/// </summary>
private System.Windows.Forms.Timer timerHide;
/// <summary>
///
/// </summary>
public static int cityID;
/// <summary>
///
/// </summary>
private SystemManagerForm systemManagerForm = new SystemManagerForm();
/// <summary>
///
/// </summary>
private double showForm = 0;
private System.Windows.Forms.Timer timerExit;
/// <summary>
///
/// </summary>
private double hideForm = 1;
#endregion
#region 构造函数===============================================
public MainForm()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
}
#endregion
#region 窗体加载事件处理=======================================
private void MainForm_Load(object sender, System.EventArgs e)
{
//绑定tVCityList
this.CityList();
//根据城市名称取回城市信息
this.GetCityInfo();
//填充某一城市下的所有公交车的数据
this.BusInfo();
//选中树形目录第一次加载的节点
this.SetCityList();
//设置信息
this.StatisticInfo();
//取动计时器
this.tmClock.Enabled = true;
//状态栏处理
this.StatusBar();
//设置最小化关闭按钮
this.DrawButton(1);
this.DrawButton(2);
//绘制翻页按钮
this.DrawBrowseButton(1);
this.DrawBrowseButton(2);
this.DrawBrowseButton(3);
this.DrawBrowseButton(4);
}
#endregion
#region 清理资源===============================================
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#endregion
#region Windows Form Designer generated code===================
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MainForm));
this.plTop = new System.Windows.Forms.Panel();
this.btnClose = new System.Windows.Forms.PictureBox();
this.btnMax = new System.Windows.Forms.PictureBox();
this.btnMin = new System.Windows.Forms.PictureBox();
this.pictureBox6 = new System.Windows.Forms.PictureBox();
this.pictureBox5 = new System.Windows.Forms.PictureBox();
this.pictureBox4 = new System.Windows.Forms.PictureBox();
this.pictureBox3 = new System.Windows.Forms.PictureBox();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.pictureBox7 = new System.Windows.Forms.PictureBox();
this.plBotton = new System.Windows.Forms.Panel();
this.pictureBox12 = new System.Windows.Forms.PictureBox();
this.pictureBox11 = new System.Windows.Forms.PictureBox();
this.pictureBox10 = new System.Windows.Forms.PictureBox();
this.plLeft = new System.Windows.Forms.Panel();
this.pictureBox8 = new System.Windows.Forms.PictureBox();
this.plMain = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
this.panel1 = new System.Windows.Forms.Panel();
this.panel4 = new System.Windows.Forms.Panel();
this.panel6 = new System.Windows.Forms.Panel();
this.lbFoot = new System.Windows.Forms.Label();
this.btnLast = new System.Windows.Forms.PictureBox();
this.btnNext = new System.Windows.Forms.PictureBox();
this.btnPrv = new System.Windows.Forms.PictureBox();
this.btnFirst = new System.Windows.Forms.PictureBox();
this.panel5 = new System.Windows.Forms.Panel();
this.panel8 = new System.Windows.Forms.Panel();
this.lVBusList = new System.Windows.Forms.ListView();
this.BusName = new System.Windows.Forms.ColumnHeader();
this.BusType = new System.Windows.Forms.ColumnHeader();
this.BusStartStop = new System.Windows.Forms.ColumnHeader();
this.BusEndStop = new System.Windows.Forms.ColumnHeader();
this.BusDescription = new System.Windows.Forms.ColumnHeader();
this.panel7 = new System.Windows.Forms.Panel();
this.btnOpen2 = new System.Windows.Forms.PictureBox();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -