using ElmSharp;
using System;
namespace Tizen.Applications.AttachPanel
{
///
/// Represents the immutable class for the attach panel.
///
public partial class AttachPanel
{
///
/// Represents the immutable class for the attach panel.
///
/// 4
/// The caller's conformant.
/// http://tizen.org/feature/attach_panel
/// Thrown when the parameter is null
/// Thrown when an attempt to allocate the memory fails.
/// Thrown when the AttachPanel already exists or the is not a conformant object.
/// Thrown when the AttachPanel is not supported in the device.
public AttachPanel(EvasObject conformant)
{
if (conformant == IntPtr.Zero)
{
throw new ArgumentNullException("Invalid conformant, it's null");
}
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");
s_attachPanel = candidateAttachPanel;
if (s_eventEventHandler == null)
{
StateEventListenStart();
}
if (s_resultEventHandler == null)
{
ResultEventListenStart();
}
}
///
/// Represents the immutable class for the attach panel.
///
/// 4
/// The caller's conformant.
/// http://tizen.org/feature/attach_panel
/// Thrown when an attempt to allocate the memory fails.
/// Thrown when the AttachPanel already exists or the is not a conformant object.
/// Thrown when the AttachPanel is not supported in the device.
/// Thrown when the parameter is null
public AttachPanel(Conformant conformant) : this(conformant as EvasObject)
{
}
///
/// A destructor which deallocates the attach panel resources.
///
~AttachPanel()
{
if (IsInitialized())
{
Interop.AttachPanel.DestroyAttachPanel(s_attachPanel);
s_attachPanel = IntPtr.Zero;
}
}
///
/// Gets the state of the AttachPanel.
///
/// The AttachPanel window state.
/// 4
/// http://tizen.org/feature/attach_panel
/// Thrown when the AttachPanel is not created yet or is already destroyed.
/// Thrown when the AttachPanel is not supported in the device.
/// Thrown when the parameter is invalid
public StateType State
{
get
{
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);
return (StateType)Enum.ToObject(typeof(StateType), interopState);
}
}
///
/// Gets the value that indicates whether the AttachPanel is visible.
///
/// Visible value of the AttachPanel state.
/// 4
/// http://tizen.org/feature/attach_panel
/// Thrown when the AttachPanel is not created yet or is already destroyed.
/// Thrown when the AttachPanel is not supported in the device.
public bool Visible
{
get
{
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;
}
}
///
/// Adds a content category in the AttachPanel.
///
/// The ContentCategory to be added in the AttachPanel.
/// The AttachPanel sends some information using the Bundle.
/// http://tizen.org/privilege/mediastorage
/// http://tizen.org/privilege/camera
/// http://tizen.org/privilege/recorder
/// http://tizen.org/privilege/appmanager.launch
/// http://tizen.org/feature/camera
/// http://tizen.org/feature/microphone
/// http://tizen.org/feature/attach_panel
///
/// 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 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/recorder, for using Voice.
/// 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
///
/// Thrown when the is not a valid category.
/// Thrown when the application does not have the privilege to access this method.
/// Thrown when the device does not support the feature.
/// Thrown when the AttachPanel is not created yet or is already destroyed.
/// Thrown when the AttachPanel is not supported in the device.
/// 4
public void AddCategory(ContentCategory category, Bundle extraData)
{
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();
}
var err = Interop.AttachPanel.AddCategory(s_attachPanel, (int)category, bundle);
CheckException(err);
}
///
/// Removes the ContentCategory from the AttachPanel.
///
/// The ContentCategory to be added in the AttachPanel.
/// http://tizen.org/feature/attach_panel
/// Thrown when the is not a valid category.
/// Thrown when the AttachPanel is not created yet or is already destroyed.
/// Thrown when the AttachPanel is not supported in the device.
/// 4
public void RemoveCategory(ContentCategory 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);
}
///
/// Sets the extraData to be sent to the ContentCategory using a Bundle.
///
/// The ContentCategory that some information is to be set, in the AttachPanel.
/// The AttachPanel sends some information using a Bundle.
/// http://tizen.org/feature/attach_panel
/// Thrown when the is not a valid category.
/// Thrown when the AttachPanel is destroyed.
/// Thrown when an attempt to allocate the memory fails.
/// Thrown when the AttachPanel is not supported in the device.
/// 4
public void SetExtraData(ContentCategory category, Bundle extraData)
{
if (extraData == null)
{
CheckException(Interop.AttachPanel.ErrorCode.InvalidParameter);
}
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();
}
var err = Interop.AttachPanel.SetExtraData(s_attachPanel, (int)category, bundle);
CheckException(err);
}
///
/// Shows the attach panel with the animations.
///
/// http://tizen.org/feature/attach_panel
/// Thrown when the AttachPanel is destroyed.
/// Thrown when the AttachPanel is not supported in the device.
/// 4
public void Show()
{
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.
///
/// A flag which turns on or turns off the animation while the attach panel is showing.
/// http://tizen.org/feature/attach_panel
/// Thrown when the AttachPanel is destroyed.
/// Thrown when the AttachPanel is not supported in the device.
/// 4
public void Show(bool animation)
{
if (IsAttachPanelSupported() == false)
{
CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
}
if (IsInitialized() == false)
{
CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
}
if (animation)
{
var err = Interop.AttachPanel.Show(s_attachPanel);
CheckException(err);
}
else
{
var err = Interop.AttachPanel.ShowWithoutAnimation(s_attachPanel);
CheckException(err);
}
}
///
/// Hides the attach panel with the animations.
///
/// http://tizen.org/feature/attach_panel
/// Thrown when the AttachPanel is destroyed.
/// Thrown when the AttachPanel is not supported in the device.
/// 4
public void Hide()
{
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.
///
/// A flag which turns on or turns off the animation while the attach panel is hiding.
/// http://tizen.org/feature/attach_panel
/// Thrown when the AttachPanel is destroyed.
/// Thrown when the AttachPanel is not supported in the device.
/// 4
public void Hide(bool animation)
{
if (IsAttachPanelSupported() == false)
{
CheckException(Interop.AttachPanel.ErrorCode.NotSupported);
}
if (IsInitialized() == false)
{
CheckException(Interop.AttachPanel.ErrorCode.NotInitialized);
}
if (animation)
{
var err = Interop.AttachPanel.Hide(s_attachPanel);
CheckException(err);
}
else
{
var err = Interop.AttachPanel.HideWithoutAnimation(s_attachPanel);
CheckException(err);
}
}
///
/// Occurs when the reserved events are published from the panel-side.
///
/// 4
public event EventHandler EventChanged
{
add
{
if (s_eventEventHandler == null)
{
StateEventListenStart();
}
s_eventEventHandler += value;
}
remove
{
s_eventEventHandler -= value;
if (s_eventEventHandler == null)
{
StateEventListenStop();
}
}
}
///
/// Occurs when a user selects and confirms something to attach in the AttachPanel.
///
/// 4
public event EventHandler ResultCallback
{
add
{
if (s_resultEventHandler == null)
{
ResultEventListenStart();
}
s_resultEventHandler += value;
}
remove
{
s_resultEventHandler -= value;
if (s_resultEventHandler == null)
{
ResultEventListenStop();
}
}
}
}
}