Skip to content

Jules was unable to complete the task in time. Please review the work… #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions ReClass.NET/Forms/AboutForm.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using System;
using System.Diagnostics;
using System.Drawing; // Added for Color
using System.Windows.Forms;
using ReClassNET.UI;

namespace ReClassNET.Forms
{
public partial class AboutForm : IconForm
{
private bool isApplyingTheme = false; // To prevent re-entrancy

public AboutForm()
{
InitializeComponent();
Expand All @@ -19,13 +22,97 @@ public AboutForm()
buildTimeValueLabel.Text = Properties.Resources.BuildDate;
authorValueLabel.Text = Constants.Author;
homepageValueLabel.Text = Constants.HomepageUrl;

this.Activated += AboutForm_Activated;
}

private void AboutForm_Activated(object sender, EventArgs e)
{
ApplyTheme();
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

GlobalWindowManager.AddWindow(this);

ApplyTheme();
}

private void ApplyTheme()
{
if (isApplyingTheme) return;
isApplyingTheme = true;

try
{
var foreColor = Program.Settings.TextColor;
var backColor = Program.Settings.BackgroundColor;
var backColorSelected = Program.Settings.SelectedColor; // For input-like backgrounds
var linkColor = Program.Settings.OffsetColor; // Using OffsetColor for links as an example

this.ForeColor = foreColor;
this.BackColor = backColor;

// Apply to child controls recursively
UpdateControlTheme(this, foreColor, backColor, backColorSelected);

// Specific controls
licenseTextBox.BackColor = backColorSelected;
licenseTextBox.ForeColor = foreColor;

homepageValueLabel.LinkColor = linkColor;
// Make ActiveLinkColor slightly different, e.g., a bit lighter or darker than LinkColor
homepageValueLabel.ActiveLinkColor = ControlPaint.Light(linkColor);
homepageValueLabel.VisitedLinkColor = ControlPaint.Dark(linkColor);


// BannerBox theming will be handled more deeply in BannerBox.cs later.
// For now, set basic colors.
bannerBox.BackColor = backColor; // Or a specific banner background from settings if available
bannerBox.ForeColor = foreColor; // For title and text, if not custom painted
bannerBox.Invalidate(); // Ensure it redraws
}
finally
{
isApplyingTheme = false;
}
}

private void UpdateControlTheme(Control parentControl, Color foreColor, Color backColor, Color backColorSelected)
{
foreach (Control control in parentControl.Controls)
{
// Skip BannerBox as it will have its own detailed theming.
if (control is BannerBox) continue;

control.ForeColor = foreColor;
control.BackColor = backColor;

if (control is TextBoxBase || control is ListBox || control is ComboBox)
{
control.BackColor = backColorSelected;
}
else if (control is GroupBox groupBox)
{
// GroupBox ForeColor sets the title color.
// Children are handled by recursion.
}
else if (control is LinkLabel linkLabel)
{
// Already handled homepageValueLabel specifically, but a general case:
linkLabel.LinkColor = Program.Settings.OffsetColor;
linkLabel.ActiveLinkColor = ControlPaint.Light(Program.Settings.OffsetColor);
linkLabel.VisitedLinkColor = ControlPaint.Dark(Program.Settings.OffsetColor);
}


if (control.HasChildren)
{
UpdateControlTheme(control, foreColor, backColor, backColorSelected);
}
}
}

protected override void OnFormClosed(FormClosedEventArgs e)
Expand Down
77 changes: 77 additions & 0 deletions ReClass.NET/Forms/ClassSelectionForm.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Drawing; // Added for Color
using System.Linq;
using System.Windows.Forms;
using ReClassNET.Nodes;
Expand All @@ -11,6 +12,7 @@ namespace ReClassNET.Forms
public partial class ClassSelectionForm : IconForm
{
private readonly List<ClassNode> allClasses;
private bool isApplyingTheme = false; // To prevent re-entrancy

public ClassNode SelectedClass => classesListBox.SelectedItem as ClassNode;

Expand All @@ -23,15 +25,90 @@ public ClassSelectionForm(IEnumerable<ClassNode> classes)
InitializeComponent();

ShowFilteredClasses();

this.Activated += ClassSelectionForm_Activated;
}

private void ClassSelectionForm_Activated(object sender, EventArgs e)
{
ApplyTheme();
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

GlobalWindowManager.AddWindow(this);

ApplyTheme();
}

private void ApplyTheme()
{
if (isApplyingTheme) return;
isApplyingTheme = true;

try
{
var foreColor = Program.Settings.TextColor;
var backColor = Program.Settings.BackgroundColor;
var backColorSelected = Program.Settings.SelectedColor;

this.ForeColor = foreColor;
this.BackColor = backColor;

UpdateControlTheme(this, foreColor, backColor, backColorSelected);

// Specific controls
classesListBox.BackColor = backColorSelected;
classesListBox.ForeColor = foreColor;

filterNameTextBox.BackColor = backColorSelected;
filterNameTextBox.ForeColor = foreColor;

// BannerBox theming will be handled more deeply in BannerBox.cs later.
bannerBox.BackColor = backColor;
bannerBox.ForeColor = foreColor;
bannerBox.Invalidate();
}
finally
{
isApplyingTheme = false;
}
}

private void UpdateControlTheme(Control parentControl, Color foreColor, Color backColor, Color backColorSelected)
{
foreach (Control control in parentControl.Controls)
{
if (control is BannerBox) continue; // Skip BannerBox

control.ForeColor = foreColor;
control.BackColor = backColor;

if (control is TextBoxBase || control is ListBox || control is ComboBox)
{
control.BackColor = backColorSelected;
}
else if (control is ButtonBase)
{
// Standard buttons often don't style well with BackColor. ForeColor is usually fine.
// If using FlatStyle.Flat or FlatStyle.Popup, BackColor can be set.
// For now, we'll assume default button styling is mostly acceptable or will be tweaked if issues arise.
}
else if (control is GroupBox)
{
// GroupBox ForeColor sets the title color.
}

if (control.HasChildren)
{
UpdateControlTheme(control, foreColor, backColor, backColorSelected);
}
}
}


protected override void OnFormClosed(FormClosedEventArgs e)
{
base.OnFormClosed(e);
Expand Down
68 changes: 68 additions & 0 deletions ReClass.NET/Forms/CodeForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing; // Added for Color
using ColorCode;
using ColorCode.Parsing;
using ReClassNET.CodeGenerator;
Expand All @@ -19,6 +20,8 @@ namespace ReClassNET.Forms
{
public partial class CodeForm : IconForm
{
private bool isApplyingTheme = false; // To prevent re-entrancy

public CodeForm(ICodeGenerator generator, IReadOnlyList<ClassNode> classes, IReadOnlyList<EnumDescription> enums, ILogger logger)
{
Contract.Requires(generator != null);
Expand All @@ -44,13 +47,78 @@ public CodeForm(ICodeGenerator generator, IReadOnlyList<ClassNode> classes, IRea
}

codeRichTextBox.Rtf = buffer.ToString();

this.Activated += CodeForm_Activated;
}

private void CodeForm_Activated(object sender, EventArgs e)
{
ApplyTheme();
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);

GlobalWindowManager.AddWindow(this);

ApplyTheme();
}

private void ApplyTheme()
{
if (isApplyingTheme) return;
isApplyingTheme = true;

try
{
var foreColor = Program.Settings.TextColor;
var backColor = Program.Settings.BackgroundColor;
// For RichTextBox, the selected color might be too dark if it's used as a general input field background.
// Sticking to the main BackgroundColor for now, as RTF handles its own foreground colors.
var rtbBackColor = Program.Settings.BackgroundColor;

this.ForeColor = foreColor;
this.BackColor = backColor;

UpdateControlTheme(this, foreColor, backColor, rtbBackColor); // Pass rtbBackColor for specific use

// Specific controls
codeRichTextBox.BackColor = rtbBackColor;
codeRichTextBox.ForeColor = foreColor; // Default text color if no RTF styling applies

// BannerBox theming
bannerBox.BackColor = backColor;
bannerBox.ForeColor = foreColor;
bannerBox.Invalidate();
}
finally
{
isApplyingTheme = false;
}
}

private void UpdateControlTheme(Control parentControl, Color foreColor, Color backColor, Color specificBackColor)
{
foreach (Control control in parentControl.Controls)
{
if (control is BannerBox) continue;

control.ForeColor = foreColor;
control.BackColor = backColor;

if (control is RichTextBox) // Apply specificBackColor to RichTextBox
{
control.BackColor = specificBackColor;
}
// No other specific input controls like TextBox, ListBox on this form from designer.
// Buttons will take general ForeColor/BackColor.

if (control.HasChildren)
{
UpdateControlTheme(control, foreColor, backColor, specificBackColor);
}
}
}

protected override void OnFormClosed(FormClosedEventArgs e)
Expand Down
Loading