Exemple #1
0
        public static Task RegisterDropEventsAsync(this IFileReaderRef source, Action <DropEventsOptions> dropEventsModifier)
        {
            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (dropEventsModifier is null)
            {
                throw new ArgumentNullException(nameof(dropEventsModifier));
            }

            var options = new DropEventsOptions();

            dropEventsModifier(options);
            return(source.RegisterDropEventsAsync(options));
        }
Exemple #2
0
        /// <summary>
        /// Sets the specified <see cref="dropEffect"/> value on the dataTransfer property in the dragover event to the specified value.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="dropEffect"></param>
        /// <remarks>https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/dropEffect</remarks>
        /// <returns></returns>
        public static DropEventsOptions SetDragOverDataTransferDropEffect(this DropEventsOptions source, DropEffect dropEffect)
        {
            if (source is null)
            {
                throw new System.ArgumentNullException(nameof(source));
            }

            if (!dropeffectDomstringValues.TryGetValue(dropEffect, out var value))
            {
                throw new System.ArgumentException($"{dropEffect} is not a valid value for parameter {nameof(dropEffect)}", nameof(dropEffect));
            }

            source.OnDragOverScript = @$ "(dragEvent) => {{
                if (dragEvent.dataTransfer) {{
                    dragEvent.dataTransfer.dropEffect = " "{value}" ";
                }}
            }}";