示例#1
0
        private bool Validate(ProjectEditor editor, object sender, DragEventArgs e, bool bExecute)
        {
            var point = DropHelper.GetPosition(sender, e);

            if (e.Data.Contains(DataFormats.Text))
            {
                var text = e.Data.GetText();

                if (bExecute)
                {
                    editor?.OnTryPaste(text);
                }

                return(true);
            }

            foreach (var format in e.Data.GetDataFormats())
            {
                var data = e.Data.Get(format);

                switch (data)
                {
                case BaseShape shape:
                    return(editor?.OnDropShape(shape, point.X, point.Y, bExecute) == true);

                case Record record:
                    return(editor?.OnDropRecord(record, point.X, point.Y, bExecute) == true);

                case ShapeStyle style:
                    return(editor?.OnDropStyle(style, point.X, point.Y, bExecute) == true);

                case PageContainer page:
                    return(editor?.OnDropTemplate(page, point.X, point.Y, bExecute) == true);

                default:
                    break;
                }
            }

            if (e.Data.Contains(DataFormats.FileNames))
            {
                var files = e.Data.GetFileNames().ToArray();
                if (bExecute)
                {
                    editor?.OnDropFiles(files);
                }
                return(true);
            }

            return(false);
        }