Skip to content

Commit 44aef1a

Browse files
authored
Make new Accelerate Dev Tools available (#151)
1 parent 261b321 commit 44aef1a

File tree

4 files changed

+49
-4
lines changed

4 files changed

+49
-4
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,21 @@ Custom Avalonia Themes developed by [Devolutions](https://devolutions.net/)
88

99
➡️ [DevExpress Theme](https://github.com/Devolutions/avalonia-themes/blob/master/src/Devolutions.AvaloniaTheme.DevExpress/README.md)
1010

11+
➡️ [Linux Theme](https://github.com/Devolutions/avalonia-themes/blob/master/src/Devolutions.AvaloniaTheme.Linux/README.md)
12+
13+
# Sample App
14+
15+
Contributers can use the SampleApp to test, debug and document styles for the various controls under each theme.
16+
17+
## Debugging
18+
19+
The SampleApp attaches the Avalonia Dev Tools for inspecting controls (open with F12).
20+
21+
If you own a licence for the new Dev Tools in _Avalonia Accelerate_, you can set an environment variable in your IDE's debug configuration.
22+
For example, in Rider:
23+
24+
- Open **Run > Edit Configurations**
25+
- Pick your configuration for the SampleApp
26+
- In the **Environment Variables** field add `USE_AVALONIA_ACCELERATE_TOOLS=true`
27+
28+
The F12 key then opens the new Dev Tools, and F10 opens the old version

samples/SampleApp/App.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class App : Application
1919
public override void Initialize()
2020
{
2121
AvaloniaXamlLoader.Load(this);
22-
22+
2323
if (!Avalonia.Controls.Design.IsDesignMode)
2424
{
2525
Styles.Clear();

samples/SampleApp/MainWindow.axaml.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
using System;
12
using Avalonia;
23
using Avalonia.Controls;
34
using Avalonia.Controls.Primitives;
5+
using Avalonia.Input;
46
using Avalonia.Styling;
57

68
namespace SampleApp;
@@ -11,7 +13,20 @@ public MainWindow()
1113
{
1214
InitializeComponent();
1315
#if DEBUG
14-
this.AttachDevTools();
16+
bool useAccelerate = Environment.GetEnvironmentVariable("USE_AVALONIA_ACCELERATE_TOOLS")?.ToLowerInvariant() == "true";
17+
18+
if (useAccelerate)
19+
{
20+
// Enable Accelerate dev tools (AvaloniaUI.DiagnosticsSupport) - requiring a licence to use
21+
(Application.Current as App)?.AttachDeveloperTools();
22+
// Enable original free dev tools (Avalonia.Diagnostics) as an additional option available on F10
23+
this.AttachDevTools(new KeyGesture(Key.F10));
24+
}
25+
else
26+
{
27+
// Enable original free dev tools (Avalonia.Diagnostics)
28+
this.AttachDevTools();
29+
}
1530
#endif
1631
}
1732

samples/SampleApp/SampleApp.csproj

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,27 @@
88
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
99
</PropertyGroup>
1010

11+
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
12+
<!-- Prevent automatic attachment of regular free dev tools to avoid duplicate mapping of F12 key -->
13+
<AvaloniaNameGeneratorAttachDevTools>false</AvaloniaNameGeneratorAttachDevTools>
14+
</PropertyGroup>
15+
1116
<ItemGroup>
1217
<PackageReference Include="Avalonia" Version="11.3.0" />
1318
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.0" />
1419
<PackageReference Include="Avalonia.Desktop" Version="11.3.0" />
1520
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.0" />
16-
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
17-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.0" />
1821
</ItemGroup>
1922

23+
<ItemGroup>
24+
<!--Add both, Classic and Accelerate Dev Tools -->
25+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.0" />
26+
<PackageReference Include="AvaloniaUI.DiagnosticsSupport" Version="2.0.3" >
27+
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
28+
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
29+
</PackageReference>
30+
</ItemGroup>
31+
2032
<ItemGroup>
2133
<PackageReference Include="Avalonia.Svg.Skia" Version="11.3.0" />
2234
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0"/>

0 commit comments

Comments
 (0)