Artyom
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with
52 additions and
21 deletions
-
samples/ControlCatalog/Pages/ContextMenuPage.xaml.cs
-
samples/ControlCatalog/Pages/MenuPage.xaml.cs
-
samples/ControlCatalog/ViewModels/ContextMenuPageViewModel.cs
-
samples/ControlCatalog/ViewModels/MenuPageViewModel.cs
-
src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs
-
src/Avalonia.Controls/Primitives/PopupRoot.cs
-
src/Avalonia.Controls/Screens.cs
-
src/Avalonia.Controls/Window.cs
-
src/Avalonia.Controls/WindowBase.cs
-
src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebuffer.cs
-
src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs
-
src/Markup/Avalonia.Markup.Xaml/XamlIl/xamlil.github
|
|
|
@ -1,3 +1,4 @@ |
|
|
|
using System; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Markup.Xaml; |
|
|
|
using ControlCatalog.ViewModels; |
|
|
|
@ -12,6 +13,18 @@ namespace ControlCatalog.Pages |
|
|
|
DataContext = new ContextMenuPageViewModel(); |
|
|
|
} |
|
|
|
|
|
|
|
private ContextMenuPageViewModel _model; |
|
|
|
protected override void OnDataContextChanged(EventArgs e) |
|
|
|
{ |
|
|
|
if (_model != null) |
|
|
|
_model.View = null; |
|
|
|
_model = DataContext as ContextMenuPageViewModel; |
|
|
|
if (_model != null) |
|
|
|
_model.View = this; |
|
|
|
|
|
|
|
base.OnDataContextChanged(e); |
|
|
|
} |
|
|
|
|
|
|
|
private void InitializeComponent() |
|
|
|
{ |
|
|
|
AvaloniaXamlLoader.Load(this); |
|
|
|
|
|
|
|
@ -1,3 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Reactive; |
|
|
|
using System.Threading.Tasks; |
|
|
|
@ -21,5 +22,18 @@ namespace ControlCatalog.Pages |
|
|
|
{ |
|
|
|
AvaloniaXamlLoader.Load(this); |
|
|
|
} |
|
|
|
|
|
|
|
private MenuPageViewModel _model; |
|
|
|
protected override void OnDataContextChanged(EventArgs e) |
|
|
|
{ |
|
|
|
if (_model != null) |
|
|
|
_model.View = null; |
|
|
|
_model = DataContext as MenuPageViewModel; |
|
|
|
if (_model != null) |
|
|
|
_model.View = this; |
|
|
|
|
|
|
|
base.OnDataContextChanged(e); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -2,12 +2,14 @@ |
|
|
|
using System.Reactive; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.VisualTree; |
|
|
|
using ReactiveUI; |
|
|
|
|
|
|
|
namespace ControlCatalog.ViewModels |
|
|
|
{ |
|
|
|
public class ContextMenuPageViewModel |
|
|
|
{ |
|
|
|
public Control View { get; set; } |
|
|
|
public ContextMenuPageViewModel() |
|
|
|
{ |
|
|
|
OpenCommand = ReactiveCommand.CreateFromTask(Open); |
|
|
|
@ -48,8 +50,11 @@ namespace ControlCatalog.ViewModels |
|
|
|
|
|
|
|
public async Task Open() |
|
|
|
{ |
|
|
|
var window = View?.GetVisualRoot() as Window; |
|
|
|
if (window == null) |
|
|
|
return; |
|
|
|
var dialog = new OpenFileDialog(); |
|
|
|
var result = await dialog.ShowAsync(App.Current.MainWindow); |
|
|
|
var result = await dialog.ShowAsync(window); |
|
|
|
|
|
|
|
if (result != null) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -3,12 +3,14 @@ using System.Reactive; |
|
|
|
using System.Reactive.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.VisualTree; |
|
|
|
using ReactiveUI; |
|
|
|
|
|
|
|
namespace ControlCatalog.ViewModels |
|
|
|
{ |
|
|
|
public class MenuPageViewModel |
|
|
|
{ |
|
|
|
public Control View { get; set; } |
|
|
|
public MenuPageViewModel() |
|
|
|
{ |
|
|
|
OpenCommand = ReactiveCommand.CreateFromTask(Open); |
|
|
|
@ -65,8 +67,11 @@ namespace ControlCatalog.ViewModels |
|
|
|
|
|
|
|
public async Task Open() |
|
|
|
{ |
|
|
|
var window = View?.GetVisualRoot() as Window; |
|
|
|
if (window == null) |
|
|
|
return; |
|
|
|
var dialog = new OpenFileDialog(); |
|
|
|
var result = await dialog.ShowAsync(App.Current.MainWindow); |
|
|
|
var result = await dialog.ShowAsync(window); |
|
|
|
|
|
|
|
if (result != null) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -45,7 +45,10 @@ namespace Avalonia.Controls.Embedding |
|
|
|
{ |
|
|
|
if (EnforceClientSize) |
|
|
|
availableSize = PlatformImpl?.ClientSize ?? default(Size); |
|
|
|
return base.MeasureOverride(availableSize); |
|
|
|
var rv = base.MeasureOverride(availableSize); |
|
|
|
if (EnforceClientSize) |
|
|
|
return availableSize; |
|
|
|
return rv; |
|
|
|
} |
|
|
|
|
|
|
|
private readonly NameScope _nameScope = new NameScope(); |
|
|
|
|
|
|
|
@ -80,7 +80,7 @@ namespace Avalonia.Controls.Primitives |
|
|
|
/// </summary>
|
|
|
|
public void SnapInsideScreenEdges() |
|
|
|
{ |
|
|
|
var screen = Application.Current.MainWindow?.Screens.ScreenFromPoint(Position); |
|
|
|
var screen = (VisualRoot as WindowBase)?.Screens?.ScreenFromPoint(Position); |
|
|
|
|
|
|
|
if (screen != null) |
|
|
|
{ |
|
|
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using Avalonia.Platform; |
|
|
|
using Avalonia.Utilities; |
|
|
|
@ -11,7 +12,7 @@ namespace Avalonia.Controls |
|
|
|
private readonly IScreenImpl _iScreenImpl; |
|
|
|
|
|
|
|
public int ScreenCount => _iScreenImpl.ScreenCount; |
|
|
|
public IReadOnlyList<Screen> All => _iScreenImpl?.AllScreens; |
|
|
|
public IReadOnlyList<Screen> All => _iScreenImpl?.AllScreens ?? Array.Empty<Screen>(); |
|
|
|
public Screen Primary => All.FirstOrDefault(x => x.Primary); |
|
|
|
|
|
|
|
public Screens(IScreenImpl iScreenImpl) |
|
|
|
|
|
|
|
@ -140,7 +140,6 @@ namespace Avalonia.Controls |
|
|
|
impl.Closing = HandleClosing; |
|
|
|
impl.WindowStateChanged = HandleWindowStateChanged; |
|
|
|
_maxPlatformClientSize = PlatformImpl?.MaxClientSize ?? default(Size); |
|
|
|
Screens = new Screens(PlatformImpl?.Screen); |
|
|
|
} |
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
@ -157,8 +156,6 @@ namespace Avalonia.Controls |
|
|
|
remove { _nameScope.Unregistered -= value; } |
|
|
|
} |
|
|
|
|
|
|
|
public Screens Screens { get; private set; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Gets the platform-specific window implementation.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
@ -63,6 +63,7 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
public WindowBase(IWindowBaseImpl impl, IAvaloniaDependencyResolver dependencyResolver) : base(impl, dependencyResolver) |
|
|
|
{ |
|
|
|
Screens = new Screens(PlatformImpl?.Screen); |
|
|
|
impl.Activated = HandleActivated; |
|
|
|
impl.Deactivated = HandleDeactivated; |
|
|
|
impl.PositionChanged = HandlePositionChanged; |
|
|
|
@ -108,6 +109,8 @@ namespace Avalonia.Controls |
|
|
|
impl.Position = value; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public Screens Screens { get; private set; } |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Whether an auto-size operation is in progress.
|
|
|
|
|
|
|
|
@ -43,12 +43,10 @@ namespace Avalonia.LinuxFramebuffer |
|
|
|
|
|
|
|
SetBpp(); |
|
|
|
|
|
|
|
_varInfo.yoffset = 100; |
|
|
|
if (-1 == NativeUnsafeMethods.ioctl(_fd, FbIoCtl.FBIOPUT_VSCREENINFO, pnfo)) |
|
|
|
_varInfo.transp = new fb_bitfield(); |
|
|
|
|
|
|
|
if (-1 == NativeUnsafeMethods.ioctl(_fd, FbIoCtl.FBIOPUT_VSCREENINFO, pnfo)) |
|
|
|
throw new Exception("FBIOPUT_VSCREENINFO error: " + Marshal.GetLastWin32Error()); |
|
|
|
NativeUnsafeMethods.ioctl(_fd, FbIoCtl.FBIOPUT_VSCREENINFO, pnfo); |
|
|
|
|
|
|
|
if (-1 == NativeUnsafeMethods.ioctl(_fd, FbIoCtl.FBIOGET_VSCREENINFO, pnfo)) |
|
|
|
throw new Exception("FBIOGET_VSCREENINFO error: " + Marshal.GetLastWin32Error()); |
|
|
|
|
|
|
|
@ -2,18 +2,10 @@ |
|
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.ComponentModel; |
|
|
|
using System.IO; |
|
|
|
using System.Linq; |
|
|
|
using System.Reflection; |
|
|
|
using System.Runtime.Serialization; |
|
|
|
using System.Text; |
|
|
|
using System.Xml.Linq; |
|
|
|
using Avalonia.Markup.Xaml.XamlIl; |
|
|
|
using Avalonia.Controls; |
|
|
|
using Avalonia.Markup.Data; |
|
|
|
using Avalonia.Markup.Xaml.PortableXaml; |
|
|
|
using Avalonia.Platform; |
|
|
|
|
|
|
|
namespace Avalonia.Markup.Xaml |
|
|
|
|
|
|
|
@ -1 +1 @@ |
|
|
|
Subproject commit 610cda30c69e32e83c8235060606480904c937bc |
|
|
|
Subproject commit 894b2c02827fd5eb16a338de5d5b6c9fbc60fef5 |