/// </summary>
/// <since_tizen> 4 </since_tizen>
/// <param name="conformant">The caller's conformant.</param>
+ /// <feature>http://tizen.org/feature/attach_panel</feature>
+ /// <exception cref="ArgumentNullException">Thrown when the parameter is null</exception>
/// <exception cref="OutOfMemoryException">Thrown when an attempt to allocate the memory fails.</exception>
/// <exception cref="InvalidOperationException">Thrown when the AttachPanel already exists or the <paramref name="conformant"/> is not a conformant object.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
public AttachPanel(EvasObject conformant)
{
if (conformant == IntPtr.Zero)
{
- throw new ArgumentNullException("Use the value property, not null value");
+ throw new ArgumentNullException("Invalid conformant, it's null");
}
- IntPtr candidateAttachPanel = new IntPtr();
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.CreateAttachPanel(conformant, ref candidateAttachPanel);
+ if (IsAttachPanelSupported() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+ }
+
+ if (IsInitialized())
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.AlreadyExists);
+ }
+
+ var candidateAttachPanel = IntPtr.Zero;
+ var err = Interop.AttachPanel.CreateAttachPanel(conformant, out candidateAttachPanel);
CheckException(err);
Tizen.Log.Debug("AttachPanelSharp", "Success to create an AttachPanel Instance");
- isCreationSucceed = true;
- _attachPanel = candidateAttachPanel;
+ s_attachPanel = candidateAttachPanel;
- if (_eventEventHandler == null)
+ if (s_eventEventHandler == null)
{
StateEventListenStart();
}
- if (_resultEventHandler == null)
+ if (s_resultEventHandler == null)
{
ResultEventListenStart();
}
/// </summary>
/// <since_tizen> 4 </since_tizen>
/// <param name="conformant">The caller's conformant.</param>
+ /// <feature>http://tizen.org/feature/attach_panel</feature>
/// <exception cref="OutOfMemoryException">Thrown when an attempt to allocate the memory fails.</exception>
/// <exception cref="InvalidOperationException">Thrown when the AttachPanel already exists or the <paramref name="conformant"/> is not a conformant object.</exception>
- public AttachPanel(Conformant conformant)
+ /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
+ /// <exception cref="ArgumentNullException">Thrown when the parameter is null</exception>
+ public AttachPanel(Conformant conformant) : this(conformant as EvasObject)
{
- if (conformant == IntPtr.Zero)
- {
- throw new ArgumentNullException("Use the value property, not null value");
- }
-
- IntPtr candidateAttachPanel = new IntPtr();
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.CreateAttachPanel(conformant, ref candidateAttachPanel);
- CheckException(err);
-
- Tizen.Log.Debug("AttachPanelSharp", "Success to create an AttachPanel Instance");
- isCreationSucceed = true;
- _attachPanel = candidateAttachPanel;
-
- if (_eventEventHandler == null)
- {
- StateEventListenStart();
- }
-
- if (_resultEventHandler == null)
- {
- ResultEventListenStart();
- }
}
/// <summary>
/// </summary>
~AttachPanel()
{
- if (isCreationSucceed &&
- _attachPanel != IntPtr.Zero)
+ if (IsInitialized())
{
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.DestroyAttachPanel(_attachPanel);
- CheckException(err);
- _attachPanel = IntPtr.Zero;
+ Interop.AttachPanel.DestroyAttachPanel(s_attachPanel);
+ s_attachPanel = IntPtr.Zero;
}
}
/// </summary>
/// <value>The AttachPanel window state.</value>
/// <since_tizen> 4 </since_tizen>
+ /// <feature>http://tizen.org/feature/attach_panel</feature>
+ /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is not created yet or is already destroyed.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
+ /// <exception cref="ArgumentException">Thrown when the parameter is invalid</exception>
public StateType State
{
get
{
- int interopState;
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.GetState(_attachPanel, out interopState);
+ if (IsAttachPanelSupported() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+ }
+
+ if (IsInitialized() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+ }
+
+ var err = Interop.AttachPanel.GetState(s_attachPanel, out int interopState);
CheckException(err);
- StateType state = (StateType)Enum.ToObject(typeof(StateType), interopState);
- return state;
+
+ return (StateType)Enum.ToObject(typeof(StateType), interopState);
}
}
/// </summary>
/// <value>Visible value of the AttachPanel state.</value>
/// <since_tizen> 4 </since_tizen>
+ /// <feature>http://tizen.org/feature/attach_panel</feature>
+ /// <exception cref="InvalidOperationException">Thrown when the AttachPanel is not created yet or is already destroyed.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
public bool Visible
{
get
{
- int visible;
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.GetVisibility(_attachPanel, out visible);
+ if (IsAttachPanelSupported() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+ }
+
+ if (IsInitialized() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+ }
+
+ var err = Interop.AttachPanel.GetVisibility(s_attachPanel, out int visible);
CheckException(err);
- return (visible == 1);
+
+ return visible == 1;
}
}
/// <privilege>http://tizen.org/privilege/appmanager.launch</privilege>
/// <feature>http://tizen.org/feature/camera</feature>
/// <feature>http://tizen.org/feature/microphone</feature>
+ /// <feature>http://tizen.org/feature/attach_panel</feature>
/// <remarks>
/// The caller application has to check the return value of this function.
/// Content categories will be shown as the sequence of using AddCategory.
/// Some contents need time to load it all.
- /// So, it is needed to use this before the mainloop of the Show.
+ /// So, it is needed to use this before the main-loop of the Show.
/// Privileges,
/// http://tizen.org/privilege/mediastorage, for using Image or Camera.
/// http://tizen.org/privilege/camera, for using Camera or TakePicture.
/// http://tizen.org/privilege/appmanager.launch, for adding content categories on the More tab.
/// http://tizen.org/feature/camera, for using Camera or TakePicture.
/// http://tizen.org/feature/microphone, for using Voice.
+ /// http://tizen.org/feature/attach_panel, for using attach panel
/// Deliver more information to the callee with a bundle if you need.
/// http://tizen.org/appcontrol/data/total_count
/// http://tizen.org/appcontrol/data/total_size
/// <exception cref="UnauthorizedAccessException">Thrown when the application does not have the privilege to access this method.</exception>
/// <exception cref="NotSupportedException">Thrown when the device does not support the <paramref name="category"/> feature.</exception>
/// <exception cref="InvalidOperationException">Thrown when the AttachPanel is not created yet or is already destroyed.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
/// <since_tizen> 4 </since_tizen>
public void AddCategory(ContentCategory category, Bundle extraData)
{
- IntPtr bundle = IntPtr.Zero;
+ if (IsAttachPanelSupported() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+ }
+
+ if (IsInitialized() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+ }
+
+ var bundle = IntPtr.Zero;
if (extraData != null)
{
bundle = extraData.SafeBundleHandle.DangerousGetHandle();
}
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.AddCategory(_attachPanel, (int)category, bundle);
+ var err = Interop.AttachPanel.AddCategory(s_attachPanel, (int)category, bundle);
CheckException(err);
}
/// Removes the ContentCategory from the AttachPanel.
/// </summary>
/// <param name="category">The ContentCategory to be added in the AttachPanel.</param>
- /// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="category"/> is not a valid category.</exception>
+ /// <feature>http://tizen.org/feature/attach_panel</feature>
+ /// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="category"/> is not a valid category.</exception>
/// <exception cref="InvalidOperationException">Thrown when the AttachPanel is not created yet or is already destroyed.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
/// <since_tizen> 4 </since_tizen>
public void RemoveCategory(ContentCategory category)
{
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.RemoveCategory(_attachPanel, (int)category);
+ if (IsAttachPanelSupported() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+ }
+
+ if (IsInitialized() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+ }
+
+ var err = Interop.AttachPanel.RemoveCategory(s_attachPanel, (int)category);
CheckException(err);
}
/// </summary>
/// <param name="category">The ContentCategory that some information is to be set, in the AttachPanel.</param>
/// <param name="extraData">The AttachPanel sends some information using a Bundle.</param>
+ /// <feature>http://tizen.org/feature/attach_panel</feature>
/// <exception cref="ArgumentOutOfRangeException">Thrown when the <paramref name="category"/> is not a valid category.</exception>
/// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed.</exception>
/// <exception cref="OutOfMemoryException">Thrown when an attempt to allocate the memory fails.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
/// <since_tizen> 4 </since_tizen>
public void SetExtraData(ContentCategory category, Bundle extraData)
{
CheckException(Interop.AttachPanel.ErrorCode.InvalidParameter);
}
- IntPtr bundle = IntPtr.Zero;
+ if (IsAttachPanelSupported() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+ }
+
+ if (IsInitialized() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+ }
+
+ var bundle = IntPtr.Zero;
if (extraData != null)
{
bundle = extraData.SafeBundleHandle.DangerousGetHandle();
}
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.SetExtraData(_attachPanel, (int)category, bundle);
+ var err = Interop.AttachPanel.SetExtraData(s_attachPanel, (int)category, bundle);
CheckException(err);
}
/// <summary>
/// Shows the attach panel with the animations.
/// </summary>
+ /// <feature>http://tizen.org/feature/attach_panel</feature>
/// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
/// <since_tizen> 4 </since_tizen>
public void Show()
{
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Show(_attachPanel);
+ if (IsAttachPanelSupported() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+ }
+
+ if (IsInitialized() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+ }
+
+ var err = Interop.AttachPanel.Show(s_attachPanel);
CheckException(err);
}
/// Shows the attach panel and selects whether or not to animate.
/// </summary>
/// <param name="animation">A flag which turns on or turns off the animation while the attach panel is showing.</param>
+ /// <feature>http://tizen.org/feature/attach_panel</feature>
/// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
/// <since_tizen> 4 </since_tizen>
public void Show(bool animation)
{
+ if (IsAttachPanelSupported() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+ }
+
+ if (IsInitialized() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+ }
+
if (animation)
{
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Show(_attachPanel);
+ var err = Interop.AttachPanel.Show(s_attachPanel);
CheckException(err);
}
else
{
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.ShowWithoutAnimation(_attachPanel);
+ var err = Interop.AttachPanel.ShowWithoutAnimation(s_attachPanel);
CheckException(err);
}
}
/// <summary>
/// Hides the attach panel with the animations.
/// </summary>
+ /// <feature>http://tizen.org/feature/attach_panel</feature>
/// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
/// <since_tizen> 4 </since_tizen>
public void Hide()
{
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Hide(_attachPanel);
+ if (IsAttachPanelSupported() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+ }
+
+ if (IsInitialized() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+ }
+
+ var err = Interop.AttachPanel.Hide(s_attachPanel);
CheckException(err);
}
/// Hides the attach panel and selects whether or not to animate.
/// </summary>
/// <param name="animation">A flag which turns on or turns off the animation while the attach panel is hiding.</param>
+ /// <feature>http://tizen.org/feature/attach_panel</feature>
/// <exception cref="InvalidOperationException">Thrown when the AttachPanel is destroyed.</exception>
+ /// <exception cref="NotSupportedException">Thrown when the AttachPanel is not supported in the device.</exception>
/// <since_tizen> 4 </since_tizen>
public void Hide(bool animation)
{
+ if (IsAttachPanelSupported() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
+ }
+
+ if (IsInitialized() == false)
+ {
+ CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
+ }
+
if (animation)
{
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Hide(_attachPanel);
+ var err = Interop.AttachPanel.Hide(s_attachPanel);
CheckException(err);
}
else
{
- Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.HideWithoutAnimation(_attachPanel);
+ var err = Interop.AttachPanel.HideWithoutAnimation(s_attachPanel);
CheckException(err);
}
}
{
add
{
- if (_eventEventHandler == null)
+ if (s_eventEventHandler == null)
{
StateEventListenStart();
}
- _eventEventHandler += value;
+ s_eventEventHandler += value;
}
remove
{
- _eventEventHandler -= value;
- if (_eventEventHandler == null)
+ s_eventEventHandler -= value;
+ if (s_eventEventHandler == null)
{
StateEventListenStop();
}
{
add
{
- if (_resultEventHandler == null)
+ if (s_resultEventHandler == null)
{
ResultEventListenStart();
}
- _resultEventHandler += value;
+ s_resultEventHandler += value;
}
remove
{
- _resultEventHandler -= value;
- if (_resultEventHandler == null)
+ s_resultEventHandler -= value;
+ if (s_resultEventHandler == null)
{
ResultEventListenStop();
}
using System;
using System.Collections.Generic;
+using Tizen.System;
namespace Tizen.Applications.AttachPanel
{
/// <since_tizen> 4 </since_tizen>
public partial class AttachPanel
{
- private static IntPtr _attachPanel;
- private bool isCreationSucceed;
+ private static IntPtr s_attachPanel = IntPtr.Zero;
- private static event EventHandler<StateEventArgs> _eventEventHandler;
- private static event EventHandler<ResultEventArgs> _resultEventHandler;
+ private static event EventHandler<StateEventArgs> s_eventEventHandler;
- private static Interop.AttachPanel.AttachPanelEventCallback SetEventListener;
- private static Interop.AttachPanel.AttachPanelResultCallback SetResultListener;
+ private static event EventHandler<ResultEventArgs> s_resultEventHandler;
+
+ private static Interop.AttachPanel.AttachPanelEventCallback s_setEventListener;
+ private static Interop.AttachPanel.AttachPanelResultCallback s_setResultListener;
private void StateEventListenStart()
{
- Interop.AttachPanel.ErrorCode err = 0;
-
- SetEventListener = (attachPanel, eventType, eventInfo, userData) =>
+ s_setEventListener = (attachPanel, eventType, eventInfo, userData) =>
{
- _eventEventHandler?.Invoke(null, new StateEventArgs((EventType)eventType));
+ s_eventEventHandler?.Invoke(null, new StateEventArgs((EventType)eventType));
};
- err = Interop.AttachPanel.SetEventCb(_attachPanel, SetEventListener, IntPtr.Zero);
+ var err = Interop.AttachPanel.SetEventCb(s_attachPanel, s_setEventListener, IntPtr.Zero);
CheckException(err);
}
private void StateEventListenStop()
{
- Interop.AttachPanel.ErrorCode err = 0;
- err = Interop.AttachPanel.UnsetEventCb(_attachPanel);
+ var err = Interop.AttachPanel.UnsetEventCb(s_attachPanel);
CheckException(err);
}
private void ResultEventListenStart()
{
- Interop.AttachPanel.ErrorCode err = 0;
- SetResultListener = (attachPanel, category, resulthandler, resultCode, userData) =>
+ s_setResultListener = (attachPanel, category, resulthandler, resultCode, userData) =>
{
SafeAppControlHandle handle = new SafeAppControlHandle(resulthandler, false);
AppControl result = new AppControl(handle);
- _resultEventHandler?.Invoke(null, new ResultEventArgs((ContentCategory)category, result, (AppControlReplyResult)resultCode));
+ s_resultEventHandler?.Invoke(null, new ResultEventArgs((ContentCategory)category, result, (AppControlReplyResult)resultCode));
};
- err = Interop.AttachPanel.SetResultCb(_attachPanel, SetResultListener, IntPtr.Zero);
+ var err = Interop.AttachPanel.SetResultCb(s_attachPanel, s_setResultListener, IntPtr.Zero);
CheckException(err);
}
private void ResultEventListenStop()
{
- Interop.AttachPanel.ErrorCode err = 0;
- err = Interop.AttachPanel.UnsetResultCb(_attachPanel);
+ var err = Interop.AttachPanel.UnsetResultCb(s_attachPanel);
CheckException(err);
}
switch (err)
{
case Interop.AttachPanel.ErrorCode.InvalidParameter:
- throw new ArgumentOutOfRangeException("Invalid parameter error at unmanaged code");
+ throw new ArgumentOutOfRangeException("Invalid parameter");
case Interop.AttachPanel.ErrorCode.OutOfMemory:
throw new OutOfMemoryException("Out of Memory");
case Interop.AttachPanel.ErrorCode.PermissionDenied:
throw new UnauthorizedAccessException();
case Interop.AttachPanel.ErrorCode.AlreadyExists:
- throw new InvalidOperationException("Already Exists");
+ throw new InvalidOperationException("AttachPanel is already exists");
case Interop.AttachPanel.ErrorCode.NotInitialized:
- throw new InvalidOperationException("Not initialized");
+ throw new InvalidOperationException("AttachPanel is not initialized");
case Interop.AttachPanel.ErrorCode.UnsupportedContentCategory:
- throw new NotSupportedException("Unsupported Content Category");
+ throw new NotSupportedException("Unsupported content category");
case Interop.AttachPanel.ErrorCode.AlreadyDestroyed:
- throw new InvalidOperationException("Already Destroyed");
+ throw new InvalidOperationException("AttachPanel is already destroyed");
+ case Interop.AttachPanel.ErrorCode.NotSupported:
+ throw new NotSupportedException("AttachPanel is not supported in this device");
}
}
+
+ internal static bool IsAttachPanelSupported()
+ {
+ return Information.TryGetValue("http://tizen.org/feature/attach_panel", out bool isAttachPanelSupported) && isAttachPanelSupported;
+ }
+
+ internal static bool IsInitialized()
+ {
+ return s_attachPanel != IntPtr.Zero;
+ }
}
}