📄 frmoption.cs
字号:
//
this.btnSelectDir.Location = new System.Drawing.Point(496, 30);
this.btnSelectDir.Name = "btnSelectDir";
this.btnSelectDir.Size = new System.Drawing.Size(88, 22);
this.btnSelectDir.TabIndex = 2;
this.btnSelectDir.Text = "选择目录…";
this.btnSelectDir.Click += new System.EventHandler(this.btnSelectDir_Click);
//
// lblRtnLogFile
//
this.lblRtnLogFile.Location = new System.Drawing.Point(16, 8);
this.lblRtnLogFile.Name = "lblRtnLogFile";
this.lblRtnLogFile.Size = new System.Drawing.Size(138, 18);
this.lblRtnLogFile.TabIndex = 1;
this.lblRtnLogFile.Text = "返回日志文件目录";
//
// txtDir
//
this.txtDir.Location = new System.Drawing.Point(16, 30);
this.txtDir.Name = "txtDir";
this.txtDir.Size = new System.Drawing.Size(470, 21);
this.txtDir.TabIndex = 0;
this.txtDir.Text = "";
//
// tabPage3
//
this.tabPage3.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.tabPage3.Controls.Add(this.lblMaxUsers);
this.tabPage3.Controls.Add(this.txtMaxUsers);
this.tabPage3.Controls.Add(this.lblName);
this.tabPage3.Controls.Add(this.txtMainTitle);
this.tabPage3.Location = new System.Drawing.Point(4, 24);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Size = new System.Drawing.Size(594, 232);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "其他";
//
// lblMaxUsers
//
this.lblMaxUsers.Location = new System.Drawing.Point(14, 66);
this.lblMaxUsers.Name = "lblMaxUsers";
this.lblMaxUsers.Size = new System.Drawing.Size(254, 18);
this.lblMaxUsers.TabIndex = 6;
this.lblMaxUsers.Text = "超市中的最大用户数";
//
// txtMaxUsers
//
this.txtMaxUsers.Location = new System.Drawing.Point(16, 88);
this.txtMaxUsers.Name = "txtMaxUsers";
this.txtMaxUsers.Size = new System.Drawing.Size(64, 21);
this.txtMaxUsers.TabIndex = 5;
this.txtMaxUsers.Text = "50";
//
// lblName
//
this.lblName.Location = new System.Drawing.Point(14, 10);
this.lblName.Name = "lblName";
this.lblName.Size = new System.Drawing.Size(145, 18);
this.lblName.TabIndex = 4;
this.lblName.Text = "超市名称";
//
// txtMainTitle
//
this.txtMainTitle.Location = new System.Drawing.Point(16, 32);
this.txtMainTitle.Name = "txtMainTitle";
this.txtMainTitle.Size = new System.Drawing.Size(368, 21);
this.txtMainTitle.TabIndex = 3;
this.txtMainTitle.Text = "祥龙超市";
//
// btnCancel
//
this.btnCancel.Location = new System.Drawing.Point(516, 276);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(90, 26);
this.btnCancel.TabIndex = 1;
this.btnCancel.Text = "取消(&C)";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnApply
//
this.btnApply.Location = new System.Drawing.Point(418, 276);
this.btnApply.Name = "btnApply";
this.btnApply.Size = new System.Drawing.Size(90, 26);
this.btnApply.TabIndex = 2;
this.btnApply.Text = "应用(&A)";
this.btnApply.Click += new System.EventHandler(this.btnApply_Click);
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(318, 276);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(90, 26);
this.btnOK.TabIndex = 3;
this.btnOK.Text = "确定(&O)";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// tipOption
//
this.tipOption.AutomaticDelay = 150;
//
// frmOption
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 14);
this.ClientSize = new System.Drawing.Size(612, 311);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.btnApply);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.tabSettings);
this.Font = new System.Drawing.Font("Times New Roman", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
this.Name = "frmOption";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "选项";
this.Load += new System.EventHandler(this.frmOption_Load);
this.tabSettings.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.grpSelectBkFile.ResumeLayout(false);
this.grpSelectColor.ResumeLayout(false);
this.grpMainWindowBackGround.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.grpLogFileOption.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.Close ();
}
private void btnColor_Click(object sender, System.EventArgs e)
{
//original = ctlMDI.BackColor;
cdlgColor.ShowDialog(this);
lblColor.BackColor=cdlgColor.Color;
}
private void btnSelectFile_Click(object sender, System.EventArgs e)
{
ofdlgOpenFile.ShowDialog(this);
txtFile.Text =ofdlgOpenFile.FileName;
}
private void btnSelectDir_Click(object sender, System.EventArgs e)
{
fbdFileBrDialog.ShowDialog(this);
txtDir.Text = fbdFileBrDialog.SelectedPath;
}
private void frmOption_Load(object sender, System.EventArgs e)
{
this.grpSelectBkFile.Enabled=false;
this.grpSelectColor.Enabled=false;
}
private void rdoShowNothing_CheckedChanged(object sender, System.EventArgs e)
{
this.grpSelectBkFile.Enabled=false;
this.grpSelectColor.Enabled=false;
this.btnApply.Enabled=false;
this.ParentForm.BackgroundImage = null;
//ctlMDI.BackColor = original;
}
private void rdoShowPicture_CheckedChanged(object sender, System.EventArgs e)
{
this.grpSelectBkFile.Enabled=true;
this.grpSelectColor.Enabled=false;
this.btnApply.Enabled=true;
}
private void rdoShowBackColor_CheckedChanged(object sender, System.EventArgs e)
{
this.grpSelectBkFile.Enabled=false;
this.grpSelectColor.Enabled=true;
this.btnApply.Enabled=true;
}
private void ChangeMainFormBackColor()
{
MdiClient ctlMDI;
// Loop through all of the form's controls looking
// for the control of type MdiClient.
foreach (Control ctl in this.ParentForm.Controls)
{
try
{
// Attempt to cast the control to type MdiClient.
ctlMDI = (MdiClient) ctl;
// Set the BackColor of the MdiClient control.
this.ParentForm.BackgroundImage = null;
ctlMDI.BackColor = this.lblColor.BackColor;
}
catch(InvalidCastException){}
}
}
private void ChangeMainFormBackPicture()
{
try
{
this.ParentForm.BackgroundImage = Image.FromFile(this.txtFile.Text);
}
catch(Exception)
{
MessageBox.Show("图片文件无效");
}
}
private void MainTitleChange()
{
//Changing the Title Bar of the Main Menu form
if(this.txtMainTitle.Text == "")
{
this.txtMainTitle.Text = "祥龙超市";
this.ParentForm.Text = this.txtMainTitle.Text;
}
else if (this.txtMainTitle.Text != this.mainTitle)
{
this.ParentForm.Text = this.txtMainTitle.Text;
this.mainTitle = this.ParentForm.Text;
}
}
private void MaximizeWindow()
{
if(this.chkMaximizeWindow.Checked == true)
if (this.ParentForm.WindowState != System.Windows.Forms.FormWindowState.Maximized)
this.ParentForm.WindowState = System.Windows.Forms.FormWindowState.Maximized;
}
private void BackColor_Picture()
{
//Changing the background color and picture
if ((this.txtFile.Text !="")&& (this.grpSelectBkFile.Enabled==true))
this.ChangeMainFormBackPicture();
else if((this.lblColor.Enabled == true)& (this.grpSelectColor.Enabled==true))
this.ChangeMainFormBackColor();
}
private void btnApply_Click(object sender, System.EventArgs e)
{
//call MainTitleChange to change the main title of Main Window
this.MainTitleChange();
//checking the Show ToolBar status and make visible true/false
if(this.chkShowToolBar.Checked == false)
this.tbrMain.Visible = false;
else
this.tbrMain.Visible = true;
//Maximizing the Main Window
this.MaximizeWindow();
//Changing the background color and picture
this.BackColor_Picture();
}
private void btnOK_Click(object sender, System.EventArgs e)
{
//call MainTitleChange to change the main title of Main Window
this.MainTitleChange();
//checking the Show ToolBar status and make visible true/false
if(this.chkShowToolBar.Checked == false)
this.tbrMain.Visible = false;
else
this.tbrMain.Visible = true;
//Maximizing the Main Window
this.MaximizeWindow();
//Changing the background color and picture
this.BackColor_Picture();
Settings settings=new Settings();
Environment.CurrentDirectory = settings.appDirectory;
this.Close();
}
private void rdoShowBackColor_MouseHover(object sender, System.EventArgs e)
{
this.tipOption.SetToolTip(this.rdoShowBackColor ,"显示背景色");
}
private void rdoShowPicture_MouseHover(object sender, System.EventArgs e)
{
this.tipOption.SetToolTip(this.rdoShowPicture ,"选择背景图片");
}
private void rdoShowNothing_MouseHover(object sender, System.EventArgs e)
{
this.tipOption.SetToolTip(this.rdoShowNothing ,"移除背景效果");
}
private void txtFile_MouseHover(object sender, System.EventArgs e)
{
this.tipOption.SetToolTip(this.txtFile ,"");
}
private void grpSelectColor_MouseHover(object sender, System.EventArgs e)
{
this.tipOption.SetToolTip(this.grpSelectColor ,"选择一种背景色");
}
private void chkShowToolBar_MouseHover(object sender, System.EventArgs e)
{
this.tipOption.SetToolTip(this.chkShowToolBar ,"显示工具栏");
}
private void chkMaximizeWindow_MouseHover(object sender, System.EventArgs e)
{
this.tipOption.SetToolTip(this.chkMaximizeWindow ,"最大化窗体");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -