/// </summary>
public class ScreenMirroring : IDisposable, IDisplayable<ScreenMirroringErrorCode>
{
+ private const string Feature = "http://tizen.org/feature/network.wifi.direct.display";
private const int Port = 2022;
private IntPtr _handle;
{
get
{
- if (_disposed)
- {
- throw new ObjectDisposedException(nameof(ScreenMirroring));
- }
+ ThrowIfDisposed();
return _handle;
}
}
+ private static bool IsSupported()
+ {
+ return System.Information.TryGetValue(Feature, out bool isSupported) ? isSupported : false;
+ }
+
/// <summary>
/// Initializes a new instance of the ScreenMirroring class.
/// </summary>
/// <exception cref="NotSupportedException">The feature is not supported.</exception>
public ScreenMirroring()
{
+ if (IsSupported() == false)
+ {
+ throw new PlatformNotSupportedException($"The feature({Feature}) is not supported on the current device");
+ }
+
Native.Create(out _handle).ThrowIfError("Failed to create ScreenMirroring.");
_state = new AtomicState();
RegisterStateChangedEvent();
}
+ /// <summary>
+ /// Finalizes an instance of the ScreenMirroring class.
+ /// </summary>
~ScreenMirroring()
{
Dispose(false);
return Native.SetDisplay(Handle, (int)type, evasObject);
}
+
+ ScreenMirroringErrorCode IDisplayable<ScreenMirroringErrorCode>.ApplyEcoreWindow(IntPtr windowHandle)
+ {
+ throw new NotSupportedException("ScreenMirroring does not support NUI.Window display.");
+ }
#endregion
/// <summary>
internal void ThrowIfNotConnected()
{
+ ThrowIfDisposed();
+
if (IsConnected == false)
{
throw new InvalidOperationException("ScreenMirroring is not connected.");
/// Prepares the screen mirroring with the specified display.
/// </summary>
/// <remarks>
- /// The state must be <see cref="ScreenMirroringState.Idle"/>.\n
- /// \n
+ /// The state must be <see cref="ScreenMirroringState.Idle"/>.<br/>
+ /// <br/>
/// All supported resolutions will be candidates.
/// </remarks>
/// <param name="display">The display where the mirroring will be played on.</param>
/// </exception>
/// <exception cref="ArgumentNullException"><paramref name="display"/> is null.</exception>
/// <exception cref="InvalidOperationException">
- /// The current state is not in the valid.\n
- /// -or-\n
+ /// The current state is not in the valid.<br/>
+ /// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
/// <param name="display">The display where the mirroring will be played on.</param>
/// <param name="resolutions">The desired resolutions.</param>
/// <exception cref="ArgumentException">
- /// <paramref name="resolutions"/> contain invalid flags.\n
- /// -or-\n
+ /// <paramref name="resolutions"/> contain invalid flags.<br/>
+ /// -or-<br/>
/// <paramref name="display"/> has already been assigned to another.
/// </exception>
/// <exception cref="ArgumentNullException"><paramref name="display"/> is null.</exception>
/// <exception cref="InvalidOperationException">
- /// The current state is not in the valid.\n
- /// -or-\n
+ /// The current state is not in the valid.<br/>
+ /// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
/// <privilege>http://tizen.org/privilege/internet</privilege>
/// <exception cref="ArgumentNullException"><paramref name="sourceIp"/> is null.</exception>
/// <exception cref="InvalidOperationException">
- /// The current state is not in the valid.\n
- /// -or-\n
+ /// The current state is not in the valid.<br/>
+ /// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ArgumentException"><paramref name="sourceIp"/> is a zero-length string, contains only white space.</exception>
/// <returns>A task that represents the asynchronous operation.</returns>
/// <privilege>http://tizen.org/privilege/internet</privilege>
/// <exception cref="InvalidOperationException">
- /// The current state is not in the valid.\n
- /// -or-\n
+ /// The current state is not in the valid.<br/>
+ /// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
/// <returns>A task that represents the asynchronous operation.</returns>
/// <privilege>http://tizen.org/privilege/internet</privilege>
/// <exception cref="InvalidOperationException">
- /// The current state is not in the valid.\n
- /// -or-\n
+ /// The current state is not in the valid.<br/>
+ /// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
/// <returns>A task that represents the asynchronous operation.</returns>
/// <privilege>http://tizen.org/privilege/internet</privilege>
/// <exception cref="InvalidOperationException">
- /// The current state is not in the valid.\n
- /// -or-\n
+ /// The current state is not in the valid.<br/>
+ /// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
/// </remarks>
/// <privilege>http://tizen.org/privilege/internet</privilege>
/// <exception cref="InvalidOperationException">
- /// The current state is not in the valid.\n
- /// -or-\n
+ /// The current state is not in the valid.<br/>
+ /// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
/// or <see cref="ScreenMirroringState.Disconnected"/>.
/// </remarks>
/// <exception cref="InvalidOperationException">
- /// The current state is not in the valid.\n
- /// -or-\n
+ /// The current state is not in the valid.<br/>
+ /// -or-<br/>
/// An internal error occurs.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="ScreenMirroring"/> has already been disposed.</exception>
DetachDisplay();
}
+ private void ThrowIfDisposed()
+ {
+ if (_disposed)
+ {
+ throw new ObjectDisposedException(nameof(ScreenMirroring));
+ }
+ }
+
/// <summary>
/// Releases all resource used by the <see cref="ScreenMirroring"/> object.
/// </summary>
/// <remarks>
/// Call <see cref="Dispose()"/> when you are finished using the <see cref="ScreenMirroring"/>.
/// The <see cref="Dispose()"/> method leaves the <see cref="ScreenMirroring"/> in an unusable
- /// state. After calling <see cref="Dispose"()/>, you must release all references to the
+ /// state. After calling <see cref="Dispose()"/>, you must release all references to the
/// <see cref="ScreenMirroring"/> so the garbage collector can reclaim the memory that the
/// <see cref="ScreenMirroring"/> was occupying.
/// </remarks>
private void RegisterStateChangedEvent()
{
- _stateChangedCallback = (_, state, error) =>
+ _stateChangedCallback = (error, state, _) =>
{
var prevState = _state.Value;