Skip to content

Commit 787fa19

Browse files
committed
vgui corner radius
1 parent 058802f commit 787fa19

2 files changed

Lines changed: 104 additions & 0 deletions

File tree

src/PleasantUI.ToolKit/Controls/CrashReportDialog/CrashReportDialog.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,45 @@ public string UserMessagePlaceholder
535535
// Tab items — built once and reused.
536536
private readonly List<string> _tabs = new();
537537

538+
static CrashReportDialog()
539+
{
540+
CornerRadiusProperty.Changed.AddClassHandler<CrashReportDialog>((x, e) => x.OnCornerRadiusChanged(e));
541+
}
542+
543+
private void OnCornerRadiusChanged(AvaloniaPropertyChangedEventArgs e)
544+
{
545+
try
546+
{
547+
if (IsVGUIActive())
548+
{
549+
System.Diagnostics.Debug.WriteLine("[CrashReportDialog] VGUI theme active, setting CornerRadius to 0");
550+
SetValue(CornerRadiusProperty, new CornerRadius(0));
551+
}
552+
}
553+
catch (Exception ex)
554+
{
555+
System.Diagnostics.Debug.WriteLine($"[CrashReportDialog] Error in OnCornerRadiusChanged: {ex.Message}");
556+
}
557+
}
558+
559+
/// <summary>
560+
/// Checks if the VGUI theme is currently active.
561+
/// </summary>
562+
protected static bool IsVGUIActive()
563+
{
564+
try
565+
{
566+
var isActive = PleasantUI.Core.PleasantSettings.Current?.Theme == "VGUI";
567+
System.Diagnostics.Debug.WriteLine($"[CrashReportDialog] IsVGUIActive: {isActive}");
568+
return isActive;
569+
}
570+
catch (Exception ex)
571+
{
572+
System.Diagnostics.Debug.WriteLine($"[CrashReportDialog] Error checking VGUI status: {ex.Message}");
573+
return false;
574+
}
575+
}
576+
538577
// ── Convenience factory ───────────────────────────────────────────────────
539578

540579
/// <summary>
@@ -571,6 +610,19 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
571610
{
572611
base.OnApplyTemplate(e);
573612

613+
try
614+
{
615+
if (IsVGUIActive())
616+
{
617+
System.Diagnostics.Debug.WriteLine("[CrashReportDialog] OnApplyTemplate: VGUI theme active, setting CornerRadius to 0");
618+
CornerRadius = new CornerRadius(0);
619+
}
620+
}
621+
catch (Exception ex)
622+
{
623+
System.Diagnostics.Debug.WriteLine($"[CrashReportDialog] Error in OnApplyTemplate: {ex.Message}");
624+
}
625+
574626
DetachHandlers();
575627

576628
_sendButton = e.NameScope.Find<Button>(PART_SendButton);

src/PleasantUI.ToolKit/Controls/StepDialog/StepDialog.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,17 +164,69 @@ public Animation? CloseAnimation
164164

165165
// ── Constructor ───────────────────────────────────────────────────────────
166166

167+
static StepDialog()
168+
{
169+
CornerRadiusProperty.Changed.AddClassHandler<StepDialog>((x, e) => x.OnCornerRadiusChanged(e));
170+
}
171+
167172
public StepDialog()
168173
{
169174
Steps.CollectionChanged += OnStepsChanged;
170175
}
171176

177+
private void OnCornerRadiusChanged(AvaloniaPropertyChangedEventArgs e)
178+
{
179+
try
180+
{
181+
if (IsVGUIActive())
182+
{
183+
System.Diagnostics.Debug.WriteLine("[StepDialog] VGUI theme active, setting CornerRadius to 0");
184+
SetValue(CornerRadiusProperty, new CornerRadius(0));
185+
}
186+
}
187+
catch (Exception ex)
188+
{
189+
System.Diagnostics.Debug.WriteLine($"[StepDialog] Error in OnCornerRadiusChanged: {ex.Message}");
190+
}
191+
}
192+
193+
/// <summary>
194+
/// Checks if the VGUI theme is currently active.
195+
/// </summary>
196+
protected static bool IsVGUIActive()
197+
{
198+
try
199+
{
200+
var isActive = PleasantUI.Core.PleasantSettings.Current?.Theme == "VGUI";
201+
System.Diagnostics.Debug.WriteLine($"[StepDialog] IsVGUIActive: {isActive}");
202+
return isActive;
203+
}
204+
catch (Exception ex)
205+
{
206+
System.Diagnostics.Debug.WriteLine($"[StepDialog] Error checking VGUI status: {ex.Message}");
207+
return false;
208+
}
209+
}
210+
172211
// ── Template ──────────────────────────────────────────────────────────────
173212

174213
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
175214
{
176215
base.OnApplyTemplate(e);
177216

217+
try
218+
{
219+
if (IsVGUIActive())
220+
{
221+
System.Diagnostics.Debug.WriteLine("[StepDialog] OnApplyTemplate: VGUI theme active, setting CornerRadius to 0");
222+
CornerRadius = new CornerRadius(0);
223+
}
224+
}
225+
catch (Exception ex)
226+
{
227+
System.Diagnostics.Debug.WriteLine($"[StepDialog] Error in OnApplyTemplate: {ex.Message}");
228+
}
229+
178230
DetachHandlers();
179231

180232
_closeButton = e.NameScope.Find<Button>(PART_CloseButton);

0 commit comments

Comments
 (0)