172 lines
9.1 KiB
C#
172 lines
9.1 KiB
C#
using System.Drawing;
|
||
using System.Windows.Forms;
|
||
|
||
namespace Lskj.Main
|
||
{
|
||
partial class FrmPersonalSetting
|
||
{
|
||
private System.ComponentModel.IContainer components;
|
||
private Panel pnlHeader, pnlNavigation, pnlContent, pnlAppearance, pnlFonts;
|
||
private Button navAppearance, navFonts, btnSave, btnCancel, btnReset;
|
||
private TextBox txtTopColor, txtLeftColor, txtLeftSelectColor;
|
||
private Panel pnlTopPreview, pnlLeftPreview, pnlLeftSelectPreview;
|
||
private Button btnTopColor, btnLeftColor, btnLeftSelectColor;
|
||
private NumericUpDown numTopFont, numLeftFont;
|
||
|
||
protected override void Dispose(bool disposing)
|
||
{
|
||
if (disposing && components != null) components.Dispose();
|
||
base.Dispose(disposing);
|
||
}
|
||
|
||
// Keep this method limited to straightforward assignments so the WinForms
|
||
// designer can parse it reliably.
|
||
private void InitializeComponent()
|
||
{
|
||
components = new System.ComponentModel.Container();
|
||
Text = "个性化";
|
||
StartPosition = FormStartPosition.CenterParent;
|
||
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||
MaximizeBox = false;
|
||
MinimizeBox = false;
|
||
ClientSize = new Size(780, 582);
|
||
BackColor = Color.White;
|
||
Font = new Font("Microsoft YaHei", 9F);
|
||
|
||
pnlHeader = new Panel();
|
||
pnlNavigation = new Panel();
|
||
pnlContent = new Panel();
|
||
pnlAppearance = new Panel();
|
||
pnlFonts = new Panel();
|
||
pnlHeader.Dock = DockStyle.Top;
|
||
pnlHeader.Height = 36;
|
||
pnlHeader.BackColor = Color.FromArgb(7, 95, 166);
|
||
pnlNavigation.Dock = DockStyle.Left;
|
||
pnlNavigation.Width = 176;
|
||
pnlNavigation.BackColor = Color.FromArgb(247, 249, 252);
|
||
pnlNavigation.Padding = new Padding(8, 8, 8, 0);
|
||
pnlContent.Dock = DockStyle.Fill;
|
||
pnlContent.BackColor = Color.White;
|
||
pnlContent.Padding = new Padding(18, 0, 18, 0);
|
||
|
||
Controls.Add(pnlContent);
|
||
Controls.Add(pnlNavigation);
|
||
Controls.Add(pnlHeader);
|
||
}
|
||
|
||
// Build the remaining controls outside InitializeComponent. This is invoked
|
||
// by the form constructor for both runtime and Visual Studio design-time.
|
||
private void BuildDesignerControls()
|
||
{
|
||
Label title = new Label { Text = "● 个性化", ForeColor = Color.White, AutoSize = true, Location = new Point(12, 9), Font = new Font("Microsoft YaHei", 10F) };
|
||
Button close = new Button { Text = "×", FlatStyle = FlatStyle.Flat, ForeColor = Color.White, BackColor = Color.Transparent, Size = new Size(32, 30), Anchor = AnchorStyles.Top | AnchorStyles.Right, Location = new Point(740, 3) };
|
||
close.FlatAppearance.BorderSize = 0;
|
||
close.Click += delegate { Close(); };
|
||
pnlHeader.Controls.Add(title);
|
||
pnlHeader.Controls.Add(close);
|
||
|
||
navAppearance = MakeNavButton("外观", 8);
|
||
navFonts = MakeNavButton("字体与字号", 48);
|
||
navAppearance.Click += navAppearance_Click;
|
||
navFonts.Click += navFonts_Click;
|
||
pnlNavigation.Controls.Add(navFonts);
|
||
pnlNavigation.Controls.Add(navAppearance);
|
||
|
||
pnlAppearance = MakePage();
|
||
pnlFonts = MakePage();
|
||
pnlFonts.Visible = false;
|
||
pnlContent.Controls.Add(pnlFonts);
|
||
pnlContent.Controls.Add(pnlAppearance);
|
||
BuildAppearancePage();
|
||
BuildFontsPage();
|
||
|
||
Panel footer = new Panel { Dock = DockStyle.Bottom, Height = 48, BackColor = Color.White, BorderStyle = BorderStyle.FixedSingle };
|
||
btnReset = MakeFooterButton("恢复默认", 12);
|
||
btnCancel = MakeFooterButton("取消", 610);
|
||
btnSave = MakeFooterButton("保存", 690);
|
||
btnReset.Click += btnReset_Click;
|
||
btnCancel.Click += btnCancel_Click;
|
||
btnSave.Click += btnSave_Click;
|
||
footer.Controls.Add(btnReset);
|
||
footer.Controls.Add(btnCancel);
|
||
footer.Controls.Add(btnSave);
|
||
Controls.Add(footer);
|
||
ShowPage(pnlAppearance);
|
||
}
|
||
|
||
private Button MakeNavButton(string text, int top)
|
||
{
|
||
return new Button { Text = text, TextAlign = ContentAlignment.MiddleLeft, Padding = new Padding(14, 0, 0, 0), FlatStyle = FlatStyle.Flat, ForeColor = Color.FromArgb(50, 70, 95), BackColor = Color.Transparent, Size = new Size(160, 36), Location = new Point(8, top) };
|
||
}
|
||
|
||
private Button MakeFooterButton(string text, int left)
|
||
{
|
||
return new Button { Text = text, FlatStyle = FlatStyle.Flat, BackColor = Color.White, ForeColor = Color.FromArgb(65, 85, 110), Size = new Size(70, 30), Location = new Point(left, 8), Anchor = AnchorStyles.Right | AnchorStyles.Top };
|
||
}
|
||
|
||
private Panel MakePage() { return new Panel { Dock = DockStyle.Fill, BackColor = Color.White }; }
|
||
|
||
private Label MakeLabel(string text, int top)
|
||
{
|
||
return new Label { Text = text, AutoSize = true, Location = new Point(2, top + 7), ForeColor = Color.FromArgb(35, 48, 65), Font = new Font("Microsoft YaHei", 9F) };
|
||
}
|
||
|
||
private void AddRow(Panel page, Label label, System.Windows.Forms.Control editor, int top)
|
||
{
|
||
Panel row = new Panel { Height = 64, Width = 560, Location = new Point(0, top), Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right, BorderStyle = BorderStyle.FixedSingle, BackColor = Color.White };
|
||
label.Location = new Point(20, 22);
|
||
row.Controls.Add(label);
|
||
editor.Location = new Point(318, 16);
|
||
row.Controls.Add(editor);
|
||
page.Controls.Add(row);
|
||
row.BringToFront();
|
||
}
|
||
|
||
private void BuildAppearancePage()
|
||
{
|
||
Label heading = new Label { Text = "外观", Dock = DockStyle.Top, Height = 38, Padding = new Padding(2, 11, 0, 0), ForeColor = Color.FromArgb(45, 65, 90) };
|
||
pnlAppearance.Controls.Add(heading);
|
||
txtTopColor = MakeColorText(); pnlTopPreview = MakePreview(); btnTopColor = MakeChooseButton();
|
||
AddRow(pnlAppearance, MakeLabel("顶部菜单背景色", 0), MakeColorEditor(txtTopColor, pnlTopPreview, btnTopColor), 38);
|
||
btnTopColor.Click += btnTopColor_Click; txtTopColor.TextChanged += txtColor_TextChanged;
|
||
txtLeftColor = MakeColorText(); pnlLeftPreview = MakePreview(); btnLeftColor = MakeChooseButton();
|
||
AddRow(pnlAppearance, MakeLabel("左侧菜单背景色", 0), MakeColorEditor(txtLeftColor, pnlLeftPreview, btnLeftColor), 102);
|
||
btnLeftColor.Click += btnLeftColor_Click; txtLeftColor.TextChanged += txtColor_TextChanged;
|
||
txtLeftSelectColor = MakeColorText(); pnlLeftSelectPreview = MakePreview(); btnLeftSelectColor = MakeChooseButton();
|
||
AddRow(pnlAppearance, MakeLabel("左侧菜单选中背景色", 0), MakeColorEditor(txtLeftSelectColor, pnlLeftSelectPreview, btnLeftSelectColor), 166);
|
||
btnLeftSelectColor.Click += btnLeftSelectColor_Click; txtLeftSelectColor.TextChanged += txtColor_TextChanged;
|
||
}
|
||
|
||
private void BuildFontsPage()
|
||
{
|
||
Label heading = new Label { Text = "字体与字号", Dock = DockStyle.Top, Height = 38, Padding = new Padding(2, 11, 0, 0), ForeColor = Color.FromArgb(45, 65, 90) };
|
||
pnlFonts.Controls.Add(heading);
|
||
numTopFont = MakeNumber(); numLeftFont = MakeNumber();
|
||
AddRow(pnlFonts, MakeLabel("顶部菜单字号", 0), numTopFont, 38);
|
||
AddRow(pnlFonts, MakeLabel("左侧菜单字号", 0), numLeftFont, 102);
|
||
}
|
||
|
||
private TextBox MakeColorText() { return new TextBox { Width = 130, Height = 24, BorderStyle = BorderStyle.FixedSingle }; }
|
||
private Panel MakePreview() { return new Panel { Width = 24, Height = 22, BorderStyle = BorderStyle.FixedSingle }; }
|
||
private Button MakeChooseButton() { return new Button { Text = "选择", Width = 52, Height = 24, FlatStyle = FlatStyle.Flat }; }
|
||
|
||
private Panel MakeColorEditor(TextBox text, Panel preview, Button choose)
|
||
{
|
||
Panel p = new Panel { Width = 260, Height = 28 };
|
||
text.Location = new Point(0, 1); preview.Location = new Point(136, 1); choose.Location = new Point(166, 0);
|
||
p.Controls.Add(text); p.Controls.Add(preview); p.Controls.Add(choose); return p;
|
||
}
|
||
|
||
private NumericUpDown MakeNumber() { return new NumericUpDown { Width = 220, Minimum = 8, Maximum = 24, Value = 12, BorderStyle = BorderStyle.FixedSingle }; }
|
||
|
||
private void ShowPage(System.Windows.Forms.Control page)
|
||
{
|
||
if (pnlAppearance == null || pnlFonts == null) return;
|
||
pnlAppearance.Visible = page == pnlAppearance;
|
||
pnlFonts.Visible = page == pnlFonts;
|
||
if (navAppearance != null) navAppearance.BackColor = pnlAppearance.Visible ? Color.FromArgb(229, 239, 250) : Color.Transparent;
|
||
if (navFonts != null) navFonts.BackColor = pnlFonts.Visible ? Color.FromArgb(229, 239, 250) : Color.Transparent;
|
||
}
|
||
}
|
||
}
|