📄 form1.cs
字号:
this.label2.Size = new System.Drawing.Size(170, 29);
this.label2.TabIndex = 4;
this.label2.Text = "已点的菜";
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 301);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
this.statusBarPanel1,
this.statusBarPanel2});
this.statusBar1.ShowPanels = true;
this.statusBar1.Size = new System.Drawing.Size(496, 28);
this.statusBar1.TabIndex = 5;
this.statusBar1.Text = "statusBar1";
//
// statusBarPanel1
//
this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
this.statusBarPanel1.Name = "statusBarPanel1";
this.statusBarPanel1.Text = "statusBarPanel1";
this.statusBarPanel1.Width = 132;
//
// statusBarPanel2
//
this.statusBarPanel2.Name = "statusBarPanel2";
this.statusBarPanel2.Text = "statusBarPanel2";
//
// toolBar1
//
this.toolBar1.AutoSize = false;
this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton1,
this.toolBarButton2,
this.toolBarButton3,
this.toolBarButton4,
this.toolBarButton5});
this.toolBar1.DropDownArrows = true;
this.toolBar1.ImageList = this.imageList1;
this.toolBar1.Location = new System.Drawing.Point(0, 0);
this.toolBar1.Name = "toolBar1";
this.toolBar1.ShowToolTips = true;
this.toolBar1.Size = new System.Drawing.Size(496, 41);
this.toolBar1.TabIndex = 6;
this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
//
// toolBarButton1
//
this.toolBarButton1.ImageIndex = 0;
this.toolBarButton1.Name = "toolBarButton1";
this.toolBarButton1.Tag = this.menuItem6;
//
// toolBarButton2
//
this.toolBarButton2.ImageIndex = 1;
this.toolBarButton2.Name = "toolBarButton2";
this.toolBarButton2.Tag = this.menuItem7;
//
// toolBarButton3
//
this.toolBarButton3.Name = "toolBarButton3";
this.toolBarButton3.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
//
// toolBarButton4
//
this.toolBarButton4.ImageIndex = 2;
this.toolBarButton4.Name = "toolBarButton4";
this.toolBarButton4.Tag = this.menuItem4;
//
// toolBarButton5
//
this.toolBarButton5.ImageIndex = 3;
this.toolBarButton5.Name = "toolBarButton5";
this.toolBarButton5.Tag = this.menuItem5;
//
// imageList1
//
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
this.imageList1.Images.SetKeyName(0, "");
this.imageList1.Images.SetKeyName(1, "");
this.imageList1.Images.SetKeyName(2, "");
this.imageList1.Images.SetKeyName(3, "");
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(8, 18);
this.ClientSize = new System.Drawing.Size(496, 329);
this.ContextMenu = this.contextMenu1;
this.Controls.Add(this.toolBar1);
this.Controls.Add(this.statusBar1);
this.Controls.Add(this.label2);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Menu = this.mainMenu1;
this.Name = "Form1";
this.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "菜单的综合应用";
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.Form1_MouseMove);
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void menuItem6_Click(object sender, System.EventArgs e)
{
DialogResult result=MessageBox.Show("大盘的青椒土豆丝货真价实,包您满意。确定吗?","请点菜",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Exclamation);
if(result==DialogResult.Yes)
{
listBox1.Items.Add("大盘的青椒土豆丝");
price=price+20;
statusBarPanel1.Text ="总价格:"+price.ToString()+"元";
}
}
private void menuItem7_Click(object sender, System.EventArgs e)
{
DialogResult result=MessageBox.Show("小盘的青椒土豆丝经济实惠,您一定会吃了一盘想两盘,吃了两盘想四盘。确定吗?","请点菜",MessageBoxButtons.YesNoCancel);
if(result==DialogResult.Yes)
{
listBox1.Items.Add("小盘的青椒土豆丝");
price=price+10;
statusBarPanel1.Text ="总价格:"+price.ToString()+"元";
}
}
private void menuItem4_Click(object sender, System.EventArgs e)
{
DialogResult result=MessageBox.Show("麻辣鸡丝是宫廷名菜,麻辣爽口,鲜香诱人。确定吗?","请点菜",MessageBoxButtons.YesNoCancel);
if(result==DialogResult.Yes)
{
listBox1.Items.Add("麻辣鸡丝");
price=price+80;
statusBarPanel1.Text ="总价格:"+price.ToString()+"元";
}
}
private void menuItem5_Click(object sender, System.EventArgs e)
{
DialogResult result=MessageBox.Show("群英荟萃是著名的宫廷名菜,爽口爽心。确定吗?","请点菜",MessageBoxButtons.YesNoCancel);
if(result==DialogResult.Yes)
{
listBox1.Items.Add("群英荟萃");
price=price+70;
statusBarPanel1.Text ="总价格:"+price.ToString()+"元";
}
}
private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
statusBarPanel2.Text="欢迎光临";
}
private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
ToolBarButton button=e.Button;
MenuItem mItem=(MenuItem)button.Tag ;
mItem.PerformClick();
}
private void menuItem9_Click(object sender, System.EventArgs e)
{
DialogResult result=MessageBox.Show("今日优惠菜为京城经典名菜京酱肉丝,吃了这次想下次,确定吗?","请点菜",MessageBoxButtons.YesNoCancel);
if(result==DialogResult.Yes)
{
listBox1.Items.Add("京酱肉丝");
price=price+88;
statusBarPanel1.Text ="总价格:"+price.ToString()+"元";
}
}
private void button1_Click(object sender, System.EventArgs e)
{
DialogResult result=MessageBox.Show("您确定菜单吗","点菜完毕",MessageBoxButtons.YesNo);
if(result==DialogResult.Yes)
{ label1.Text="您本次消费的总价格:"+price.ToString()+"元,"+"全体员工祝您开心用餐!";
statusBarPanel1.Text ="您本次消费的总价格:"+price.ToString()+"元,"+"全体员工祝您开心用餐!";
}
}
private void button2_Click(object sender, System.EventArgs e)
{
price=0;
listBox1.Items.Clear();
label1.Text=" 欢迎光临";
statusBarPanel1.Text ="总价格:"+price.ToString()+"元";
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -