Catel.LogAnalyzer.Behaviors.DropFileBehavior.UIElement_Drop C# (CSharp) Метод

UIElement_Drop() приватный статический Метод

private static UIElement_Drop ( object sender, System.Windows.DragEventArgs e ) : void
sender object
e System.Windows.DragEventArgs
Результат void
        private static void UIElement_Drop(object sender, DragEventArgs e)
        {
            var uiElement = sender as UIElement;

            // Sanity check just in case this was somehow send by something else
            if (uiElement == null)
            {
                return;
            }

            var dropFileCommand = GetCommand(uiElement);

            // There may not be a command bound to this after all
            if (dropFileCommand == null)
            {
                return;
            }

            if (!e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                return;
            }

            var droppedFilePaths =
                e.Data.GetData(DataFormats.FileDrop, true) as string[];

            if (droppedFilePaths == null)
            {
                return;
            }

            foreach (var droppedFilePath in droppedFilePaths)
            {
                // Check whether this attached behaviour is bound to a RoutedCommand
                if (dropFileCommand is RoutedCommand)
                {
                    // Execute the routed command
                    (dropFileCommand as RoutedCommand).Execute(droppedFilePath, uiElement);
                }
                else
                {
                    // Execute the Command as bound delegate
                    dropFileCommand.Execute(droppedFilePath);
                }
            }
        }
        #endregion