Browse Source
Merge branch 'master' into fixes/osx-window-state
pull/6083/head
Dan Walmsley
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
41 additions and
4 deletions
-
samples/ControlCatalog/MainWindow.xaml.cs
-
src/Avalonia.Controls/Remote/RemoteWidget.cs
-
src/Avalonia.Diagnostics/Diagnostics/DevTools.cs
-
src/Avalonia.Diagnostics/Diagnostics/DevToolsOptions.cs
-
src/Avalonia.Diagnostics/Diagnostics/ViewModels/MainViewModel.cs
-
src/Avalonia.Diagnostics/Diagnostics/Views/MainWindow.xaml.cs
|
|
|
@ -17,7 +17,10 @@ namespace ControlCatalog |
|
|
|
public MainWindow() |
|
|
|
{ |
|
|
|
this.InitializeComponent(); |
|
|
|
this.AttachDevTools(); |
|
|
|
this.AttachDevTools(new Avalonia.Diagnostics.DevToolsOptions() |
|
|
|
{ |
|
|
|
StartupScreenIndex = 1, |
|
|
|
}); |
|
|
|
//Renderer.DrawFps = true;
|
|
|
|
//Renderer.DrawDirtyRects = Renderer.DrawFps = true;
|
|
|
|
|
|
|
|
|
|
|
|
@ -70,7 +70,7 @@ namespace Avalonia.Controls.Remote |
|
|
|
|
|
|
|
public override void Render(DrawingContext context) |
|
|
|
{ |
|
|
|
if (_lastFrame != null) |
|
|
|
if (_lastFrame != null && _lastFrame.Width != 0 && _lastFrame.Height != 0) |
|
|
|
{ |
|
|
|
var fmt = (PixelFormat) _lastFrame.Format; |
|
|
|
if (_bitmap == null || _bitmap.PixelSize.Width != _lastFrame.Width || |
|
|
|
|
|
|
|
@ -10,7 +10,8 @@ namespace Avalonia.Diagnostics |
|
|
|
{ |
|
|
|
public static class DevTools |
|
|
|
{ |
|
|
|
private static readonly Dictionary<TopLevel, Window> s_open = new Dictionary<TopLevel, Window>(); |
|
|
|
private static readonly Dictionary<TopLevel, MainWindow> s_open = |
|
|
|
new Dictionary<TopLevel, MainWindow>(); |
|
|
|
|
|
|
|
public static IDisposable Attach(TopLevel root, KeyGesture gesture) |
|
|
|
{ |
|
|
|
@ -52,6 +53,7 @@ namespace Avalonia.Diagnostics |
|
|
|
Width = options.Size.Width, |
|
|
|
Height = options.Size.Height, |
|
|
|
}; |
|
|
|
window.SetOptions(options); |
|
|
|
|
|
|
|
window.Closed += DevToolsClosed; |
|
|
|
s_open.Add(root, window); |
|
|
|
|
|
|
|
@ -22,5 +22,10 @@ namespace Avalonia.Diagnostics |
|
|
|
/// Gets or sets the initial size of the DevTools window. The default value is 1280x720.
|
|
|
|
/// </summary>
|
|
|
|
public Size Size { get; set; } = new Size(1280, 720); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get or set the startup screen index where the DevTools window will be displayed.
|
|
|
|
/// </summary>
|
|
|
|
public int? StartupScreenIndex { get; set; } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -151,7 +151,7 @@ namespace Avalonia.Diagnostics.ViewModels |
|
|
|
get { return _pointerOverElement; } |
|
|
|
private set { RaiseAndSetIfChanged(ref _pointerOverElement, value); } |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void UpdateConsoleContext(ConsoleContext context) |
|
|
|
{ |
|
|
|
context.root = _root; |
|
|
|
@ -213,5 +213,12 @@ namespace Avalonia.Diagnostics.ViewModels |
|
|
|
tree.SelectControl(control); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public int? StartupScreenIndex { get; private set; } = default; |
|
|
|
|
|
|
|
public void SetOptions(DevToolsOptions options) |
|
|
|
{ |
|
|
|
StartupScreenIndex = options.StartupScreenIndex; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -24,6 +24,23 @@ namespace Avalonia.Diagnostics.Views |
|
|
|
_keySubscription = InputManager.Instance.Process |
|
|
|
.OfType<RawKeyEventArgs>() |
|
|
|
.Subscribe(RawKeyDown); |
|
|
|
|
|
|
|
EventHandler? lh = default; |
|
|
|
lh = (s, e) => |
|
|
|
{ |
|
|
|
this.Opened -= lh; |
|
|
|
if ((DataContext as MainViewModel)?.StartupScreenIndex is int index) |
|
|
|
{ |
|
|
|
var screens = this.Screens; |
|
|
|
if (index > -1 && index < screens.ScreenCount) |
|
|
|
{ |
|
|
|
var screen = screens.All[index]; |
|
|
|
this.Position = screen.Bounds.TopLeft; |
|
|
|
this.WindowState = WindowState.Maximized; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
this.Opened += lh; |
|
|
|
} |
|
|
|
|
|
|
|
public TopLevel? Root |
|
|
|
@ -115,5 +132,8 @@ namespace Avalonia.Diagnostics.Views |
|
|
|
} |
|
|
|
|
|
|
|
private void RootClosed(object? sender, EventArgs e) => Close(); |
|
|
|
|
|
|
|
public void SetOptions(DevToolsOptions options) => |
|
|
|
(DataContext as MainViewModel)?.SetOptions(options); |
|
|
|
} |
|
|
|
} |
|
|
|
|