// Token: 0x0600385A RID: 14426 RVA: 0x000FC080 File Offset: 0x000FA280
        private static void OnQueryStatusPaste(object target, CanExecuteRoutedEventArgs args)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(target);

            if (textEditor == null || !textEditor._IsEnabled || textEditor.IsReadOnly)
            {
                return;
            }
            args.Handled = true;
            try
            {
                if (SecurityHelper.CallerHasAllClipboardPermission())
                {
                    string pasteApplyFormat = TextEditorCopyPaste.GetPasteApplyFormat(textEditor, Clipboard.GetDataObject());
                    args.CanExecute = (pasteApplyFormat.Length > 0);
                }
                else
                {
                    args.CanExecute = Clipboard.IsClipboardPopulated();
                }
            }
            catch (ExternalException)
            {
                args.CanExecute = false;
            }
        }
Exemple #2
0
        // Token: 0x0600386A RID: 14442 RVA: 0x000FC8DC File Offset: 0x000FAADC
        internal static void OnDragEnter(object sender, DragEventArgs e)
        {
            e.Handled = true;
            TextEditor textEditor = TextEditor._GetTextEditor(sender);

            if (textEditor == null)
            {
                e.Effects = DragDropEffects.None;
                return;
            }
            if (!textEditor._IsEnabled || textEditor.TextView == null || textEditor.TextView.RenderScope == null)
            {
                e.Effects = DragDropEffects.None;
                return;
            }
            if (e.Data == null)
            {
                e.Effects = DragDropEffects.None;
                return;
            }
            if (TextEditorCopyPaste.GetPasteApplyFormat(textEditor, e.Data) == string.Empty)
            {
                e.Effects = DragDropEffects.None;
                return;
            }
            TextEditorTyping._FlushPendingInputItems(textEditor);
            if (!textEditor.TextView.Validate(e.GetPosition(textEditor.TextView.RenderScope)))
            {
                e.Effects = DragDropEffects.None;
                return;
            }
            textEditor._dragDropProcess.TargetOnDragEnter(e);
        }
        internal static bool _DoPaste(TextEditor This, IDataObject dataObject, bool isDragDrop)
        {
            if (!SecurityHelper.CallerHasAllClipboardPermission())
            {
                return(false);
            }
            Invariant.Assert(dataObject != null);
            bool   result        = false;
            string formatToApply = TextEditorCopyPaste.GetPasteApplyFormat(This, dataObject);
            DataObjectPastingEventArgs dataObjectPastingEventArgs;

            try
            {
                dataObjectPastingEventArgs = new DataObjectPastingEventArgs(dataObject, isDragDrop, formatToApply);
            }
            catch (ArgumentException)
            {
                return(result);
            }
            This.UiScope.RaiseEvent(dataObjectPastingEventArgs);
            if (!dataObjectPastingEventArgs.CommandCancelled)
            {
                IDataObject dataObject2 = dataObjectPastingEventArgs.DataObject;
                formatToApply = dataObjectPastingEventArgs.FormatToApply;
                result        = TextEditorCopyPaste.PasteContentData(This, dataObject, dataObject2, formatToApply);
            }
            return(result);
        }
        /// <summary>
        /// An event reporting that the drag enter during drag-and-drop operation.
        /// </summary>
        internal static void OnDragEnter(object sender, DragEventArgs e)
        {
            // Consider event handled
            e.Handled = true;

            TextEditor This = TextEditor._GetTextEditor(sender);

            if (This == null)
            {
                e.Effects = DragDropEffects.None;
                return;
            }

            // Ignore the event if the editor has been detached from its scope
            if (!This._IsEnabled || This.TextView == null || This.TextView.RenderScope == null)
            {
                e.Effects = DragDropEffects.None;
                return;
            }

            // If there's no supported data available, don't allow the drag-and-drop.
            if (e.Data == null)
            {
                e.Effects = DragDropEffects.None;
                return;
            }

            // Ignore the event if there isn't the dropable(pasteable) data format
            if (TextEditorCopyPaste.GetPasteApplyFormat(This, e.Data) == string.Empty)
            {
                e.Effects = DragDropEffects.None;
                return;
            }

            TextEditorTyping._FlushPendingInputItems(This);

            if (!This.TextView.Validate(e.GetPosition(This.TextView.RenderScope)))
            {
                e.Effects = DragDropEffects.None;
                return;
            }

            This._dragDropProcess.TargetOnDragEnter(e);
        }