using Avalonia.Controls; using Avalonia.Diagnostics; using Avalonia.Input; namespace Avalonia { /// /// Extension methods for attaching DevTools.. /// public static class DevToolsExtensions { /// /// Attaches DevTools to a window, to be opened with the F12 key. /// /// The window to attach DevTools to. public static void AttachDevTools(this TopLevel root) { DevTools.Attach(root, new DevToolsOptions()); } /// /// Attaches DevTools to a window, to be opened with the specified key gesture. /// /// The window to attach DevTools to. /// The key gesture to open DevTools. public static void AttachDevTools(this TopLevel root, KeyGesture gesture) { DevTools.Attach(root, gesture); } /// /// Attaches DevTools to a window, to be opened with the specified options. /// /// The window to attach DevTools to. /// Additional settings of DevTools. public static void AttachDevTools(this TopLevel root, DevToolsOptions options) { DevTools.Attach(root, options); } /// /// Attaches DevTools to a Application, to be opened with the specified options. /// /// The Application to attach DevTools to. public static void AttachDevTools(this Application application) { DevTools.Attach(application, new DevToolsOptions()); } /// /// Attaches DevTools to a Application, to be opened with the specified options. /// /// The Application to attach DevTools to. /// Additional settings of DevTools. /// /// Attach DevTools should only be called after application initialization is complete. A good point is /// /// /// /// public class App : Application /// { /// public override void OnFrameworkInitializationCompleted() /// { /// if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime) /// { /// desktopLifetime.MainWindow = new MainWindow(); /// } /// else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewLifetime) /// singleViewLifetime.MainView = new MainView(); /// /// base.OnFrameworkInitializationCompleted(); /// this.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions() /// { /// StartupScreenIndex = 1, /// }); /// } /// } /// /// public static void AttachDevTools(this Application application, DevToolsOptions options) { DevTools.Attach(application, options); } } }