Ejemplo n.º 1
0
        public ICollection <AnnoObject> Paste()
        {
            var files = _clipboard.GetFileDropList();

            if (files?.Count == 1)
            {
                try
                {
                    return(_layoutLoader.LoadLayout(files[0], forceLoad: true).Objects);
                }
                catch (JsonReaderException) { }
            }

            if (_clipboard.ContainsData(CoreConstants.AnnoDesignerClipboardFormat))
            {
                try
                {
                    var stream = _clipboard.GetData(CoreConstants.AnnoDesignerClipboardFormat) as Stream;
                    if (stream is not null)
                    {
                        return(_layoutLoader.LoadLayout(stream, forceLoad: true).Objects);
                    }
                }
                catch (JsonReaderException) { }
            }

            if (_clipboard.ContainsText())
            {
                using var memoryStream = new MemoryStream();
                using var streamWriter = new StreamWriter(memoryStream);
                streamWriter.Write(_clipboard.GetText());
                streamWriter.Flush();
                memoryStream.Seek(0, SeekOrigin.Begin);
                try
                {
                    return(_layoutLoader.LoadLayout(memoryStream, forceLoad: true).Objects);
                }
                catch (JsonReaderException) { }
            }

            return(Array.Empty <AnnoObject>());
        }