Skip to content

Commit e8eedc0

Browse files
authored
Merge pull request #16 from ghudulf/main
add extra logging and bump version
2 parents ed99851 + 6f8ac81 commit e8eedc0

19 files changed

Lines changed: 314 additions & 98 deletions

File tree

build/Package.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<LangVersion>default</LangVersion>
7-
<PackageVersion>5.2.1</PackageVersion>
7+
<PackageVersion>5.2.1-fix</PackageVersion>
88
<Authors>Dmitry Zhutkov (Onebeld), Andrey Savich (pieckenst)</Authors>
99
<Copyright>Dmitry Zhutkov (Onebeld)</Copyright>
1010
<PackageTags>theme, design, xaml, library, ui, gui, control, csharp, styled-components, interface, dotnet, nuget, style, avalonia, controls, user-interface, styles, avaloniaui, pleasant, graphical-user-interface</PackageTags>

samples/PleasantUI.Example/Properties/Localizations/App.resx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,7 @@ The above copyright notice and this permission notice shall be included in all c
621621
<data name="PropertyGrid/LabelType" xml:space="preserve"><value>Type</value></data>
622622
<data name="PropertyGrid/LabelSource" xml:space="preserve"><value>Source</value></data>
623623
<data name="PropertyGrid/LabelStatus" xml:space="preserve"><value>Status</value></data>
624+
<data name="PropertyGrid/RunningText" xml:space="preserve"><value>Running</value></data>
624625

625626
<!-- LogViewerPanel -->
626627
<data name="LogViewerPanel/AllFilterText" xml:space="preserve"><value>All</value></data>
@@ -630,6 +631,10 @@ The above copyright notice and this permission notice shall be included in all c
630631
<data name="LogViewerPanel/CloseTooltip" xml:space="preserve"><value>Close</value></data>
631632
<data name="LogViewerPanel/DebugTooltip" xml:space="preserve"><value>Show debug entries</value></data>
632633

634+
<!-- TerminalPanel -->
635+
636+
<data name="TerminalPanel/RunningText" xml:space="preserve"><value>Running</value></data>
637+
633638
<!-- DownloadPanel -->
634639
<data name="DownloadPanel/SizeLabel" xml:space="preserve"><value>SIZE</value></data>
635640
<data name="DownloadPanel/SpeedLabel" xml:space="preserve"><value>SPEED</value></data>
@@ -646,11 +651,13 @@ The above copyright notice and this permission notice shall be included in all c
646651
<data name="DownloadPanel/ChunkFailedText" xml:space="preserve"><value>Failed</value></data>
647652
<data name="DownloadPanel/ChunkPausedText" xml:space="preserve"><value>Paused</value></data>
648653
<data name="DownloadPanel/ChunkUnknownText" xml:space="preserve"><value>Unknown</value></data>
654+
<data name="DownloadPanel/StatusText" xml:space="preserve"><value>Running</value></data>
649655

650656
<!-- TerminalPanel -->
651657
<data name="TerminalPanel/ClearTooltip" xml:space="preserve"><value>Clear output</value></data>
652658
<data name="TerminalPanel/CloseTooltip" xml:space="preserve"><value>Close</value></data>
653659
<data name="TerminalPanel/InputPlaceholder" xml:space="preserve"><value>Type a command and press Enter</value></data>
660+
<data name="TerminalPanel/StatusText" xml:space="preserve"><value>Running</value></data>
654661

655662
<!-- LogViewerPanel -->
656663
<data name="LogViewerPanel/SearchPlaceholder" xml:space="preserve"><value>Search logs...</value></data>

samples/PleasantUI.Example/Properties/Localizations/App.ru.resx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@
640640
<data name="TerminalPanel/ClearTooltip" xml:space="preserve"><value>Очистить вывод</value></data>
641641
<data name="TerminalPanel/CloseTooltip" xml:space="preserve"><value>Закрыть</value></data>
642642
<data name="TerminalPanel/InputPlaceholder" xml:space="preserve"><value>Введите команду и нажмите Enter</value></data>
643+
<data name="TerminalPanel/StatusText" xml:space="preserve"><value>Работает</value></data>
644+
<data name="TerminalPanel/RunningText" xml:space="preserve"><value>Работает</value></data>
643645

644646
<!-- LogViewerPanel -->
645647
<data name="LogViewerPanel/SearchPlaceholder" xml:space="preserve"><value>Поиск в журнале...</value></data>

samples/PleasantUI.Example/Views/Pages/PleasantControlPages/TerminalPanelPageView.axaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
<controls:TerminalPanel x:Name="Terminal"
1515
Title="{Localize CardTitle/TerminalPanel}"
1616
IsRunning="True"
17-
StatusText="Running"
17+
StatusText="{Localize TerminalPanel/StatusText}"
18+
RunningText="{Localize TerminalPanel/RunningText}"
1819
Prompt="$"
1920
Height="320"
2021
ShowCloseButton="False"

src/PleasantUI.ToolKit/Controls/TerminalPanel/TerminalPanel.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ public class TerminalPanel : TemplatedControl
4949
public static readonly StyledProperty<string?> StatusTextProperty =
5050
AvaloniaProperty.Register<TerminalPanel, string?>(nameof(StatusText));
5151

52+
/// <summary>Defines the <see cref="RunningText"/> property.</summary>
53+
public static readonly StyledProperty<string> RunningTextProperty =
54+
AvaloniaProperty.Register<TerminalPanel, string>(nameof(RunningText), defaultValue: "Running");
55+
5256
/// <summary>Defines the <see cref="StatusColor"/> property.</summary>
5357
public static readonly StyledProperty<IBrush?> StatusColorProperty =
5458
AvaloniaProperty.Register<TerminalPanel, IBrush?>(nameof(StatusColor));
@@ -108,6 +112,13 @@ public string? StatusText
108112
set => SetValue(StatusTextProperty, value);
109113
}
110114

115+
/// <summary>Gets or sets the text shown when the terminal is running.</summary>
116+
public string RunningText
117+
{
118+
get => GetValue(RunningTextProperty);
119+
set => SetValue(RunningTextProperty, value);
120+
}
121+
111122
/// <summary>Gets or sets the brush used for the status indicator dot.</summary>
112123
public IBrush? StatusColor
113124
{
@@ -218,7 +229,17 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
218229
base.OnPropertyChanged(change);
219230

220231
if (change.Property == IsRunningProperty)
221-
PseudoClasses.Set(PC_Running, change.GetNewValue<bool>());
232+
{
233+
bool isRunning = change.GetNewValue<bool>();
234+
PseudoClasses.Set(PC_Running, isRunning);
235+
236+
// Automatically set StatusText to RunningText when IsRunning changes
237+
// This can be overridden manually for error messages or general status
238+
if (isRunning)
239+
StatusText = RunningText;
240+
else
241+
StatusText = null;
242+
}
222243
else if (change.Property == OutputTextProperty)
223244
{
224245
if (_outputBox is not null)

src/PleasantUI.ToolKit/PleasantUIToolKit.axaml.cs

Lines changed: 140 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Avalonia.Markup.Xaml;
44
using Avalonia.Markup.Xaml.Styling;
55
using Avalonia.Styling;
6+
using PleasantUI.Core;
67

78
namespace PleasantUI.ToolKit;
89

@@ -13,6 +14,7 @@ public class PleasantUIToolKit : ResourceDictionary
1314
{
1415
private static PleasantUIToolKit? _instance;
1516
private StyleInclude? _vguiStyleInclude;
17+
private bool _listenerAdded = false;
1618

1719
/// <summary>
1820
/// Gets the singleton instance of PleasantUIToolKit
@@ -26,6 +28,109 @@ public PleasantUIToolKit()
2628
{
2729
_instance = this;
2830
AvaloniaXamlLoader.Load(this);
31+
32+
TryAddListener();
33+
}
34+
35+
private void TryAddListener()
36+
{
37+
if (_listenerAdded) return;
38+
39+
if (PleasantSettings.Current is not null)
40+
{
41+
PleasantSettings.Current.PropertyChanged += OnPleasantSettingsChanged;
42+
_listenerAdded = true;
43+
// Check if VGUI is already active
44+
UpdateVGUIStyle(PleasantSettings.Current.Theme == "VGUI");
45+
System.Diagnostics.Debug.WriteLine("[PleasantUIToolKit] Listener added, checking VGUI status");
46+
}
47+
else
48+
{
49+
System.Diagnostics.Debug.WriteLine("[PleasantUIToolKit] PleasantSettings.Current is null, will retry later");
50+
// Retry after a delay
51+
System.Threading.Tasks.Task.Delay(100).ContinueWith(_ =>
52+
{
53+
Avalonia.Threading.Dispatcher.UIThread.Post(TryAddListener);
54+
});
55+
}
56+
}
57+
58+
private void OnPleasantSettingsChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
59+
{
60+
if (e.PropertyName == nameof(PleasantSettings.Current.Theme))
61+
{
62+
UpdateVGUIStyle(PleasantSettings.Current?.Theme == "VGUI");
63+
}
64+
}
65+
66+
/// <summary>
67+
/// Manually triggers VGUI style update (called from PleasantTheme via reflection)
68+
/// </summary>
69+
public static void UpdateVGUIStyleManually(bool isVGUI)
70+
{
71+
System.Diagnostics.Debug.WriteLine($"[PleasantUIToolKit] UpdateVGUIStyleManually called with isVGUI={isVGUI}");
72+
73+
if (Avalonia.Application.Current?.Resources is null)
74+
{
75+
System.Diagnostics.Debug.WriteLine("[PleasantUIToolKit] Application.Current.Resources is null");
76+
return;
77+
}
78+
79+
System.Diagnostics.Debug.WriteLine($"[PleasantUIToolKit] Application.Current.Resources.MergedDictionaries count: {Avalonia.Application.Current.Resources.MergedDictionaries.Count}");
80+
81+
// Log all resources to debug
82+
int index = 0;
83+
foreach (var resource in Avalonia.Application.Current.Resources.MergedDictionaries)
84+
{
85+
string resourceInfo = resource?.GetType().FullName ?? "null";
86+
if (resource is Avalonia.Markup.Xaml.Styling.ResourceInclude ri)
87+
{
88+
resourceInfo += $" (Source: {ri.Source})";
89+
}
90+
System.Diagnostics.Debug.WriteLine($"[PleasantUIToolKit] Resource [{index}]: {resourceInfo}");
91+
index++;
92+
}
93+
94+
// Find PleasantUIToolKit in MergedDictionaries
95+
PleasantUIToolKit? toolKit = null;
96+
foreach (var resource in Avalonia.Application.Current.Resources.MergedDictionaries)
97+
{
98+
if (resource is PleasantUIToolKit tk)
99+
{
100+
toolKit = tk;
101+
break;
102+
}
103+
}
104+
105+
if (toolKit is not null)
106+
{
107+
toolKit.UpdateVGUIStyle(isVGUI);
108+
}
109+
else
110+
{
111+
System.Diagnostics.Debug.WriteLine("[PleasantUIToolKit] PleasantUIToolKit not found in Application.Resources.MergedDictionaries");
112+
// Try to find it recursively in nested MergedDictionaries
113+
FindRecursive(Avalonia.Application.Current.Resources, 0);
114+
}
115+
}
116+
117+
private static void FindRecursive(IResourceDictionary dict, int depth)
118+
{
119+
string indent = new string(' ', depth * 2);
120+
System.Diagnostics.Debug.WriteLine($"{indent}Checking dictionary: {dict?.GetType().FullName}");
121+
122+
if (dict is PleasantUIToolKit)
123+
{
124+
System.Diagnostics.Debug.WriteLine($"{indent}FOUND PleasantUIToolKit!");
125+
}
126+
127+
foreach (var resource in dict.MergedDictionaries)
128+
{
129+
if (resource is IResourceDictionary rd)
130+
{
131+
FindRecursive(rd, depth + 1);
132+
}
133+
}
29134
}
30135

31136
/// <summary>
@@ -34,23 +139,52 @@ public PleasantUIToolKit()
34139
/// <param name="isVGUI">Whether VGUI mode is active</param>
35140
public void UpdateVGUIStyle(bool isVGUI)
36141
{
142+
System.Diagnostics.Debug.WriteLine($"[PleasantUIToolKit] UpdateVGUIStyle called with isVGUI={isVGUI}");
143+
System.Diagnostics.Debug.WriteLine($"[PleasantUIToolKit] MergedDictionaries count before: {MergedDictionaries.Count}");
144+
37145
if (isVGUI)
38146
{
39147
if (_vguiStyleInclude is null)
40148
{
41-
_vguiStyleInclude = new StyleInclude(new Uri("avares://PleasantUI.ToolKit/"))
149+
System.Diagnostics.Debug.WriteLine("[PleasantUIToolKit] Adding VGUIControlThemes.axaml");
150+
try
151+
{
152+
_vguiStyleInclude = new StyleInclude(new Uri("avares://PleasantUI.ToolKit/"))
153+
{
154+
Source = new Uri("avares://PleasantUI.ToolKit/Styling/VGUIControlThemes.axaml")
155+
};
156+
MergedDictionaries.Add(_vguiStyleInclude);
157+
System.Diagnostics.Debug.WriteLine($"[PleasantUIToolKit] VGUIControlThemes.axaml added successfully, MergedDictionaries count after: {MergedDictionaries.Count}");
158+
}
159+
catch (Exception ex)
42160
{
43-
Source = new Uri("avares://PleasantUI.ToolKit/Styling/VGUIControlThemes.axaml")
44-
};
45-
MergedDictionaries.Add(_vguiStyleInclude);
161+
System.Diagnostics.Debug.WriteLine($"[PleasantUIToolKit] Error adding VGUIControlThemes.axaml: {ex.Message}");
162+
}
163+
}
164+
else
165+
{
166+
System.Diagnostics.Debug.WriteLine("[PleasantUIToolKit] VGUIControlThemes.axaml already loaded");
46167
}
47168
}
48169
else
49170
{
50171
if (_vguiStyleInclude is not null)
51172
{
52-
MergedDictionaries.Remove(_vguiStyleInclude);
53-
_vguiStyleInclude = null;
173+
System.Diagnostics.Debug.WriteLine("[PleasantUIToolKit] Removing VGUIControlThemes.axaml");
174+
try
175+
{
176+
MergedDictionaries.Remove(_vguiStyleInclude);
177+
_vguiStyleInclude = null;
178+
System.Diagnostics.Debug.WriteLine("[PleasantUIToolKit] VGUIControlThemes.axaml removed successfully");
179+
}
180+
catch (Exception ex)
181+
{
182+
System.Diagnostics.Debug.WriteLine($"[PleasantUIToolKit] Error removing VGUIControlThemes.axaml: {ex.Message}");
183+
}
184+
}
185+
else
186+
{
187+
System.Diagnostics.Debug.WriteLine("[PleasantUIToolKit] VGUIControlThemes.axaml not loaded");
54188
}
55189
}
56190
}

src/PleasantUI.ToolKit/Styling/ControlThemes/PleasantToolKitControls/CrashReportDialog.axaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<Setter Property="Opacity" Value="0" />
5858
<Setter Property="MinWidth" Value="560" />
5959
<Setter Property="MaxWidth" Value="680" />
60+
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
6061

6162
<Setter Property="OpenAnimation">
6263
<Animation Duration="0:0:0.22" FillMode="Both" Easing="CubicEaseOut">
@@ -90,14 +91,14 @@
9091

9192
<Setter Property="Template">
9293
<ControlTemplate>
93-
<ShadowBorder CornerRadius="{DynamicResource ControlCornerRadius}"
94+
<ShadowBorder CornerRadius="{TemplateBinding CornerRadius}"
9495
BlurRadius="50"
9596
ShadowColor="#6E000000"
9697
Offset="0 8">
9798
<Border Background="{DynamicResource BackgroundColor1}"
9899
BorderBrush="{DynamicResource ControlBorderColor}"
99100
BorderThickness="{DynamicResource ControlBorderThickness}"
100-
CornerRadius="{DynamicResource ControlCornerRadius}"
101+
CornerRadius="{TemplateBinding CornerRadius}"
101102
ClipToBounds="True">
102103
<Grid RowDefinitions="Auto,Auto,*,Auto">
103104

src/PleasantUI.ToolKit/Styling/ControlThemes/PleasantToolKitControls/StepDialog.axaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
<Setter Property="HorizontalAlignment" Value="Center" />
8989
<Setter Property="VerticalAlignment" Value="Center" />
9090
<Setter Property="Opacity" Value="0" />
91+
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" />
9192

9293
<Setter Property="OpenAnimation">
9394
<Animation Duration="0:0:0.2" FillMode="Both" Easing="CubicEaseOut">
@@ -121,14 +122,14 @@
121122

122123
<Setter Property="Template">
123124
<ControlTemplate>
124-
<ShadowBorder CornerRadius="{DynamicResource ControlCornerRadius}"
125+
<ShadowBorder CornerRadius="{TemplateBinding CornerRadius}"
125126
BlurRadius="40"
126127
ShadowColor="#5A000000"
127128
Offset="0 8">
128129
<Border Background="{DynamicResource BackgroundColor1}"
129130
BorderBrush="{DynamicResource ControlBorderColor}"
130131
BorderThickness="{DynamicResource ControlBorderThickness}"
131-
CornerRadius="{DynamicResource ControlCornerRadius}"
132+
CornerRadius="{TemplateBinding CornerRadius}"
132133
MinWidth="{TemplateBinding MinDialogWidth}"
133134
ClipToBounds="True">
134135
<Grid RowDefinitions="Auto,*,Auto">

src/PleasantUI.ToolKit/Styling/ControlThemes/PleasantToolKitControls/TerminalPanel.axaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
BorderBrush="{DynamicResource ControlBorderColor}"
108108
BorderThickness="0 1 0 0"
109109
Background="{DynamicResource BackgroundColor2}"
110-
Padding="10 8">
110+
Padding="14 8">
111111
<Grid ColumnDefinitions="Auto,*" ColumnSpacing="8">
112112
<TextBlock Grid.Column="0"
113113
Text="{TemplateBinding Prompt}"
@@ -123,7 +123,7 @@
123123
FontSize="12"
124124
Background="Transparent"
125125
BorderThickness="0"
126-
Padding="0 4" />
126+
Padding="8 4" />
127127
</Grid>
128128
</Border>
129129
</Grid>

0 commit comments

Comments
 (0)