📄 settingsform.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MobileDevelopersHandbook
{
public partial class SettingsForm : Form
{
public SettingsForm()
{
InitializeComponent();
this.settingsBindingSource.DataSource = Settings.Instance;
}
private void SettingsForm_Load(object sender, EventArgs e)
{
// Set the two color comboboxes
switch (Settings.Instance.TextColor.ToArgb())
{
case -1:
this.textColorComboBox.Text = "White";
break;
case -65536:
this.textColorComboBox.Text = "Red";
break;
case -16776961:
this.textColorComboBox.Text = "Blue";
break;
default:
this.textColorComboBox.Text = "Black";
break;
}
switch (Settings.Instance.BackgroundColor.ToArgb())
{
case -16777216:
this.backGroundColorComboBox.Text = "Black";
break;
case -256:
this.backGroundColorComboBox.Text = "Yellow";
break;
case -16744448:
this.backGroundColorComboBox.Text = "Green";
break;
default:
this.backGroundColorComboBox.Text = "White";
break;
}
}
private void cancelMenuItem_Click(object sender, EventArgs e)
{
this.settingsBindingSource.CancelEdit();
this.DialogResult = DialogResult.Cancel;
}
private void saveMenuItem_Click(object sender, EventArgs e)
{
this.settingsBindingSource.EndEdit();
// Save the Colors
switch (this.textColorComboBox.Text)
{
case "White":
Settings.Instance.TextColor = Color.White;
break;
case "Red":
Settings.Instance.TextColor = Color.Red;
break;
case "Blue":
Settings.Instance.TextColor = Color.Blue;
break;
default:
Settings.Instance.TextColor = Color.Black;
break;
}
switch (this.backGroundColorComboBox.Text)
{
case "Black":
Settings.Instance.BackgroundColor = Color.Black;
break;
case "Yellow":
Settings.Instance.BackgroundColor = Color.Yellow;
break;
case "Green":
Settings.Instance.BackgroundColor = Color.Green;
break;
default:
Settings.Instance.BackgroundColor = Color.White;
break;
}
// Persist the settings
Settings.SaveSettings();
// Close the form
this.DialogResult = DialogResult.OK;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -