* UINotifier: 调整窗体及字体大小

This commit is contained in:
Sunny 2024-06-03 22:04:06 +08:00
parent 660cf54146
commit 0aafb6e897
2 changed files with 76 additions and 99 deletions

View File

@ -46,11 +46,8 @@ namespace Sunny.UI
noteTitle.Font = noteTitle.Font.DPIScaleFont(noteTitle.Font.Size); noteTitle.Font = noteTitle.Font.DPIScaleFont(noteTitle.Font.Size);
noteContent.Font = noteContent.Font.DPIScaleFont(noteContent.Font.Size); noteContent.Font = noteContent.Font.DPIScaleFont(noteContent.Font.Size);
noteDate.Font = noteDate.Font.DPIScaleFont(noteDate.Font.Size); noteDate.Font = noteDate.Font.DPIScaleFont(noteDate.Font.Size);
buttonMenu.Font = noteDate.Font.DPIScaleFont(buttonMenu.Font.Size);
foreach (var control in this.GetAllDPIScaleControls()) buttonClose.Font = noteDate.Font.DPIScaleFont(buttonClose.Font.Size);
{
control.SetDPIScale();
}
} }
#region GLOBALS #region GLOBALS
@ -180,6 +177,7 @@ namespace Sunny.UI
icon.SymbolColor = UIStyles.Red.ButtonFillColor; icon.SymbolColor = UIStyles.Red.ButtonFillColor;
LeaveColor = UIStyles.Red.ButtonFillColor; LeaveColor = UIStyles.Red.ButtonFillColor;
HoverColor = UIStyles.Red.ButtonFillHoverColor; HoverColor = UIStyles.Red.ButtonFillHoverColor;
buttonMenu.Style = buttonClose.Style = noteTitle.Style = UIStyle.Red;
break; break;
case UINotifierType.INFO: case UINotifierType.INFO:
@ -187,6 +185,7 @@ namespace Sunny.UI
icon.SymbolColor = UIStyles.Blue.ButtonFillColor; icon.SymbolColor = UIStyles.Blue.ButtonFillColor;
LeaveColor = UIStyles.Blue.ButtonFillColor; LeaveColor = UIStyles.Blue.ButtonFillColor;
HoverColor = UIStyles.Blue.ButtonFillHoverColor; HoverColor = UIStyles.Blue.ButtonFillHoverColor;
buttonMenu.Style = buttonClose.Style = noteTitle.Style = UIStyle.Blue;
break; break;
case UINotifierType.WARNING: case UINotifierType.WARNING:
@ -194,6 +193,7 @@ namespace Sunny.UI
icon.SymbolColor = UIStyles.Orange.ButtonFillColor; icon.SymbolColor = UIStyles.Orange.ButtonFillColor;
LeaveColor = UIStyles.Orange.ButtonFillColor; LeaveColor = UIStyles.Orange.ButtonFillColor;
HoverColor = UIStyles.Orange.ButtonFillHoverColor; HoverColor = UIStyles.Orange.ButtonFillHoverColor;
buttonMenu.Style = buttonClose.Style = noteTitle.Style = UIStyle.Orange;
break; break;
case UINotifierType.OK: case UINotifierType.OK:
@ -201,49 +201,12 @@ namespace Sunny.UI
icon.SymbolColor = UIStyles.Green.ButtonFillColor; icon.SymbolColor = UIStyles.Green.ButtonFillColor;
LeaveColor = UIStyles.Green.ButtonFillColor; LeaveColor = UIStyles.Green.ButtonFillColor;
HoverColor = UIStyles.Green.ButtonFillHoverColor; HoverColor = UIStyles.Green.ButtonFillHoverColor;
buttonMenu.Style = buttonClose.Style = noteTitle.Style = UIStyle.Green;
break; break;
} }
buttonClose.BackColor = LeaveColor; // Init colors noteTitle.FillColor = noteTitle.RectColor;
buttonMenu.BackColor = LeaveColor; noteTitle.ForeColor = Color.White;
noteTitle.BackColor = LeaveColor;
buttonClose.MouseHover += (s, e) => // Mouse hover
{
buttonClose.BackColor = HoverColor;
buttonMenu.BackColor = HoverColor;
noteTitle.BackColor = HoverColor;
};
buttonMenu.MouseHover += (s, e) =>
{
buttonMenu.BackColor = HoverColor;
buttonClose.BackColor = HoverColor;
noteTitle.BackColor = HoverColor;
}; noteTitle.MouseHover += (s, e) =>
{
buttonMenu.BackColor = HoverColor;
buttonClose.BackColor = HoverColor;
noteTitle.BackColor = HoverColor;
};
buttonClose.MouseLeave += (s, e) => // Mouse leave
{
buttonClose.BackColor = LeaveColor;
buttonMenu.BackColor = LeaveColor;
noteTitle.BackColor = LeaveColor;
};
buttonMenu.MouseLeave += (s, e) =>
{
buttonMenu.BackColor = LeaveColor;
buttonClose.BackColor = LeaveColor;
noteTitle.BackColor = LeaveColor;
};
noteTitle.MouseLeave += (s, e) =>
{
buttonMenu.BackColor = LeaveColor;
buttonClose.BackColor = LeaveColor;
noteTitle.BackColor = LeaveColor;
};
#endregion ADJUST COLORS #endregion ADJUST COLORS
@ -252,14 +215,14 @@ namespace Sunny.UI
if (IsDialog) if (IsDialog)
{ {
Button ok_button = new Button(); // Dialog note comes with a simple Ok button Button ok_button = new Button(); // Dialog note comes with a simple Ok button
ok_button.Font = noteTitle.Font;
ok_button.FlatStyle = FlatStyle.Flat; ok_button.FlatStyle = FlatStyle.Flat;
ok_button.BackColor = LeaveColor; ok_button.BackColor = LeaveColor;
ok_button.ForeColor = Color.White; ok_button.ForeColor = Color.White;
Size = new Size(Size.Width, // Resize the note to contain the button Size = new Size(Size.Width, // Resize the note to contain the button
Size.Height + 50); Size.Height + 50);
ok_button.Size = new Size(120, 40); ok_button.Size = new Size(120, 40);
ok_button.Location = new Point(Size.Width / 2 - ok_button.Size.Width / 2, ok_button.Location = new Point(noteContent.Right - ok_button.Width, Size.Height - 55);
Size.Height - 50);
ok_button.Text = UILocalize.OK; ok_button.Text = UILocalize.OK;
ok_button.Click += onOkButtonClick; ok_button.Click += onOkButtonClick;
Controls.Add(ok_button); Controls.Add(ok_button);

View File

@ -34,55 +34,39 @@
components = new System.ComponentModel.Container(); components = new System.ComponentModel.Container();
noteContent = new System.Windows.Forms.Label(); noteContent = new System.Windows.Forms.Label();
noteDate = new System.Windows.Forms.Label(); noteDate = new System.Windows.Forms.Label();
buttonClose = new System.Windows.Forms.PictureBox(); buttonMenu = new UISymbolButton();
buttonMenu = new System.Windows.Forms.PictureBox();
menu = new System.Windows.Forms.ContextMenuStrip(components); menu = new System.Windows.Forms.ContextMenuStrip(components);
closeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); closeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
noteTitle = new System.Windows.Forms.Label(); noteTitle = new UIPanel();
idLabel = new System.Windows.Forms.Label(); idLabel = new System.Windows.Forms.Label();
icon = new UISymbolLabel(); icon = new UISymbolLabel();
((System.ComponentModel.ISupportInitialize)buttonClose).BeginInit(); buttonClose = new UISymbolButton();
((System.ComponentModel.ISupportInitialize)buttonMenu).BeginInit();
menu.SuspendLayout(); menu.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// noteContent // noteContent
// //
noteContent.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold); noteContent.BackColor = System.Drawing.Color.Transparent;
noteContent.Image = Properties.Resources.notifier; noteContent.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
noteContent.Location = new System.Drawing.Point(43, 30); noteContent.Location = new System.Drawing.Point(69, 48);
noteContent.MaximumSize = new System.Drawing.Size(288, 100);
noteContent.Name = "noteContent"; noteContent.Name = "noteContent";
noteContent.Size = new System.Drawing.Size(270, 73); noteContent.Size = new System.Drawing.Size(288, 100);
noteContent.TabIndex = 3; noteContent.TabIndex = 3;
noteContent.Text = "Description"; noteContent.Text = "Desc";
noteContent.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; noteContent.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
noteContent.Click += noteContent_Click; noteContent.Click += noteContent_Click;
// //
// noteDate // noteDate
// //
noteDate.AutoSize = true; noteDate.AutoSize = true;
noteDate.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F); noteDate.Font = new System.Drawing.Font("宋体", 9F);
noteDate.Image = Properties.Resources.notifier; noteDate.Image = Properties.Resources.notifier;
noteDate.Location = new System.Drawing.Point(11, 97); noteDate.Location = new System.Drawing.Point(19, 168);
noteDate.Name = "noteDate"; noteDate.Name = "noteDate";
noteDate.Size = new System.Drawing.Size(13, 9); noteDate.Size = new System.Drawing.Size(65, 12);
noteDate.TabIndex = 4; noteDate.TabIndex = 4;
noteDate.Text = "- -"; noteDate.Text = "2024-01-01";
//
// buttonClose
//
buttonClose.BackColor = System.Drawing.Color.FromArgb(90, 140, 230);
buttonClose.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
buttonClose.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold);
buttonClose.ForeColor = System.Drawing.Color.White;
buttonClose.Location = new System.Drawing.Point(256, 2);
buttonClose.Name = "buttonClose";
buttonClose.Size = new System.Drawing.Size(66, 24);
buttonClose.TabIndex = 1;
buttonClose.TabStop = false;
buttonClose.Text = " Calibrator";
buttonClose.Click += onCloseClick;
buttonClose.Paint += OnPaint;
// //
// buttonMenu // buttonMenu
// //
@ -90,11 +74,18 @@
buttonMenu.BackgroundImage = Properties.Resources.menu; buttonMenu.BackgroundImage = Properties.Resources.menu;
buttonMenu.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; buttonMenu.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
buttonMenu.ContextMenuStrip = menu; buttonMenu.ContextMenuStrip = menu;
buttonMenu.Location = new System.Drawing.Point(275, 2); buttonMenu.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
buttonMenu.Location = new System.Drawing.Point(295, 2);
buttonMenu.MinimumSize = new System.Drawing.Size(1, 1);
buttonMenu.Name = "buttonMenu"; buttonMenu.Name = "buttonMenu";
buttonMenu.Size = new System.Drawing.Size(24, 24); buttonMenu.RadiusSides = UICornerRadiusSides.None;
buttonMenu.Size = new System.Drawing.Size(40, 35);
buttonMenu.Style = UIStyle.Custom;
buttonMenu.Symbol = 361641;
buttonMenu.SymbolOffset = new System.Drawing.Point(-1, 1);
buttonMenu.TabIndex = 5; buttonMenu.TabIndex = 5;
buttonMenu.TabStop = false; buttonMenu.TabStop = false;
buttonMenu.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
buttonMenu.Click += onMenuClick; buttonMenu.Click += onMenuClick;
// //
// menu // menu
@ -102,36 +93,42 @@
menu.ImageScalingSize = new System.Drawing.Size(24, 24); menu.ImageScalingSize = new System.Drawing.Size(24, 24);
menu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { closeAllToolStripMenuItem }); menu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { closeAllToolStripMenuItem });
menu.Name = "menu"; menu.Name = "menu";
menu.Size = new System.Drawing.Size(120, 26); menu.Size = new System.Drawing.Size(148, 26);
// //
// closeAllToolStripMenuItem // closeAllToolStripMenuItem
// //
closeAllToolStripMenuItem.Font = new System.Drawing.Font("Segoe UI", 8.25F); closeAllToolStripMenuItem.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
closeAllToolStripMenuItem.Name = "closeAllToolStripMenuItem"; closeAllToolStripMenuItem.Name = "closeAllToolStripMenuItem";
closeAllToolStripMenuItem.Size = new System.Drawing.Size(119, 22); closeAllToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
closeAllToolStripMenuItem.Text = "Close All"; closeAllToolStripMenuItem.Text = "Close All";
closeAllToolStripMenuItem.Click += onMenuCloseAllClick; closeAllToolStripMenuItem.Click += onMenuCloseAllClick;
// //
// noteTitle // noteTitle
// //
noteTitle.BackColor = System.Drawing.Color.FromArgb(90, 140, 230); noteTitle.BackColor = System.Drawing.Color.FromArgb(90, 140, 230);
noteTitle.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold); noteTitle.FillColor = System.Drawing.Color.FromArgb(80, 160, 255);
noteTitle.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
noteTitle.ForeColor = System.Drawing.Color.White; noteTitle.ForeColor = System.Drawing.Color.White;
noteTitle.Location = new System.Drawing.Point(2, 2); noteTitle.Location = new System.Drawing.Point(2, 2);
noteTitle.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
noteTitle.MinimumSize = new System.Drawing.Size(1, 1);
noteTitle.Name = "noteTitle"; noteTitle.Name = "noteTitle";
noteTitle.Size = new System.Drawing.Size(270, 24); noteTitle.Padding = new System.Windows.Forms.Padding(6, 0, 0, 0);
noteTitle.RadiusSides = UICornerRadiusSides.None;
noteTitle.Size = new System.Drawing.Size(374, 35);
noteTitle.Style = UIStyle.Custom;
noteTitle.TabIndex = 6; noteTitle.TabIndex = 6;
noteTitle.Text = "Note"; noteTitle.Text = "Note";
noteTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; noteTitle.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
// //
// idLabel // idLabel
// //
idLabel.AutoSize = true; idLabel.AutoSize = true;
idLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 6F); idLabel.Font = new System.Drawing.Font("宋体", 9F);
idLabel.Image = Properties.Resources.notifier; idLabel.Image = Properties.Resources.notifier;
idLabel.Location = new System.Drawing.Point(296, 103); idLabel.Location = new System.Drawing.Point(331, 168);
idLabel.Name = "idLabel"; idLabel.Name = "idLabel";
idLabel.Size = new System.Drawing.Size(21, 9); idLabel.Size = new System.Drawing.Size(29, 12);
idLabel.TabIndex = 7; idLabel.TabIndex = 7;
idLabel.Text = "0000"; idLabel.Text = "0000";
idLabel.Visible = false; idLabel.Visible = false;
@ -140,33 +137,53 @@
// //
icon.BackColor = System.Drawing.Color.White; icon.BackColor = System.Drawing.Color.White;
icon.Font = new System.Drawing.Font("宋体", 12F); icon.Font = new System.Drawing.Font("宋体", 12F);
icon.Location = new System.Drawing.Point(10, 51); icon.Location = new System.Drawing.Point(11, 79);
icon.MinimumSize = new System.Drawing.Size(1, 1); icon.MinimumSize = new System.Drawing.Size(1, 1);
icon.Name = "icon"; icon.Name = "icon";
icon.Padding = new System.Windows.Forms.Padding(40, 0, 0, 0); icon.Padding = new System.Windows.Forms.Padding(40, 0, 0, 0);
icon.Size = new System.Drawing.Size(32, 30); icon.Size = new System.Drawing.Size(40, 40);
icon.Style = UIStyle.Custom; icon.Style = UIStyle.Custom;
icon.StyleCustomMode = true; icon.StyleCustomMode = true;
icon.Symbol = 361528; icon.Symbol = 361528;
icon.SymbolColor = System.Drawing.Color.FromArgb(90, 140, 230); icon.SymbolColor = System.Drawing.Color.FromArgb(90, 140, 230);
icon.SymbolSize = 36; icon.SymbolSize = 45;
icon.TabIndex = 8; icon.TabIndex = 8;
icon.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; icon.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
// //
// buttonClose
//
buttonClose.BackColor = System.Drawing.Color.FromArgb(90, 140, 230);
buttonClose.Font = new System.Drawing.Font("宋体", 12F);
buttonClose.Location = new System.Drawing.Point(335, 2);
buttonClose.MinimumSize = new System.Drawing.Size(1, 1);
buttonClose.Name = "buttonClose";
buttonClose.Padding = new System.Windows.Forms.Padding(40, 0, 0, 0);
buttonClose.RadiusSides = UICornerRadiusSides.None;
buttonClose.Size = new System.Drawing.Size(40, 35);
buttonClose.Style = UIStyle.Custom;
buttonClose.StyleCustomMode = true;
buttonClose.Symbol = 361453;
buttonClose.SymbolOffset = new System.Drawing.Point(0, 1);
buttonClose.SymbolSize = 26;
buttonClose.TabIndex = 9;
buttonClose.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
buttonClose.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
buttonClose.Click += onCloseClick;
//
// UINotifier // UINotifier
// //
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
BackColor = System.Drawing.Color.White; BackColor = System.Drawing.Color.White;
BackgroundImage = Properties.Resources.notifier; BackgroundImage = Properties.Resources.notifier;
BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
ClientSize = new System.Drawing.Size(324, 117); ClientSize = new System.Drawing.Size(378, 204);
Controls.Add(buttonClose);
Controls.Add(icon); Controls.Add(icon);
Controls.Add(idLabel); Controls.Add(idLabel);
Controls.Add(buttonMenu); Controls.Add(buttonMenu);
Controls.Add(noteTitle);
Controls.Add(noteDate); Controls.Add(noteDate);
Controls.Add(noteContent); Controls.Add(noteContent);
Controls.Add(buttonClose); Controls.Add(noteTitle);
DoubleBuffered = true; DoubleBuffered = true;
FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
Name = "UINotifier"; Name = "UINotifier";
@ -179,23 +196,20 @@
MouseDown += OnMouseDown; MouseDown += OnMouseDown;
MouseMove += OnMouseMove; MouseMove += OnMouseMove;
MouseUp += OnMouseUp; MouseUp += OnMouseUp;
((System.ComponentModel.ISupportInitialize)buttonClose).EndInit();
((System.ComponentModel.ISupportInitialize)buttonMenu).EndInit();
menu.ResumeLayout(false); menu.ResumeLayout(false);
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }
#endregion #endregion
private Sunny.UI.UISymbolButton buttonMenu;
private System.Windows.Forms.PictureBox buttonClose;
private System.Windows.Forms.PictureBox buttonMenu;
private System.Windows.Forms.Label noteContent; private System.Windows.Forms.Label noteContent;
private System.Windows.Forms.Label noteDate; private System.Windows.Forms.Label noteDate;
private System.Windows.Forms.ContextMenuStrip menu; private System.Windows.Forms.ContextMenuStrip menu;
private System.Windows.Forms.ToolStripMenuItem closeAllToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem closeAllToolStripMenuItem;
private System.Windows.Forms.Label noteTitle; private Sunny.UI.UIPanel noteTitle;
private System.Windows.Forms.Label idLabel; private System.Windows.Forms.Label idLabel;
private UISymbolLabel icon; private UISymbolLabel icon;
private Sunny.UI.UISymbolButton buttonClose;
} }
} }