/// <summary> /// Apply theme / language /// </summary> internal void UpdateUI() { // Apply current theme ------------------------------------------------------ OnDpiChanged(); SetColors(Configs.Theme); // Remove white line under tool strip toolPageNav.Renderer = new UI.Renderers.ToolStripRenderer(Configs.Theme.ToolbarBackgroundColor, Configs.Theme.TextInfoColor); toolPageNav.BackgroundImage = Configs.Theme.ToolbarBackgroundImage.Image; toolPageNav.BackColor = Configs.Theme.ToolbarBackgroundColor; toolPageNav.Alignment = ToolbarAlignment.CENTER; // Overflow button and Overflow dropdown toolPageNav.OverflowButton.DropDown.BackColor = Configs.Theme.ToolbarBackgroundColor; toolPageNav.OverflowButton.AutoSize = false; toolPageNav.OverflowButton.Padding = new Padding(DPIScaling.Transform(10)); lblFormTitle.Text = Configs.Language.Items[$"{nameof(frmMain)}.mnuMainPageNav"]; btnNextPage.ToolTipText = Configs.Language.Items[$"{nameof(frmMain)}.mnuMainNextPage"]; btnPreviousPage.ToolTipText = Configs.Language.Items[$"{nameof(frmMain)}.mnuMainPrevPage"]; btnFirstPage.ToolTipText = Configs.Language.Items[$"{nameof(frmMain)}.mnuMainFirstPage"]; btnLastPage.ToolTipText = Configs.Language.Items[$"{nameof(frmMain)}.mnuMainLastPage"]; btnSnapTo.FlatAppearance.MouseOverBackColor = Theme.LightenColor(Configs.Theme.BackgroundColor, 0.1f); btnSnapTo.FlatAppearance.MouseDownBackColor = Theme.DarkenColor(Configs.Theme.BackgroundColor, 0.1f); }
protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) { var textColor = e.Item.Selected ? theme.MenuTextHoverColor : theme.MenuTextColor; if (!e.Item.Enabled) { if (theme.MenuBackgroundColor.GetBrightness() > 0.5) //light background color { textColor = Theme.DarkenColor(theme.MenuBackgroundColor, 0.5f); } else //dark background color { textColor = Theme.LightenColor(theme.MenuBackgroundColor, 0.5f); } } using var pen = new Pen(textColor, DPIScaling.Transform <float>(1)); e.Graphics.SmoothingMode = SmoothingMode.HighQuality; e.Graphics.DrawLine(pen, e.Item.Width - (5 * e.Item.Height / 8), 3 * e.Item.Height / 8, e.Item.Width - (4 * e.Item.Height / 8), e.Item.Height / 2); e.Graphics.DrawLine(pen, e.Item.Width - (4 * e.Item.Height / 8), e.Item.Height / 2, e.Item.Width - (5 * e.Item.Height / 8), 5 * e.Item.Height / 8); // Render ShortcutKeyDisplayString for menu item with dropdown if (e.Item is ToolStripMenuItem) { var mnu = e.Item as ToolStripMenuItem; if (!string.IsNullOrWhiteSpace(mnu.ShortcutKeyDisplayString)) { var shortcutSize = e.Graphics.MeasureString(mnu.ShortcutKeyDisplayString, mnu.Font); var shortcutRect = new RectangleF(e.ArrowRectangle.X - shortcutSize.Width - DPIScaling.Transform <float>(13), e.Item.Height / 2 - shortcutSize.Height / 2, shortcutSize.Width, shortcutSize.Height); e.Graphics.DrawString(mnu.ShortcutKeyDisplayString, e.Item.Font, new SolidBrush(textColor), shortcutRect); } } }
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) { var textColor = e.Item.Selected ? theme.MenuTextHoverColor : theme.MenuTextColor; using var pen = new Pen(textColor, DPIScaling.Transform <float>(2)); e.Graphics.DrawLine(pen, (2 * e.Item.Height / 10) + 1, e.Item.Height / 2, (4 * e.Item.Height / 10) + 1, 7 * e.Item.Height / 10); e.Graphics.DrawLine(pen, 4 * e.Item.Height / 10, 7 * e.Item.Height / 10, 8 * e.Item.Height / 10, 3 * e.Item.Height / 10); }
protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) { var textColor = e.Item.Selected ? theme.MenuTextHoverColor : theme.MenuTextColor; using var pen = new Pen(textColor, DPIScaling.Transform <float>(1)); e.Graphics.DrawLine(pen, e.Item.Width - (5 * e.Item.Height / 8), 3 * e.Item.Height / 8, e.Item.Width - (4 * e.Item.Height / 8), e.Item.Height / 2); e.Graphics.DrawLine(pen, e.Item.Width - (4 * e.Item.Height / 8), e.Item.Height / 2, e.Item.Width - (5 * e.Item.Height / 8), 5 * e.Item.Height / 8); // Render ShortcutKeyDisplayString for menu item with dropdown if (e.Item is ToolStripMenuItem) { var mnu = e.Item as ToolStripMenuItem; if (!string.IsNullOrWhiteSpace(mnu.ShortcutKeyDisplayString)) { var shortcutSize = e.Graphics.MeasureString(mnu.ShortcutKeyDisplayString, mnu.Font); var shortcutRect = new RectangleF(e.ArrowRectangle.X - shortcutSize.Width - DPIScaling.Transform <float>(13), e.Item.Height / 2 - shortcutSize.Height / 2, shortcutSize.Width, shortcutSize.Height); e.Graphics.DrawString(mnu.ShortcutKeyDisplayString, e.Item.Font, new SolidBrush(textColor), shortcutRect); } } }