Browse Source

Merge branch 'master' into master

pull/2672/head
Artyom 7 years ago
committed by GitHub
parent
commit
6d18216f87
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      samples/ControlCatalog/Pages/ContextMenuPage.xaml.cs
  2. 14
      samples/ControlCatalog/Pages/MenuPage.xaml.cs
  3. 7
      samples/ControlCatalog/ViewModels/ContextMenuPageViewModel.cs
  4. 7
      samples/ControlCatalog/ViewModels/MenuPageViewModel.cs
  5. 5
      src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs
  6. 2
      src/Avalonia.Controls/Primitives/PopupRoot.cs
  7. 5
      src/Avalonia.Controls/Screens.cs
  8. 3
      src/Avalonia.Controls/Window.cs
  9. 3
      src/Avalonia.Controls/WindowBase.cs
  10. 4
      src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebuffer.cs
  11. 8
      src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs
  12. 2
      src/Markup/Avalonia.Markup.Xaml/XamlIl/xamlil.github

13
samples/ControlCatalog/Pages/ContextMenuPage.xaml.cs

@ -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);

14
samples/ControlCatalog/Pages/MenuPage.xaml.cs

@ -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);
}
}
}

7
samples/ControlCatalog/ViewModels/ContextMenuPageViewModel.cs

@ -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)
{

7
samples/ControlCatalog/ViewModels/MenuPageViewModel.cs

@ -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)
{

5
src/Avalonia.Controls/Embedding/EmbeddableControlRoot.cs

@ -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();

2
src/Avalonia.Controls/Primitives/PopupRoot.cs

@ -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)
{

5
src/Avalonia.Controls/Screens.cs

@ -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)

3
src/Avalonia.Controls/Window.cs

@ -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>

3
src/Avalonia.Controls/WindowBase.cs

@ -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.

4
src/Linux/Avalonia.LinuxFramebuffer/LinuxFramebuffer.cs

@ -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());

8
src/Markup/Avalonia.Markup.Xaml/AvaloniaXamlLoader.cs

@ -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

2
src/Markup/Avalonia.Markup.Xaml/XamlIl/xamlil.github

@ -1 +1 @@
Subproject commit 610cda30c69e32e83c8235060606480904c937bc
Subproject commit 894b2c02827fd5eb16a338de5d5b6c9fbc60fef5
Loading…
Cancel
Save