using ElmSharp; using System; namespace Tizen.Applications.AttachPanel { /// /// Represents immutable class for attach panel. /// public partial class AttachPanel { /// /// Represents immutable class for attach panel. /// /// 4 /// The caller's conformant /// Thrown when an attempt to allocate memory fails. /// Thrown when the AttachPanel is already exist or the is not a conformant object public AttachPanel(EvasObject conformant) { 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(); } } /// /// Represents immutable class for attach panel. /// /// 4 /// The caller's conformant /// Thrown when an attempt to allocate memory fails. /// Thrown when the AttachPanel is already exist or the is not a conformant object public AttachPanel(Conformant conformant) { 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(); } } /// /// A destructor which deallocates attach panel resources. /// ~AttachPanel() { if (isCreationSucceed && _attachPanel != IntPtr.Zero) { Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.DestroyAttachPanel(_attachPanel); CheckException(err); _attachPanel = IntPtr.Zero; } } /// /// Gets the state of the AttachPanel. /// /// The AttachPanel window state /// 4 public StateType State { get { int interopState; Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.GetState(_attachPanel, out interopState); CheckException(err); StateType state = (StateType)Enum.ToObject(typeof(StateType), interopState); return state; } } /// /// Gets the value that indicates whether the AttachPanel is visible. /// /// visible value of AttachPanel state /// 4 public bool Visible { get { int visible; Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.GetVisibility(_attachPanel, out visible); CheckException(err); return (visible == 1); } } /// /// Add a content category in the AttachPanel. /// /// The ContentCategory to be added in the AttachPanel /// The AttachPanel send some information using 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 /// /// The caller app 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 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 /// 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 application does not have privilege to access this method /// Thrown when the device does not supported the feature /// Thrown when the AttachPanel is not created yet or already destroyed /// 4 public void AddCategory(ContentCategory category, Bundle extraData) { IntPtr bundle = IntPtr.Zero; if (extraData != null) { bundle = extraData.SafeBundleHandle.DangerousGetHandle(); } Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.AddCategory(_attachPanel, (int)category, bundle); CheckException(err); } /// /// Removes the ContentCategory from the AttachPanel /// /// The ContentCategory adding in the AttachPanel /// Thrown when the is not a valid category /// Thrown when the AttachPanel is not created yet or already destroyed /// 4 public void RemoveCategory(ContentCategory category) { Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.RemoveCategory(_attachPanel, (int)category); CheckException(err); } /// /// Sets extraData to send to the ContentCategory using a Bundle /// /// The ContentCategory that some information to be set in the AttachPanel. /// The AttachPanel send some information using Bundle /// Thrown when the is not a valid category /// Thrown when the AttachPanel is destroyed /// Thrown when an attempt to allocate memory fails. /// 4 public void SetExtraData(ContentCategory category, Bundle extraData) { if (extraData == null) { CheckException(Interop.AttachPanel.ErrorCode.InvalidParameter); } IntPtr bundle = IntPtr.Zero; if (extraData != null) { bundle = extraData.SafeBundleHandle.DangerousGetHandle(); } Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.SetExtraData(_attachPanel, (int)category, bundle); CheckException(err); } /// /// Shows the attach panel with animations /// /// Thrown when the AttachPanel is destroyed /// 4 public void Show() { Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Show(_attachPanel); CheckException(err); } /// /// Shows the attach panel and selects whether or not to animate /// /// A flag which turn on or turn off the animation while attach panel showing. /// Thrown when the AttachPanel is destroyed /// 4 public void Show(bool animation) { if (animation) { Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Show(_attachPanel); CheckException(err); } else { Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.ShowWithoutAnimation(_attachPanel); CheckException(err); } } /// /// Hides the attach panel with animations /// /// Thrown when the AttachPanel is destroyed /// 4 public void Hide() { Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Hide(_attachPanel); CheckException(err); } /// /// Hides the attach panel and selects whether or not to animate /// /// A flag which turn on or turn off the animation while attach panel hiding. /// Thrown when the AttachPanel is destroyed /// 4 public void Hide(bool animation) { if (animation) { Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.Hide(_attachPanel); CheckException(err); } else { Interop.AttachPanel.ErrorCode err = Interop.AttachPanel.HideWithoutAnimation(_attachPanel); CheckException(err); } } /// /// Occurs when reserved events are published from the panel-side. /// /// 4 public event EventHandler EventChanged { add { if (_eventEventHandler == null) { StateEventListenStart(); } _eventEventHandler += value; } remove { _eventEventHandler -= value; if (_eventEventHandler == null) { StateEventListenStop(); } } } /// /// Occurs when an user selects and confirms something to attach in the AttachPanel /// /// 4 public event EventHandler ResultCallback { add { if (_resultEventHandler == null) { ResultEventListenStart(); } _resultEventHandler += value; } remove { _resultEventHandler -= value; if (_resultEventHandler == null) { ResultEventListenStop(); } } } } }