📄 searchform.cs
字号:
#region 获取站点列表===========================================
/// <summary>
/// 获取站点列表
/// </summary>
private void GetStopList()
{
try
{
this.dsStop = new DataAccess.Stop().StopDataset(this.cityID);
DataTable dt = dsStop.Tables[0];
for(int i=0;i<dt.Rows.Count;i++)
{
string[] str = new string[]{dt.Rows[i]["StopName"].ToString(),dt.Rows[i]["StopDescription"].ToString()};
this.lVStopList.Items.Add(new ListViewItem(str));
}
this.totalRecordCount = dt.Rows.Count;
}
catch
{
}
}
#endregion
#region 统计信息===============================================
/// <summary>
/// 统计信息
/// </summary>
private void StatisticInfo()
{
string result = "";
result = "【总共"+this.totalRecordCount.ToString()+"条记录】";
this.lbTitle.Text = result;
}
#endregion
#region 移动窗口===============================================
private void pictureBox4_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
Point mousePoint = Control.MousePosition;
mousePoint.Offset(this.m_pOffset.X,this.m_pOffset.Y);
this.Location = mousePoint;
this.xPos = mousePoint.X;
this.yPos = mousePoint.Y;
if(xPos < 0)
{
xPos = 0;
}
if(yPos < 0)
{
yPos = 0;
}
this.locationMain.X = xPos;
this.locationMain.Y = yPos;
}
}
private void pictureBox4_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.m_pOffset = new Point(-e.X,-e.Y);
}
#endregion
#region 绘制窗体标题===========================================
private void pictureBox4_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
try
{
Point p = new Point(this.pictureBox4.Location.X-40,this.pictureBox4.Location.Y+5);
Graphics g = e.Graphics;
g.DrawString(SystemMessage.SYSTEM_TITLE+"站点查询",new Font("宋体",10),Brushes.Yellow,p);
Point p2 = new Point(p.X+1,p.Y+1);
g.DrawString(SystemMessage.SYSTEM_TITLE+"站点查询",new Font("宋体",10),Brushes.DarkBlue,p2);
//g.Dispose();
}
catch(System.Exception ex)
{
throw new Exception(ex.Message);
}
}
#endregion
#region 当前时间日期===========================================
private void tmClock_Tick(object sender, System.EventArgs e)
{
this.statusBarPanel1.Text = DateTime.Now.ToLongDateString()+" "+DateTime.Now.ToLongTimeString();
}
#endregion
#region 状态栏处理=============================================
private void StatusBar()
{
this.statusBarPanel2.Text = "作者:陈志峰 sunboy@sun188.com";
//this.statusBarPanel3.Text = "阳光商务在线 http://www.sun188.com";
}
#endregion
#region 设置最小化关闭按钮=====================================
/// <summary>
/// 设置最小化关闭按钮
/// </summary>
/// <param name="buttonType">1.btnMin 2.btnClose</param>
private void DrawButton(int buttonType)
{
switch(buttonType)
{
case 1:
if(btnMinMouseOver)
{
if(btnMinMouseDown)
{
this.btnMinBmp = new Bitmap("images/btnMinDown.jpg");
}
else
{
this.btnMinBmp = new Bitmap("images/btnMinOver.jpg");
}
}
else
{
this.btnMinBmp = new Bitmap("images/btnMin.jpg");
}
break;
case 2:
if(btnCloseMouseOver)
{
if(btnCloseMouseDown)
{
this.btnCloseBmp = new Bitmap("images/btnCloseDown.jpg");
}
else
{
this.btnCloseBmp = new Bitmap("images/btnCloseOver.jpg");
}
}
else
{
this.btnCloseBmp = new Bitmap("images/btnClose.jpg");
}
break;
}
//邦定按钮图片
this.btnMin.Image = this.btnMinBmp;
this.btnClose.Image = this.btnCloseBmp;
}
#endregion
#region 最小化,关闭按钮事件处理================================
private void btnMin_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnMinMouseOver = true;
this.DrawButton(1);
}
private void btnMin_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnMinMouseDown = true;
this.DrawButton(1);
}
private void btnMin_MouseLeave(object sender, System.EventArgs e)
{
this.btnMinMouseOver = false;
this.btnMinMouseDown = false;
this.DrawButton(1);
}
private void btnMin_Click(object sender, System.EventArgs e)
{
MainForm.ActiveForm.WindowState=FormWindowState.Minimized;
}
private void btnClose_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnCloseMouseOver = true;
this.DrawButton(2);
}
private void btnClose_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnCloseMouseDown = true;
this.DrawButton(2);
}
private void btnClose_MouseLeave(object sender, System.EventArgs e)
{
this.btnCloseMouseOver = false;
this.btnCloseMouseDown = false;
this.DrawButton(2);
}
private void btnClose_Click(object sender, System.EventArgs e)
{
this.timerHide.Enabled = true;
}
#endregion
#region 搜索结果列表===========================================
/// <summary>
/// 搜索结果列表
/// </summary>
/// <param name="searchName">关键字</param>
private void SearchStop(string searchName)
{
try
{
DataRow[] drArray = this.dsStop.Tables[0].Select("StopName like '%"+searchName+"%'");
//清除列表记录
this.lVStopList.Items.Clear();
for(int i=0;i<drArray.Length;i++)
{
DataRow dr = drArray[i];
string[] str = new string[]{dr["StopName"].ToString(),dr["StopDescription"].ToString()};
this.lVStopList.Items.Add(new ListViewItem(str));
}
this.totalRecordCount = drArray.Length;
}
catch
{
}
}
#endregion
#region 绘制搜索按钮===========================================
/// <summary>
/// 绘制搜索按钮
/// </summary>
private void DrawSearchButton()
{
if(this.btnSearchOver)
{
if(this.btnSearchDown)
{
this.btnSerachBmp = new Bitmap("images\\btnSearchDown.gif");
}
else
{
this.btnSerachBmp = new Bitmap("images\\btnSearchOver.gif");
}
}
else
{
this.btnSerachBmp = new Bitmap("images\\btnSearch.gif");
}
//绘制搜索按钮
this.btnSearch.Image = this.btnSerachBmp;
}
#endregion
#region 搜索按钮事件处理=======================================
private void btnSearch_Click(object sender, System.EventArgs e)
{
if(this.txbSearch.Text.Trim()!="")
{
this.SearchStop(this.txbSearch.Text.Trim());
}
else
{
//先清除列表的记录
this.lVStopList.Items.Clear();
//获取所有站点列表
this.GetStopList();
}
//统计信息
this.StatisticInfo();
}
private void btnSearch_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnSearchDown = true;
//绘制搜索按钮
this.DrawSearchButton();
}
private void btnSearch_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.btnSearchOver = true;
//绘制搜索按钮
this.DrawSearchButton();
}
private void btnSearch_MouseLeave(object sender, System.EventArgs e)
{
this.btnSearchDown = false;
this.btnSearchOver = false;
//绘制搜索按钮
this.DrawSearchButton();
}
#endregion
#region 返回结果===============================================
private void lVStopList_SelectedIndexChanged(object sender, System.EventArgs e)
{
foreach(ListViewItem lv in this.lVStopList.Items)
{
if(lv.Selected)
{
if(this.searchID==0)
{
this.mMainForm.txbStartStop.Text = lv.Text.ToString();
}
else
{
this.mMainForm.txbEndStop.Text = lv.Text.ToString();
}
this.timerHide.Enabled = true;
}
}
}
#endregion
#region ToolBar事件处理========================================
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
Point pLocation = new Point(this.Location.X+30,this.Location.Y+30);
Size size = new Size(600,450);
if(e.Button==this.toolBar1.Buttons[0])
{
HelpForm helpForm = new HelpForm();
helpForm.type = 1;
helpForm.Size = size;
helpForm.Location = pLocation;
helpForm.TopMost = true;
helpForm.ShowDialog();
}
else if(e.Button == this.toolBar1.Buttons[1])
{
HelpForm helpForm = new HelpForm();
helpForm.type = 2;
helpForm.Size = size;
helpForm.Location = pLocation;
helpForm.TopMost = true;
helpForm.ShowDialog();
}
else if(e.Button == this.toolBar1.Buttons[2])
{
this.timerHide.Enabled = true;
}
}
#endregion
#region 窗口淡入淡出特效处理===================================
private void timerHide_Tick(object sender, System.EventArgs e)
{
this.hideForm -= 0.2;
this.Opacity = this.hideForm;
if(this.hideForm <= 0)
{
this.timerHide.Enabled = false;
this.Close();
}
}
private void timerShow_Tick(object sender, System.EventArgs e)
{
this.showForm += 0.2;
this.Opacity = this.showForm;
if(this.showForm >= 1)
{
this.timerShow.Enabled = false;
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -