163 changed files with 4928 additions and 2281 deletions
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -0,0 +1,5 @@ |
|||
<ProjectConfiguration> |
|||
<Settings> |
|||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|||
</Settings> |
|||
</ProjectConfiguration> |
|||
@ -1,6 +1,6 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="SkiaSharp" Version="1.57.1" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="Avalonia.Skia.Linux.Natives" Version="1.57.1.3" /> |
|||
<PackageReference Include="SkiaSharp" Version="1.60.0" /> |
|||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="Avalonia.Skia.Linux.Natives" Version="1.60.0.1" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
|
|||
@ -0,0 +1,5 @@ |
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<ItemGroup> |
|||
<PackageReference Include="System.Memory" Version="4.5.0" /> |
|||
</ItemGroup> |
|||
</Project> |
|||
@ -1,7 +1,7 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" |
|||
xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' |
|||
xmlns:vm="clr-namespace:BindingTest.ViewModels" |
|||
xmlns:local="clr-namespace:BindingTest" |
|||
xmlns:vm="clr-namespace:BindingDemo.ViewModels" |
|||
xmlns:local="clr-namespace:BindingDemo" |
|||
Title="AvaloniaUI Bindings Test" |
|||
Width="800" |
|||
Height="600"> |
|||
@ -1,9 +1,9 @@ |
|||
using BindingTest.ViewModels; |
|||
using BindingDemo.ViewModels; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace BindingTest |
|||
namespace BindingDemo |
|||
{ |
|||
public class MainWindow : Window |
|||
{ |
|||
@ -1,7 +1,7 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace BindingTest |
|||
namespace BindingDemo |
|||
{ |
|||
public class TestItemView : UserControl |
|||
{ |
|||
@ -1,6 +1,6 @@ |
|||
using ReactiveUI; |
|||
|
|||
namespace BindingTest.ViewModels |
|||
namespace BindingDemo.ViewModels |
|||
{ |
|||
public class TestItem : ReactiveObject |
|||
{ |
|||
@ -1,6 +1,6 @@ |
|||
<Window xmlns="https://github.com/avaloniaui" |
|||
Title="AvaloniaUI Rendering Test" |
|||
xmlns:pages="clr-namespace:RenderTest.Pages" |
|||
xmlns:pages="clr-namespace:RenderDemo.Pages" |
|||
Width="800" |
|||
Height="600"> |
|||
<DockPanel> |
|||
@ -1,7 +1,7 @@ |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace RenderTest.Pages |
|||
namespace RenderDemo.Pages |
|||
{ |
|||
public class DrawingPage : UserControl |
|||
{ |
|||
@ -1,7 +1,7 @@ |
|||
using System; |
|||
using ReactiveUI; |
|||
|
|||
namespace RenderTest.ViewModels |
|||
namespace RenderDemo.ViewModels |
|||
{ |
|||
public class MainWindowViewModel : ReactiveObject |
|||
{ |
|||
@ -1,42 +0,0 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Reactive; |
|||
using System.Reactive.Disposables; |
|||
|
|||
namespace Avalonia.Reactive |
|||
{ |
|||
/// <summary>
|
|||
/// An <see cref="IObservable{T}"/> with an additional description.
|
|||
/// </summary>
|
|||
/// <typeparam name="T">The type of the elements in the sequence.</typeparam>
|
|||
public class AvaloniaObservable<T> : ObservableBase<T>, IDescription |
|||
{ |
|||
private readonly Func<IObserver<T>, IDisposable> _subscribe; |
|||
|
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="AvaloniaObservable{T}"/> class.
|
|||
/// </summary>
|
|||
/// <param name="subscribe">The subscribe function.</param>
|
|||
/// <param name="description">The description of the observable.</param>
|
|||
public AvaloniaObservable(Func<IObserver<T>, IDisposable> subscribe, string description) |
|||
{ |
|||
Contract.Requires<ArgumentNullException>(subscribe != null); |
|||
|
|||
_subscribe = subscribe; |
|||
Description = description; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Gets the description of the observable.
|
|||
/// </summary>
|
|||
public string Description { get; } |
|||
|
|||
/// <inheritdoc/>
|
|||
protected override IDisposable SubscribeCore(IObserver<T> observer) |
|||
{ |
|||
return _subscribe(observer) ?? Disposable.Empty; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Reactive |
|||
{ |
|||
internal class AvaloniaPropertyChangedObservable : |
|||
LightweightObservableBase<AvaloniaPropertyChangedEventArgs>, |
|||
IDescription |
|||
{ |
|||
private readonly WeakReference<IAvaloniaObject> _target; |
|||
private readonly AvaloniaProperty _property; |
|||
|
|||
public AvaloniaPropertyChangedObservable( |
|||
IAvaloniaObject target, |
|||
AvaloniaProperty property) |
|||
{ |
|||
_target = new WeakReference<IAvaloniaObject>(target); |
|||
_property = property; |
|||
} |
|||
|
|||
public string Description => $"{_target.GetType().Name}.{_property.Name}"; |
|||
|
|||
protected override void Initialize() |
|||
{ |
|||
if (_target.TryGetTarget(out var target)) |
|||
{ |
|||
target.PropertyChanged += PropertyChanged; |
|||
} |
|||
} |
|||
|
|||
protected override void Deinitialize() |
|||
{ |
|||
if (_target.TryGetTarget(out var target)) |
|||
{ |
|||
target.PropertyChanged -= PropertyChanged; |
|||
} |
|||
} |
|||
|
|||
private void PropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e) |
|||
{ |
|||
if (e.Property == _property) |
|||
{ |
|||
PublishNext(e); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
using System; |
|||
|
|||
namespace Avalonia.Reactive |
|||
{ |
|||
internal class AvaloniaPropertyObservable<T> : LightweightObservableBase<T>, IDescription |
|||
{ |
|||
private readonly WeakReference<IAvaloniaObject> _target; |
|||
private readonly AvaloniaProperty _property; |
|||
private T _value; |
|||
|
|||
public AvaloniaPropertyObservable( |
|||
IAvaloniaObject target, |
|||
AvaloniaProperty property) |
|||
{ |
|||
_target = new WeakReference<IAvaloniaObject>(target); |
|||
_property = property; |
|||
} |
|||
|
|||
public string Description => $"{_target.GetType().Name}.{_property.Name}"; |
|||
|
|||
protected override void Initialize() |
|||
{ |
|||
if (_target.TryGetTarget(out var target)) |
|||
{ |
|||
_value = (T)target.GetValue(_property); |
|||
target.PropertyChanged += PropertyChanged; |
|||
} |
|||
} |
|||
|
|||
protected override void Deinitialize() |
|||
{ |
|||
if (_target.TryGetTarget(out var target)) |
|||
{ |
|||
target.PropertyChanged -= PropertyChanged; |
|||
} |
|||
} |
|||
|
|||
protected override void Subscribed(IObserver<T> observer, bool first) |
|||
{ |
|||
observer.OnNext(_value); |
|||
} |
|||
|
|||
private void PropertyChanged(object sender, AvaloniaPropertyChangedEventArgs e) |
|||
{ |
|||
if (e.Property == _property) |
|||
{ |
|||
_value = (T)e.NewValue; |
|||
PublishNext(_value); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,202 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Reactive; |
|||
using System.Reactive.Disposables; |
|||
using System.Threading; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace Avalonia.Reactive |
|||
{ |
|||
/// <summary>
|
|||
/// Lightweight base class for observable implementations.
|
|||
/// </summary>
|
|||
/// <typeparam name="T">The observable type.</typeparam>
|
|||
/// <remarks>
|
|||
/// <see cref="ObservableBase{T}"/> is rather heavyweight in terms of allocations and memory
|
|||
/// usage. This class provides a more lightweight base for some internal observable types
|
|||
/// in the Avalonia framework.
|
|||
/// </remarks>
|
|||
public abstract class LightweightObservableBase<T> : IObservable<T> |
|||
{ |
|||
private Exception _error; |
|||
private List<IObserver<T>> _observers = new List<IObserver<T>>(); |
|||
|
|||
public IDisposable Subscribe(IObserver<T> observer) |
|||
{ |
|||
Contract.Requires<ArgumentNullException>(observer != null); |
|||
Dispatcher.UIThread.VerifyAccess(); |
|||
|
|||
var first = false; |
|||
|
|||
for (; ; ) |
|||
{ |
|||
if (Volatile.Read(ref _observers) == null) |
|||
{ |
|||
if (_error != null) |
|||
{ |
|||
observer.OnError(_error); |
|||
} |
|||
else |
|||
{ |
|||
observer.OnCompleted(); |
|||
} |
|||
|
|||
return Disposable.Empty; |
|||
} |
|||
|
|||
lock (this) |
|||
{ |
|||
if (_observers == null) |
|||
{ |
|||
continue; |
|||
} |
|||
|
|||
first = _observers.Count == 0; |
|||
_observers.Add(observer); |
|||
break; |
|||
} |
|||
} |
|||
|
|||
if (first) |
|||
{ |
|||
Initialize(); |
|||
} |
|||
|
|||
Subscribed(observer, first); |
|||
|
|||
return new RemoveObserver(this, observer); |
|||
} |
|||
|
|||
void Remove(IObserver<T> observer) |
|||
{ |
|||
if (Volatile.Read(ref _observers) != null) |
|||
{ |
|||
lock (this) |
|||
{ |
|||
var observers = _observers; |
|||
|
|||
if (observers != null) |
|||
{ |
|||
observers.Remove(observer); |
|||
|
|||
if (observers.Count == 0) |
|||
{ |
|||
observers.TrimExcess(); |
|||
} |
|||
else |
|||
{ |
|||
return; |
|||
} |
|||
} else |
|||
{ |
|||
return; |
|||
} |
|||
} |
|||
|
|||
Deinitialize(); |
|||
} |
|||
} |
|||
|
|||
sealed class RemoveObserver : IDisposable |
|||
{ |
|||
LightweightObservableBase<T> _parent; |
|||
|
|||
IObserver<T> _observer; |
|||
|
|||
public RemoveObserver(LightweightObservableBase<T> parent, IObserver<T> observer) |
|||
{ |
|||
_parent = parent; |
|||
Volatile.Write(ref _observer, observer); |
|||
} |
|||
|
|||
public void Dispose() |
|||
{ |
|||
var observer = _observer; |
|||
Interlocked.Exchange(ref _parent, null)?.Remove(observer); |
|||
_observer = null; |
|||
} |
|||
} |
|||
|
|||
protected abstract void Initialize(); |
|||
protected abstract void Deinitialize(); |
|||
|
|||
protected void PublishNext(T value) |
|||
{ |
|||
if (Volatile.Read(ref _observers) != null) |
|||
{ |
|||
IObserver<T>[] observers; |
|||
|
|||
lock (this) |
|||
{ |
|||
if (_observers == null) |
|||
{ |
|||
return; |
|||
} |
|||
observers = _observers.ToArray(); |
|||
} |
|||
|
|||
foreach (var observer in observers) |
|||
{ |
|||
observer.OnNext(value); |
|||
} |
|||
} |
|||
} |
|||
|
|||
protected void PublishCompleted() |
|||
{ |
|||
if (Volatile.Read(ref _observers) != null) |
|||
{ |
|||
IObserver<T>[] observers; |
|||
|
|||
lock (this) |
|||
{ |
|||
if (_observers == null) |
|||
{ |
|||
return; |
|||
} |
|||
observers = _observers.ToArray(); |
|||
Volatile.Write(ref _observers, null); |
|||
} |
|||
|
|||
foreach (var observer in observers) |
|||
{ |
|||
observer.OnCompleted(); |
|||
} |
|||
|
|||
Deinitialize(); |
|||
} |
|||
} |
|||
|
|||
protected void PublishError(Exception error) |
|||
{ |
|||
if (Volatile.Read(ref _observers) != null) |
|||
{ |
|||
|
|||
IObserver<T>[] observers; |
|||
|
|||
lock (this) |
|||
{ |
|||
if (_observers == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
_error = error; |
|||
observers = _observers.ToArray(); |
|||
Volatile.Write(ref _observers, null); |
|||
} |
|||
|
|||
foreach (var observer in observers) |
|||
{ |
|||
observer.OnError(error); |
|||
} |
|||
|
|||
Deinitialize(); |
|||
} |
|||
} |
|||
|
|||
protected virtual void Subscribed(IObserver<T> observer, bool first) |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
using System; |
|||
using Avalonia.Threading; |
|||
|
|||
namespace Avalonia.Reactive |
|||
{ |
|||
public abstract class SingleSubscriberObservableBase<T> : IObservable<T>, IDisposable |
|||
{ |
|||
private Exception _error; |
|||
private IObserver<T> _observer; |
|||
private bool _completed; |
|||
|
|||
public IDisposable Subscribe(IObserver<T> observer) |
|||
{ |
|||
Contract.Requires<ArgumentNullException>(observer != null); |
|||
Dispatcher.UIThread.VerifyAccess(); |
|||
|
|||
if (_observer != null) |
|||
{ |
|||
throw new InvalidOperationException("The observable can only be subscribed once."); |
|||
} |
|||
|
|||
if (_error != null) |
|||
{ |
|||
observer.OnError(_error); |
|||
} |
|||
else if (_completed) |
|||
{ |
|||
observer.OnCompleted(); |
|||
} |
|||
else |
|||
{ |
|||
_observer = observer; |
|||
Subscribed(); |
|||
} |
|||
|
|||
return this; |
|||
} |
|||
|
|||
void IDisposable.Dispose() |
|||
{ |
|||
Unsubscribed(); |
|||
_observer = null; |
|||
} |
|||
|
|||
protected abstract void Unsubscribed(); |
|||
|
|||
protected void PublishNext(T value) |
|||
{ |
|||
_observer?.OnNext(value); |
|||
} |
|||
|
|||
protected void PublishCompleted() |
|||
{ |
|||
if (_observer != null) |
|||
{ |
|||
_observer.OnCompleted(); |
|||
_completed = true; |
|||
Unsubscribed(); |
|||
_observer = null; |
|||
} |
|||
} |
|||
|
|||
protected void PublishError(Exception error) |
|||
{ |
|||
if (_observer != null) |
|||
{ |
|||
_observer.OnError(error); |
|||
_error = error; |
|||
Unsubscribed(); |
|||
_observer = null; |
|||
} |
|||
} |
|||
|
|||
protected abstract void Subscribed(); |
|||
} |
|||
} |
|||
@ -1,85 +0,0 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using System.Reactive; |
|||
using System.Reactive.Disposables; |
|||
using System.Reactive.Linq; |
|||
using System.Reactive.Subjects; |
|||
using Avalonia.Utilities; |
|||
|
|||
namespace Avalonia.Reactive |
|||
{ |
|||
internal class WeakPropertyChangedObservable : ObservableBase<object>, |
|||
IWeakSubscriber<AvaloniaPropertyChangedEventArgs>, IDescription |
|||
{ |
|||
private WeakReference<IAvaloniaObject> _sourceReference; |
|||
private readonly AvaloniaProperty _property; |
|||
private readonly Subject<object> _changed = new Subject<object>(); |
|||
|
|||
private int _count; |
|||
|
|||
public WeakPropertyChangedObservable( |
|||
WeakReference<IAvaloniaObject> source, |
|||
AvaloniaProperty property, |
|||
string description) |
|||
{ |
|||
_sourceReference = source; |
|||
_property = property; |
|||
Description = description; |
|||
} |
|||
|
|||
public string Description { get; } |
|||
|
|||
public void OnEvent(object sender, AvaloniaPropertyChangedEventArgs e) |
|||
{ |
|||
if (e.Property == _property) |
|||
{ |
|||
_changed.OnNext(e.NewValue); |
|||
} |
|||
} |
|||
|
|||
protected override IDisposable SubscribeCore(IObserver<object> observer) |
|||
{ |
|||
IAvaloniaObject instance; |
|||
|
|||
if (_sourceReference.TryGetTarget(out instance)) |
|||
{ |
|||
if (_count++ == 0) |
|||
{ |
|||
WeakSubscriptionManager.Subscribe( |
|||
instance, |
|||
nameof(instance.PropertyChanged), |
|||
this); |
|||
} |
|||
|
|||
observer.OnNext(instance.GetValue(_property)); |
|||
|
|||
return Observable.Using(() => Disposable.Create(DecrementCount), _ => _changed) |
|||
.Subscribe(observer); |
|||
} |
|||
else |
|||
{ |
|||
_changed.OnCompleted(); |
|||
observer.OnCompleted(); |
|||
return Disposable.Empty; |
|||
} |
|||
} |
|||
|
|||
private void DecrementCount() |
|||
{ |
|||
if (--_count == 0) |
|||
{ |
|||
IAvaloniaObject instance; |
|||
|
|||
if (_sourceReference.TryGetTarget(out instance)) |
|||
{ |
|||
WeakSubscriptionManager.Unsubscribe( |
|||
instance, |
|||
nameof(instance.PropertyChanged), |
|||
this); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
namespace Avalonia |
|||
{ |
|||
/// <summary>
|
|||
/// Enum for ExitMode
|
|||
/// </summary>
|
|||
public enum ExitMode |
|||
{ |
|||
/// <summary>
|
|||
/// Indicates an implicit call to Application.Exit when the last window closes.
|
|||
/// </summary>
|
|||
OnLastWindowClose, |
|||
|
|||
/// <summary>
|
|||
/// Indicates an implicit call to Application.Exit when the main window closes.
|
|||
/// </summary>
|
|||
OnMainWindowClose, |
|||
|
|||
/// <summary>
|
|||
/// Indicates that the application only exits on an explicit call to Application.Exit.
|
|||
/// </summary>
|
|||
OnExplicitExit |
|||
} |
|||
} |
|||
@ -0,0 +1,134 @@ |
|||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
|
|||
using Avalonia.Controls; |
|||
|
|||
namespace Avalonia |
|||
{ |
|||
public class WindowCollection : IReadOnlyList<Window> |
|||
{ |
|||
private readonly Application _application; |
|||
private readonly List<Window> _windows = new List<Window>(); |
|||
|
|||
public WindowCollection(Application application) |
|||
{ |
|||
_application = application; |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
/// <summary>
|
|||
/// Gets the number of elements in the collection.
|
|||
/// </summary>
|
|||
public int Count => _windows.Count; |
|||
|
|||
/// <inheritdoc />
|
|||
/// <summary>
|
|||
/// Gets the <see cref="T:Avalonia.Controls.Window" /> at the specified index.
|
|||
/// </summary>
|
|||
/// <value>
|
|||
/// The <see cref="T:Avalonia.Controls.Window" />.
|
|||
/// </value>
|
|||
/// <param name="index">The index.</param>
|
|||
/// <returns></returns>
|
|||
public Window this[int index] => _windows[index]; |
|||
|
|||
/// <inheritdoc />
|
|||
/// <summary>
|
|||
/// Returns an enumerator that iterates through the collection.
|
|||
/// </summary>
|
|||
/// <returns>
|
|||
/// An enumerator that can be used to iterate through the collection.
|
|||
/// </returns>
|
|||
public IEnumerator<Window> GetEnumerator() |
|||
{ |
|||
return _windows.GetEnumerator(); |
|||
} |
|||
|
|||
/// <inheritdoc />
|
|||
/// <summary>
|
|||
/// Returns an enumerator that iterates through a collection.
|
|||
/// </summary>
|
|||
/// <returns>
|
|||
/// An <see cref="T:System.Collections.IEnumerator"></see> object that can be used to iterate through the collection.
|
|||
/// </returns>
|
|||
IEnumerator IEnumerable.GetEnumerator() |
|||
{ |
|||
return GetEnumerator(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Adds the specified window.
|
|||
/// </summary>
|
|||
/// <param name="window">The window.</param>
|
|||
internal void Add(Window window) |
|||
{ |
|||
if (window == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
_windows.Add(window); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Removes the specified window.
|
|||
/// </summary>
|
|||
/// <param name="window">The window.</param>
|
|||
internal void Remove(Window window) |
|||
{ |
|||
if (window == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
_windows.Remove(window); |
|||
|
|||
OnRemoveWindow(window); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Closes all windows and removes them from the underlying collection.
|
|||
/// </summary>
|
|||
internal void Clear() |
|||
{ |
|||
while (_windows.Count > 0) |
|||
{ |
|||
_windows[0].Close(); |
|||
} |
|||
} |
|||
|
|||
private void OnRemoveWindow(Window window) |
|||
{ |
|||
if (window == null) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
if (_application.IsExiting) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
switch (_application.ExitMode) |
|||
{ |
|||
case ExitMode.OnLastWindowClose: |
|||
if (Count == 0) |
|||
{ |
|||
_application.Exit(); |
|||
} |
|||
|
|||
break; |
|||
case ExitMode.OnMainWindowClose: |
|||
if (window == _application.MainWindow) |
|||
{ |
|||
_application.Exit(); |
|||
} |
|||
|
|||
break; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue