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

View File

@ -34,55 +34,39 @@
components = new System.ComponentModel.Container();
noteContent = new System.Windows.Forms.Label();
noteDate = new System.Windows.Forms.Label();
buttonClose = new System.Windows.Forms.PictureBox();
buttonMenu = new System.Windows.Forms.PictureBox();
buttonMenu = new UISymbolButton();
menu = new System.Windows.Forms.ContextMenuStrip(components);
closeAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
noteTitle = new System.Windows.Forms.Label();
noteTitle = new UIPanel();
idLabel = new System.Windows.Forms.Label();
icon = new UISymbolLabel();
((System.ComponentModel.ISupportInitialize)buttonClose).BeginInit();
((System.ComponentModel.ISupportInitialize)buttonMenu).BeginInit();
buttonClose = new UISymbolButton();
menu.SuspendLayout();
SuspendLayout();
//
// noteContent
//
noteContent.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold);
noteContent.Image = Properties.Resources.notifier;
noteContent.Location = new System.Drawing.Point(43, 30);
noteContent.BackColor = System.Drawing.Color.Transparent;
noteContent.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
noteContent.Location = new System.Drawing.Point(69, 48);
noteContent.MaximumSize = new System.Drawing.Size(288, 100);
noteContent.Name = "noteContent";
noteContent.Size = new System.Drawing.Size(270, 73);
noteContent.Size = new System.Drawing.Size(288, 100);
noteContent.TabIndex = 3;
noteContent.Text = "Description";
noteContent.Text = "Desc";
noteContent.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
noteContent.Click += noteContent_Click;
//
// noteDate
//
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.Location = new System.Drawing.Point(11, 97);
noteDate.Location = new System.Drawing.Point(19, 168);
noteDate.Name = "noteDate";
noteDate.Size = new System.Drawing.Size(13, 9);
noteDate.Size = new System.Drawing.Size(65, 12);
noteDate.TabIndex = 4;
noteDate.Text = "- -";
//
// 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;
noteDate.Text = "2024-01-01";
//
// buttonMenu
//
@ -90,11 +74,18 @@
buttonMenu.BackgroundImage = Properties.Resources.menu;
buttonMenu.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
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.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.TabStop = false;
buttonMenu.TipsFont = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
buttonMenu.Click += onMenuClick;
//
// menu
@ -102,36 +93,42 @@
menu.ImageScalingSize = new System.Drawing.Size(24, 24);
menu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { closeAllToolStripMenuItem });
menu.Name = "menu";
menu.Size = new System.Drawing.Size(120, 26);
menu.Size = new System.Drawing.Size(148, 26);
//
// 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.Size = new System.Drawing.Size(119, 22);
closeAllToolStripMenuItem.Size = new System.Drawing.Size(147, 22);
closeAllToolStripMenuItem.Text = "Close All";
closeAllToolStripMenuItem.Click += onMenuCloseAllClick;
//
// noteTitle
//
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.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.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.Text = "Note";
noteTitle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
noteTitle.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
//
// idLabel
//
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.Location = new System.Drawing.Point(296, 103);
idLabel.Location = new System.Drawing.Point(331, 168);
idLabel.Name = "idLabel";
idLabel.Size = new System.Drawing.Size(21, 9);
idLabel.Size = new System.Drawing.Size(29, 12);
idLabel.TabIndex = 7;
idLabel.Text = "0000";
idLabel.Visible = false;
@ -140,33 +137,53 @@
//
icon.BackColor = System.Drawing.Color.White;
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.Name = "icon";
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.StyleCustomMode = true;
icon.Symbol = 361528;
icon.SymbolColor = System.Drawing.Color.FromArgb(90, 140, 230);
icon.SymbolSize = 36;
icon.SymbolSize = 45;
icon.TabIndex = 8;
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
//
AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
BackColor = System.Drawing.Color.White;
BackgroundImage = Properties.Resources.notifier;
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(idLabel);
Controls.Add(buttonMenu);
Controls.Add(noteTitle);
Controls.Add(noteDate);
Controls.Add(noteContent);
Controls.Add(buttonClose);
Controls.Add(noteTitle);
DoubleBuffered = true;
FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
Name = "UINotifier";
@ -179,23 +196,20 @@
MouseDown += OnMouseDown;
MouseMove += OnMouseMove;
MouseUp += OnMouseUp;
((System.ComponentModel.ISupportInitialize)buttonClose).EndInit();
((System.ComponentModel.ISupportInitialize)buttonMenu).EndInit();
menu.ResumeLayout(false);
ResumeLayout(false);
PerformLayout();
}
#endregion
private System.Windows.Forms.PictureBox buttonClose;
private System.Windows.Forms.PictureBox buttonMenu;
private Sunny.UI.UISymbolButton buttonMenu;
private System.Windows.Forms.Label noteContent;
private System.Windows.Forms.Label noteDate;
private System.Windows.Forms.ContextMenuStrip menu;
private System.Windows.Forms.ToolStripMenuItem closeAllToolStripMenuItem;
private System.Windows.Forms.Label noteTitle;
private Sunny.UI.UIPanel noteTitle;
private System.Windows.Forms.Label idLabel;
private UISymbolLabel icon;
private Sunny.UI.UISymbolButton buttonClose;
}
}