-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to close an open Window from the side that opened it.
- Loading branch information
Showing
12 changed files
with
146 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Sample/SampleBrowser/SampleBrowser.ViewModel/Page/WindowHandleExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System.Reactive.Disposables; | ||
using Kamishibai; | ||
|
||
namespace SampleBrowser.ViewModel.Page; | ||
|
||
public static class WindowHandleExtensions | ||
{ | ||
public static async Task AddTo(this Task<IWindowHandle> windowHandleTask, CompositeDisposable disposable) | ||
{ | ||
var windowHandle = await windowHandleTask; | ||
disposable.Add(windowHandle); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System.Windows; | ||
|
||
namespace Kamishibai; | ||
|
||
/// <summary> | ||
/// WindowHandle is a wrapper class for <see cref="Window"/> to implement <see cref="IWindowHandle"/>. | ||
/// </summary> | ||
public class WindowHandle : IWindowHandle | ||
{ | ||
/// <summary> | ||
/// Window instance. | ||
/// </summary> | ||
private readonly Window _window; | ||
|
||
/// <summary> | ||
/// Window is closed. | ||
/// </summary> | ||
private bool _closed; | ||
|
||
/// <summary> | ||
/// Constructor. | ||
/// </summary> | ||
/// <param name="window"></param> | ||
public WindowHandle(Window window) | ||
{ | ||
_window = window; | ||
_window.Closed += OnClosed; | ||
} | ||
|
||
/// <summary> | ||
/// Window is closed. | ||
/// </summary> | ||
/// <param name="sender"></param> | ||
/// <param name="e"></param> | ||
private void OnClosed(object sender, EventArgs e) | ||
{ | ||
_closed = true; | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Dispose. | ||
/// </summary> | ||
public void Dispose() | ||
{ | ||
Close(); | ||
} | ||
|
||
/// <summary> | ||
/// Close window. | ||
/// </summary> | ||
public void Close() | ||
{ | ||
if (_closed) | ||
{ | ||
return; | ||
} | ||
|
||
_window.Close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Kamishibai; | ||
|
||
/// <summary> | ||
/// WindowHandle is a wrapper class for Window. | ||
/// </summary> | ||
public interface IWindowHandle : IDisposable | ||
{ | ||
/// <summary> | ||
/// Close window. | ||
/// </summary> | ||
void Close(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters