Browse Source

Changes according to PR comments.

pull/877/head
Andrey Alonzov 10 years ago
parent
commit
adda76bcc0
  1. 1
      src/Avalonia.Controls/Platform/IWindowImpl.cs
  2. 26
      src/Avalonia.Controls/Window.cs
  3. 1
      src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs
  4. 1
      src/Gtk/Avalonia.Gtk/WindowImpl.cs
  5. 1
      src/Gtk/Avalonia.Gtk/WindowImplBase.cs
  6. 28
      src/Windows/Avalonia.Win32/WindowImpl.cs

1
src/Avalonia.Controls/Platform/IWindowImpl.cs

@ -28,7 +28,6 @@ namespace Avalonia.Platform
/// <returns> /// <returns>
/// An <see cref="IDisposable"/> that should be used to close the window. /// An <see cref="IDisposable"/> that should be used to close the window.
/// </returns> /// </returns>
[Obsolete("Use Avalonia.Controls.Window.ShowDialog() instead.")]
IDisposable ShowDialog(); IDisposable ShowDialog();
/// <summary> /// <summary>

26
src/Avalonia.Controls/Window.cs

@ -47,7 +47,7 @@ namespace Avalonia.Controls
/// </summary> /// </summary>
public class Window : TopLevel, IStyleable, IFocusScope, ILayoutRoot, INameScope public class Window : TopLevel, IStyleable, IFocusScope, ILayoutRoot, INameScope
{ {
private static IList<Window> s_windows = new List<Window>(); private static IList<Window> s_windows = new List<Window>();
/// <summary> /// <summary>
/// Retrieves an enumeration of all Windows in the currently running application. /// Retrieves an enumeration of all Windows in the currently running application.
@ -91,7 +91,7 @@ namespace Avalonia.Controls
TitleProperty.Changed.AddClassHandler<Window>((s, e) => s.PlatformImpl.SetTitle((string)e.NewValue)); TitleProperty.Changed.AddClassHandler<Window>((s, e) => s.PlatformImpl.SetTitle((string)e.NewValue));
HasSystemDecorationsProperty.Changed.AddClassHandler<Window>( HasSystemDecorationsProperty.Changed.AddClassHandler<Window>(
(s, e) => s.PlatformImpl.SetSystemDecorations((bool) e.NewValue)); (s, e) => s.PlatformImpl.SetSystemDecorations((bool) e.NewValue));
IconProperty.Changed.AddClassHandler<Window>((s, e) => s.PlatformImpl.SetIcon(((WindowIcon)e.NewValue).PlatformImpl)); IconProperty.Changed.AddClassHandler<Window>((s, e) => s.PlatformImpl.SetIcon(((WindowIcon)e.NewValue).PlatformImpl));
} }
@ -182,7 +182,7 @@ namespace Avalonia.Controls
Size ILayoutRoot.MaxClientSize => _maxPlatformClientSize; Size ILayoutRoot.MaxClientSize => _maxPlatformClientSize;
/// <inheritdoc/> /// <inheritdoc/>
Type IStyleable.StyleKey => typeof(Window); Type IStyleable.StyleKey => typeof(Window);
/// <summary> /// <summary>
/// Closes the window. /// Closes the window.
@ -240,7 +240,7 @@ namespace Avalonia.Controls
PlatformImpl.Show(); PlatformImpl.Show();
} }
} }
/// <summary> /// <summary>
/// Shows the window as a dialog. /// Shows the window as a dialog.
/// </summary> /// </summary>
@ -265,14 +265,14 @@ namespace Avalonia.Controls
{ {
s_windows.Add(this); s_windows.Add(this);
EnsureInitialized(); EnsureInitialized();
LayoutManager.Instance.ExecuteInitialLayoutPass(this); LayoutManager.Instance.ExecuteInitialLayoutPass(this);
using (BeginAutoSizing()) using (BeginAutoSizing())
{ {
var modal = GetModal(); var modal = ShowModal();
var result = new TaskCompletionSource<TResult>(); var result = new TaskCompletionSource<TResult>();
Observable.FromEventPattern(this, nameof(Closed)) Observable.FromEventPattern(this, nameof(Closed))
.Take(1) .Take(1)
.Subscribe(_ => .Subscribe(_ =>
@ -284,8 +284,8 @@ namespace Avalonia.Controls
return result.Task; return result.Task;
} }
} }
private IDisposable GetModal() private IDisposable ShowModal()
{ {
var disabled = s_windows.Where(w => w.IsEnabled && w != this); var disabled = s_windows.Where(w => w.IsEnabled && w != this);
Window activated = null; Window activated = null;
@ -299,7 +299,7 @@ namespace Avalonia.Controls
window.IsEnabled = false; window.IsEnabled = false;
} }
PlatformImpl.Show(); PlatformImpl.ShowDialog();
return Disposable.Create(() => return Disposable.Create(() =>
{ {
@ -335,7 +335,7 @@ namespace Avalonia.Controls
var sizeToContent = SizeToContent; var sizeToContent = SizeToContent;
var size = ClientSize; var size = ClientSize;
var desired = base.MeasureOverride(availableSize.Constrain(_maxPlatformClientSize)); var desired = base.MeasureOverride(availableSize.Constrain(_maxPlatformClientSize));
switch (sizeToContent) switch (sizeToContent)
{ {
case SizeToContent.Width: case SizeToContent.Width:
@ -376,7 +376,7 @@ namespace Avalonia.Controls
init.BeginInit(); init.BeginInit();
init.EndInit(); init.EndInit();
} }
} }
} }
} }

1
src/Gtk/Avalonia.Gtk/EmbeddableImpl.cs

@ -45,7 +45,6 @@ namespace Avalonia.Gtk
{ {
} }
[Obsolete("Use Avalonia.Controls.Window.ShowDialog() instead.")]
public override IDisposable ShowDialog() => Disposable.Create(() => { }); public override IDisposable ShowDialog() => Disposable.Create(() => { });
public override void SetSystemDecorations(bool enabled) public override void SetSystemDecorations(bool enabled)

1
src/Gtk/Avalonia.Gtk/WindowImpl.cs

@ -108,7 +108,6 @@ namespace Avalonia.Gtk
} }
} }
[Obsolete("Use Avalonia.Controls.Window.ShowDialog() instead.")]
public override IDisposable ShowDialog() public override IDisposable ShowDialog()
{ {
Window.Modal = true; Window.Modal = true;

1
src/Gtk/Avalonia.Gtk/WindowImplBase.cs

@ -167,7 +167,6 @@ namespace Avalonia.Gtk
} }
public abstract void SetTitle(string title); public abstract void SetTitle(string title);
[Obsolete("Use Avalonia.Controls.Window.ShowDialog() instead.")]
public abstract IDisposable ShowDialog(); public abstract IDisposable ShowDialog();
public abstract void SetSystemDecorations(bool enabled); public abstract void SetSystemDecorations(bool enabled);
public abstract void SetIcon(IWindowIconImpl icon); public abstract void SetIcon(IWindowIconImpl icon);

28
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -137,7 +137,7 @@ namespace Avalonia.Win32
public WindowState WindowState public WindowState WindowState
{ {
get get
{ {
var placement = default(UnmanagedMethods.WINDOWPLACEMENT); var placement = default(UnmanagedMethods.WINDOWPLACEMENT);
UnmanagedMethods.GetWindowPlacement(_hwnd, ref placement); UnmanagedMethods.GetWindowPlacement(_hwnd, ref placement);
@ -176,7 +176,7 @@ namespace Avalonia.Win32
} }
public IPopupImpl CreatePopup() public IPopupImpl CreatePopup()
{ {
return new PopupImpl(); return new PopupImpl();
} }
@ -342,33 +342,11 @@ namespace Avalonia.Win32
} }
} }
[Obsolete("Use Avalonia.Controls.Window.ShowDialog() instead.")]
public virtual IDisposable ShowDialog() public virtual IDisposable ShowDialog()
{ {
var disabled = s_instances.Where(x => x != this && x.IsEnabled).ToList();
WindowImpl activated = null;
foreach (var window in disabled)
{
if (window._isActive)
{
activated = window;
}
window.IsEnabled = false;
}
Show(); Show();
return Disposable.Create(() => return Disposable.Empty;
{
foreach (var window in disabled)
{
window.IsEnabled = true;
}
activated?.Activate();
});
} }
public void SetCursor(IPlatformHandle cursor) public void SetCursor(IPlatformHandle cursor)

Loading…
Cancel
Save