minor visual touchups
This commit is contained in:
parent
91880aa698
commit
4b6572d398
3 changed files with 91 additions and 67 deletions
|
@ -4,6 +4,8 @@ using System.Drawing;
|
|||
using System.Windows.Forms;
|
||||
using System.Windows.Forms.VisualStyles;
|
||||
|
||||
using TreeView = System.Windows.Forms.TreeView;
|
||||
|
||||
namespace CreamInstaller.Components;
|
||||
|
||||
internal class CustomTreeView : TreeView
|
||||
|
@ -18,7 +20,7 @@ internal class CustomTreeView : TreeView
|
|||
|
||||
internal CustomTreeView() : base()
|
||||
{
|
||||
DrawMode = TreeViewDrawMode.OwnerDrawAll;
|
||||
DrawMode = TreeViewDrawMode.OwnerDrawText;
|
||||
DrawNode += new DrawTreeNodeEventHandler(DrawTreeNode);
|
||||
TreeViewNodeSorter = PlatformIdComparer.NodeName;
|
||||
}
|
||||
|
@ -27,13 +29,33 @@ internal class CustomTreeView : TreeView
|
|||
private readonly Dictionary<ProgramSelection, Rectangle> checkBoxBounds = new();
|
||||
private const string koaloaderToggleString = "Koaloader";
|
||||
|
||||
private SolidBrush backBrush;
|
||||
private void DrawTreeNode(object sender, DrawTreeNodeEventArgs e)
|
||||
{
|
||||
e.DrawDefault = true;
|
||||
TreeNode node = e.Node;
|
||||
if (!node.IsVisible)
|
||||
return;
|
||||
bool highlighted = node.IsSelected && SelectedNode == node && ContainsFocus;
|
||||
|
||||
bool highlighted = (e.State & TreeNodeStates.Selected) == TreeNodeStates.Selected && Focused;
|
||||
|
||||
Graphics graphics = e.Graphics;
|
||||
backBrush ??= new(BackColor);
|
||||
Font font = node.NodeFont ?? Font;
|
||||
|
||||
Brush brush = highlighted ? SystemBrushes.Highlight : backBrush;
|
||||
string text;// = e.Node.Text;
|
||||
Size size;
|
||||
Rectangle bounds = node.Bounds;
|
||||
Rectangle selectionBounds = bounds;
|
||||
Color color;// = highlighted ? SystemColors.HighlightText : (node.ForeColor != Color.Empty) ? node.ForeColor : node.TreeView.ForeColor;
|
||||
Point point;
|
||||
|
||||
/*Size textSize = TextRenderer.MeasureText(text, font);
|
||||
Point textLoc = new(bounds.X - 1, bounds.Y);
|
||||
bounds = new Rectangle(textLoc, new Size(textSize.Width, bounds.Height));
|
||||
graphics.FillRectangle(brush, bounds);
|
||||
TextRenderer.DrawText(graphics, text, font, bounds, color, TextFormatFlags.Default);*/
|
||||
|
||||
Form form = FindForm();
|
||||
if (form is not SelectForm and not SelectDialogForm)
|
||||
|
@ -44,63 +66,65 @@ internal class CustomTreeView : TreeView
|
|||
if (string.IsNullOrWhiteSpace(platformId) || platform is Platform.None)
|
||||
return;
|
||||
|
||||
Graphics graphics = e.Graphics;
|
||||
using SolidBrush backBrush = new(BackColor);
|
||||
using SolidBrush highlightBrush = new(SystemColors.Highlight);
|
||||
Font font = Font;
|
||||
Size lastSize;
|
||||
Rectangle lastBounds = node.Bounds;
|
||||
Rectangle selectionBounds = lastBounds;
|
||||
Point lastPoint;
|
||||
|
||||
string tagText = platform.ToString();
|
||||
lastSize = TextRenderer.MeasureText(graphics, tagText, font);
|
||||
lastBounds = new(lastBounds.X + lastBounds.Width, lastBounds.Y, lastSize.Width, lastBounds.Height);
|
||||
selectionBounds = new(selectionBounds.Location, selectionBounds.Size + new Size(lastBounds.Size.Width, 0));
|
||||
graphics.FillRectangle(highlighted ? highlightBrush : backBrush, lastBounds);
|
||||
lastPoint = new(lastBounds.Location.X - 1, lastBounds.Location.Y + 1);
|
||||
TextRenderer.DrawText(graphics, tagText, font, lastPoint, highlighted ? ColorTranslator.FromHtml("#FFFF99") : Enabled ? ColorTranslator.FromHtml("#696900") : ColorTranslator.FromHtml("#AAAA69"));
|
||||
color = highlighted ? ColorTranslator.FromHtml("#FFFF99") : Enabled ? ColorTranslator.FromHtml("#696900") : ColorTranslator.FromHtml("#AAAA69");
|
||||
text = platform.ToString();
|
||||
size = TextRenderer.MeasureText(graphics, text, font);
|
||||
bounds = new(bounds.X + bounds.Width, bounds.Y, size.Width, bounds.Height);
|
||||
selectionBounds = new(selectionBounds.Location, selectionBounds.Size + new Size(bounds.Size.Width, 0));
|
||||
graphics.FillRectangle(brush, bounds);
|
||||
point = new(bounds.Location.X - 1, bounds.Location.Y + 1);
|
||||
TextRenderer.DrawText(graphics, text, font, point, color, TextFormatFlags.Default);
|
||||
|
||||
if (platform is not Platform.Paradox)
|
||||
{
|
||||
string subText = platformId.ToString();
|
||||
lastSize = TextRenderer.MeasureText(graphics, subText, font);
|
||||
lastBounds = new(lastBounds.X + lastBounds.Width - 4, lastBounds.Y, lastSize.Width, lastBounds.Height);
|
||||
selectionBounds = new(selectionBounds.Location, selectionBounds.Size + new Size(lastBounds.Size.Width - 4, 0));
|
||||
graphics.FillRectangle(highlighted ? highlightBrush : backBrush, lastBounds);
|
||||
lastPoint = new(lastBounds.Location.X - 1, lastBounds.Location.Y + 1);
|
||||
TextRenderer.DrawText(graphics, subText, font, lastPoint, highlighted ? ColorTranslator.FromHtml("#99FFFF") : Enabled ? ColorTranslator.FromHtml("#006969") : ColorTranslator.FromHtml("#69AAAA"));
|
||||
color = highlighted ? ColorTranslator.FromHtml("#99FFFF") : Enabled ? ColorTranslator.FromHtml("#006969") : ColorTranslator.FromHtml("#69AAAA");
|
||||
text = platformId.ToString();
|
||||
size = TextRenderer.MeasureText(graphics, text, font);
|
||||
int left = -4;
|
||||
bounds = new(bounds.X + bounds.Width + left, bounds.Y, size.Width, bounds.Height);
|
||||
selectionBounds = new(selectionBounds.Location, selectionBounds.Size + new Size(bounds.Size.Width + left, 0));
|
||||
graphics.FillRectangle(brush, bounds);
|
||||
point = new(bounds.Location.X - 1, bounds.Location.Y + 1);
|
||||
TextRenderer.DrawText(graphics, text, font, point, color, TextFormatFlags.Default);
|
||||
}
|
||||
|
||||
/*if (highlighted)
|
||||
ControlPaint.DrawFocusRectangle(graphics, selectionBounds, color, SystemColors.Highlight);*/
|
||||
|
||||
if (form is SelectForm)
|
||||
{
|
||||
ProgramSelection selection = ProgramSelection.FromPlatformId(platform, platformId);
|
||||
if (selection is not null)
|
||||
{
|
||||
if (lastBounds == node.Bounds)
|
||||
if (bounds == node.Bounds)
|
||||
{
|
||||
lastSize = new(4, 0);
|
||||
lastBounds = new(lastBounds.X + lastBounds.Width, lastBounds.Y, lastSize.Width, lastBounds.Height);
|
||||
graphics.FillRectangle(highlighted ? highlightBrush : backBrush, lastBounds);
|
||||
size = new(4, 0);
|
||||
bounds = new(bounds.X + bounds.Width, bounds.Y, size.Width, bounds.Height);
|
||||
graphics.FillRectangle(brush, bounds);
|
||||
}
|
||||
|
||||
CheckBoxState checkBoxState = selection.Koaloader ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal;
|
||||
lastSize = CheckBoxRenderer.GetGlyphSize(graphics, checkBoxState);
|
||||
lastBounds = new(lastBounds.X + lastBounds.Width, lastBounds.Y, lastSize.Width, lastBounds.Height);
|
||||
selectionBounds = new(selectionBounds.Location, selectionBounds.Size + new Size(lastBounds.Size.Width, 0));
|
||||
Rectangle checkBoxBounds = lastBounds;
|
||||
graphics.FillRectangle(backBrush, lastBounds);
|
||||
lastPoint = new(lastBounds.Left, lastBounds.Top + lastBounds.Height / 2 - lastSize.Height / 2 - 1);
|
||||
CheckBoxRenderer.DrawCheckBox(graphics, lastPoint, checkBoxState);
|
||||
CheckBoxState checkBoxState = selection.Koaloader
|
||||
? Enabled ? CheckBoxState.CheckedPressed : CheckBoxState.CheckedDisabled
|
||||
: Enabled ? CheckBoxState.UncheckedPressed : CheckBoxState.UncheckedDisabled;
|
||||
size = CheckBoxRenderer.GetGlyphSize(graphics, checkBoxState);
|
||||
bounds = new(bounds.X + bounds.Width, bounds.Y, size.Width, bounds.Height);
|
||||
selectionBounds = new(selectionBounds.Location, selectionBounds.Size + new Size(bounds.Size.Width, 0));
|
||||
Rectangle checkBoxBounds = bounds;
|
||||
graphics.FillRectangle(backBrush, bounds);
|
||||
point = new(bounds.Left, bounds.Top + bounds.Height / 2 - size.Height / 2 - 1);
|
||||
CheckBoxRenderer.DrawCheckBox(graphics, point, checkBoxState);
|
||||
|
||||
lastSize = TextRenderer.MeasureText(graphics, koaloaderToggleString, font);
|
||||
text = koaloaderToggleString;
|
||||
size = TextRenderer.MeasureText(graphics, text, font);
|
||||
int left = 1;
|
||||
lastBounds = new(lastBounds.X + lastBounds.Width, lastBounds.Y, lastSize.Width + left, lastBounds.Height);
|
||||
selectionBounds = new(selectionBounds.Location, selectionBounds.Size + new Size(lastBounds.Size.Width + left, 0));
|
||||
checkBoxBounds = new(checkBoxBounds.Location, checkBoxBounds.Size + new Size(lastBounds.Size.Width + left, 0));
|
||||
graphics.FillRectangle(backBrush, lastBounds);
|
||||
lastPoint = new(lastBounds.Location.X - 1 + left, lastBounds.Location.Y + 1);
|
||||
TextRenderer.DrawText(graphics, koaloaderToggleString, font, lastPoint, Enabled ? ColorTranslator.FromHtml("#006900") : ColorTranslator.FromHtml("#69AA69"));
|
||||
bounds = new(bounds.X + bounds.Width, bounds.Y, size.Width + left, bounds.Height);
|
||||
selectionBounds = new(selectionBounds.Location, selectionBounds.Size + new Size(bounds.Size.Width + left, 0));
|
||||
checkBoxBounds = new(checkBoxBounds.Location, checkBoxBounds.Size + new Size(bounds.Size.Width + left, 0));
|
||||
graphics.FillRectangle(backBrush, bounds);
|
||||
point = new(bounds.Location.X - 1 + left, bounds.Location.Y + 1);
|
||||
TextRenderer.DrawText(graphics, text, font, point,
|
||||
Enabled ? ColorTranslator.FromHtml("#006900") : ColorTranslator.FromHtml("#69AA69"),
|
||||
TextFormatFlags.Default);
|
||||
|
||||
this.checkBoxBounds[selection] = RectangleToClient(checkBoxBounds);
|
||||
}
|
||||
|
|
10
CreamInstaller/Forms/SelectDialogForm.Designer.cs
generated
10
CreamInstaller/Forms/SelectDialogForm.Designer.cs
generated
|
@ -94,20 +94,20 @@ namespace CreamInstaller
|
|||
this.flowLayoutPanel2.AutoSize = true;
|
||||
this.flowLayoutPanel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.flowLayoutPanel2.Controls.Add(this.allCheckBox);
|
||||
this.flowLayoutPanel2.Location = new System.Drawing.Point(366, -1);
|
||||
this.flowLayoutPanel2.Location = new System.Drawing.Point(370, -1);
|
||||
this.flowLayoutPanel2.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
|
||||
this.flowLayoutPanel2.Size = new System.Drawing.Size(37, 19);
|
||||
this.flowLayoutPanel2.Size = new System.Drawing.Size(34, 19);
|
||||
this.flowLayoutPanel2.TabIndex = 1007;
|
||||
//
|
||||
// allCheckBox
|
||||
//
|
||||
this.allCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.allCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||
this.allCheckBox.Location = new System.Drawing.Point(3, 0);
|
||||
this.allCheckBox.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.allCheckBox.Location = new System.Drawing.Point(2, 0);
|
||||
this.allCheckBox.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0);
|
||||
this.allCheckBox.Name = "allCheckBox";
|
||||
this.allCheckBox.Size = new System.Drawing.Size(34, 19);
|
||||
this.allCheckBox.Size = new System.Drawing.Size(32, 19);
|
||||
this.allCheckBox.TabIndex = 1;
|
||||
this.allCheckBox.Text = "All";
|
||||
this.allCheckBox.CheckedChanged += new System.EventHandler(this.OnAllCheckBoxChanged);
|
||||
|
|
36
CreamInstaller/Forms/SelectForm.Designer.cs
generated
36
CreamInstaller/Forms/SelectForm.Designer.cs
generated
|
@ -43,7 +43,7 @@ namespace CreamInstaller
|
|||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.blockedGamesCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.blockProtectedHelpButton = new System.Windows.Forms.Button();
|
||||
this.selectionTreeView = new CreamInstaller.Components.CustomTreeView();
|
||||
this.selectionTreeView = new Components.CustomTreeView();
|
||||
this.flowLayoutPanel2 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.allCheckBox = new System.Windows.Forms.CheckBox();
|
||||
this.progressBar = new System.Windows.Forms.ProgressBar();
|
||||
|
@ -123,10 +123,10 @@ namespace CreamInstaller
|
|||
this.flowLayoutPanel4.AutoSize = true;
|
||||
this.flowLayoutPanel4.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.flowLayoutPanel4.Controls.Add(this.koaloaderAllCheckBox);
|
||||
this.flowLayoutPanel4.Location = new System.Drawing.Point(420, -1);
|
||||
this.flowLayoutPanel4.Location = new System.Drawing.Point(430, -1);
|
||||
this.flowLayoutPanel4.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.flowLayoutPanel4.Name = "flowLayoutPanel4";
|
||||
this.flowLayoutPanel4.Size = new System.Drawing.Size(75, 19);
|
||||
this.flowLayoutPanel4.Size = new System.Drawing.Size(73, 19);
|
||||
this.flowLayoutPanel4.TabIndex = 10005;
|
||||
this.flowLayoutPanel4.WrapContents = false;
|
||||
//
|
||||
|
@ -137,10 +137,10 @@ namespace CreamInstaller
|
|||
this.koaloaderAllCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.koaloaderAllCheckBox.Enabled = false;
|
||||
this.koaloaderAllCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||
this.koaloaderAllCheckBox.Location = new System.Drawing.Point(3, 0);
|
||||
this.koaloaderAllCheckBox.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.koaloaderAllCheckBox.Location = new System.Drawing.Point(2, 0);
|
||||
this.koaloaderAllCheckBox.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0);
|
||||
this.koaloaderAllCheckBox.Name = "koaloaderAllCheckBox";
|
||||
this.koaloaderAllCheckBox.Size = new System.Drawing.Size(72, 19);
|
||||
this.koaloaderAllCheckBox.Size = new System.Drawing.Size(71, 19);
|
||||
this.koaloaderAllCheckBox.TabIndex = 4;
|
||||
this.koaloaderAllCheckBox.Text = "Koaloader";
|
||||
this.koaloaderAllCheckBox.CheckedChanged += new System.EventHandler(this.OnKoaloaderAllCheckBoxChanged);
|
||||
|
@ -175,10 +175,10 @@ namespace CreamInstaller
|
|||
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.flowLayoutPanel1.Controls.Add(this.blockedGamesCheckBox);
|
||||
this.flowLayoutPanel1.Controls.Add(this.blockProtectedHelpButton);
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(124, -1);
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(125, -1);
|
||||
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(165, 20);
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(162, 20);
|
||||
this.flowLayoutPanel1.TabIndex = 1005;
|
||||
this.flowLayoutPanel1.WrapContents = false;
|
||||
//
|
||||
|
@ -188,8 +188,8 @@ namespace CreamInstaller
|
|||
this.blockedGamesCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.blockedGamesCheckBox.Enabled = false;
|
||||
this.blockedGamesCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||
this.blockedGamesCheckBox.Location = new System.Drawing.Point(3, 0);
|
||||
this.blockedGamesCheckBox.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.blockedGamesCheckBox.Location = new System.Drawing.Point(2, 0);
|
||||
this.blockedGamesCheckBox.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0);
|
||||
this.blockedGamesCheckBox.Name = "blockedGamesCheckBox";
|
||||
this.blockedGamesCheckBox.Size = new System.Drawing.Size(140, 20);
|
||||
this.blockedGamesCheckBox.TabIndex = 1;
|
||||
|
@ -202,8 +202,8 @@ namespace CreamInstaller
|
|||
this.blockProtectedHelpButton.Enabled = false;
|
||||
this.blockProtectedHelpButton.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||
this.blockProtectedHelpButton.Font = new System.Drawing.Font("Segoe UI", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
this.blockProtectedHelpButton.Location = new System.Drawing.Point(143, 0);
|
||||
this.blockProtectedHelpButton.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
|
||||
this.blockProtectedHelpButton.Location = new System.Drawing.Point(142, 0);
|
||||
this.blockProtectedHelpButton.Margin = new System.Windows.Forms.Padding(0, 0, 1, 0);
|
||||
this.blockProtectedHelpButton.Name = "blockProtectedHelpButton";
|
||||
this.blockProtectedHelpButton.Size = new System.Drawing.Size(19, 19);
|
||||
this.blockProtectedHelpButton.TabIndex = 2;
|
||||
|
@ -232,10 +232,10 @@ namespace CreamInstaller
|
|||
this.flowLayoutPanel2.AutoSize = true;
|
||||
this.flowLayoutPanel2.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.flowLayoutPanel2.Controls.Add(this.allCheckBox);
|
||||
this.flowLayoutPanel2.Location = new System.Drawing.Point(515, -1);
|
||||
this.flowLayoutPanel2.Location = new System.Drawing.Point(520, -1);
|
||||
this.flowLayoutPanel2.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.flowLayoutPanel2.Name = "flowLayoutPanel2";
|
||||
this.flowLayoutPanel2.Size = new System.Drawing.Size(37, 19);
|
||||
this.flowLayoutPanel2.Size = new System.Drawing.Size(34, 19);
|
||||
this.flowLayoutPanel2.TabIndex = 1006;
|
||||
this.flowLayoutPanel2.WrapContents = false;
|
||||
//
|
||||
|
@ -246,10 +246,10 @@ namespace CreamInstaller
|
|||
this.allCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.allCheckBox.Enabled = false;
|
||||
this.allCheckBox.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
||||
this.allCheckBox.Location = new System.Drawing.Point(3, 0);
|
||||
this.allCheckBox.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.allCheckBox.Location = new System.Drawing.Point(2, 0);
|
||||
this.allCheckBox.Margin = new System.Windows.Forms.Padding(2, 0, 0, 0);
|
||||
this.allCheckBox.Name = "allCheckBox";
|
||||
this.allCheckBox.Size = new System.Drawing.Size(34, 19);
|
||||
this.allCheckBox.Size = new System.Drawing.Size(32, 19);
|
||||
this.allCheckBox.TabIndex = 4;
|
||||
this.allCheckBox.Text = "All";
|
||||
this.allCheckBox.CheckedChanged += new System.EventHandler(this.OnAllCheckBoxChanged);
|
||||
|
@ -346,7 +346,7 @@ namespace CreamInstaller
|
|||
this.contextMenuStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.VerticalStackWithOverflow;
|
||||
this.contextMenuStrip.Name = "contextMenuStrip";
|
||||
this.contextMenuStrip.ShowItemToolTips = false;
|
||||
this.contextMenuStrip.Size = new System.Drawing.Size(181, 26);
|
||||
this.contextMenuStrip.Size = new System.Drawing.Size(61, 4);
|
||||
this.contextMenuStrip.TabStop = true;
|
||||
//
|
||||
// SelectForm
|
||||
|
|
Loading…
Reference in a new issue