示例#1
0
        /// <summary>
        /// Requests edit to editor application.
        /// </summary>
        /// <privilege>http://tizen.org/privilege/datasharing</privilege>
        /// <exception cref="InvalidOperationException">Thrown when the method failed due to invalid operation.</exception>
        /// <exception cref="NotSupportedException">Thrown when the watchface complication is not supported.</exception>
        /// <exception cref="UnauthorizedAccessException">Thrown when the application does not have privilege to access this method.</exception>
        /// <example>
        /// <code>
        /// public class MyContainer : EditablesContainer {
        ///     public MyContainer() : base()
        ///     {
        ///     }
        ///     protected override void OnEditReady(string editorId)
        ///     {
        ///         this.RequestEdit();
        ///     }
        /// }
        /// </code>
        /// </example>
        /// <since_tizen> 6 </since_tizen>
        public void RequestEdit()
        {
            Log.Debug(_logTag, "request edit");
            ComplicationError ret;

            Interop.WatchfaceComplication.GetEditableContainer(out _container);
            if (_container == IntPtr.Zero)
            {
                ErrorFactory.ThrowException(ComplicationError.EditNotReady, "Editor not ready");
            }

            if (_editableUpdatedCallback == null)
            {
                _editableUpdatedCallback = new Interop.WatchfaceComplication.EditableUpdateRequestedCallback(EditableUpdatedCallback);
            }

            foreach (Complication comp in _compList)
            {
                IEditable e  = comp;
                IntPtr    hi = IntPtr.Zero;
                if (e.Highlight != null && e.Highlight.Raw != IntPtr.Zero)
                {
                    hi = e.Highlight.Raw;
                }
                Interop.WatchfaceComplication.AddComplication(_container, e.EditableId, comp._handle, hi);
            }

            foreach (DesignElement de in _deList)
            {
                IEditable e = de;
                IntPtr    candidates;
                Interop.WatchfaceComplication.CreateCandidatesList(out candidates);
                foreach (Bundle b in de.Candidates)
                {
                    Interop.WatchfaceComplication.AddCandidatesListItem(candidates, b.SafeBundleHandle);
                }

                IntPtr hi = IntPtr.Zero;
                if (e.Highlight != null && e.Highlight.Raw != IntPtr.Zero)
                {
                    hi = e.Highlight.Raw;
                }
                Interop.WatchfaceComplication.AddDesignElement(_container, e.EditableId, e.GetCurrentDataIndex(), candidates, hi, e.Name);
                Log.Debug(_logTag, "Add design element done :" + e.Name);
            }

            ret = Interop.WatchfaceComplication.RequestEdit(_container, _editableUpdatedCallback, IntPtr.Zero);
            if (ret != ComplicationError.None)
            {
                ErrorFactory.ThrowException(ret, "Request edit fail");
            }
        }