public override ClipboardImplementationViewModel Create(ClipboardImplementation implementation, ClipboardObjectViewModel clipboardObject) { if (implementation is TextClipboardImplementation textImplementation) { if (implementation.Parent is null) { return(new TextClipboardImplementationViewModel(textImplementation, clipboardObject)); } else { return(new LinkedTextClipboardImplementationViewModel(textImplementation, clipboardObject)); } } else if (implementation is PathsImplementation pathsImplementation) { if (pathsImplementation.Paths.Count == 1) { return(new SinglePathViewModel(pathsImplementation, clipboardObject)); } else { return(new MultiPathsViewModel(pathsImplementation, clipboardObject)); } } else if (implementation is BitmapImplementation bitmapImplementation) { return(new BitmapImplementationViewModel(bitmapImplementation, clipboardObject)); } return(null); }
public ClipboardImplementationViewModel?CreateViewModel(ClipboardImplementation implementation, ClipboardObjectViewModel clipboardObject) { var returner = _viewModelFactoriesManager.OfType <ClipboardImplementationViewModelFactory>().Select(f => f.Create(implementation, clipboardObject)).FirstOrDefault(i => !(i is null)); if (!(returner is null)) { _interactablesManager.AssignStates(returner); } return(returner); }
public async IAsyncEnumerable <ClipboardImplementation> CreateLinkedImplementationsAsync(DataObject dataObject, ClipboardImplementation implementation) { foreach (var factory in _implementationFactories) { var result = await factory.CreateLinkedFromDataObject(implementation, dataObject).ConfigureAwait(false); if (!(result is null)) { yield return(result); } } }
public PathsImplementation(ClipboardFormat format, ClipboardImplementationFactory factory, ClipboardImplementation parent, params string[] paths) : base(format, factory, parent) { Paths = new ReadOnlyCollection <string>(paths); }
public BitmapImplementation(ClipboardFormat format, ClipboardImplementationFactory factory, ClipboardImplementation parent, BitmapSource bitmap) : base(format, factory, parent) { fileName = DiContainer.SP.GetService <ITempManager>().GetNewFileName("bmp"); Size = new IntSize(bitmap.PixelWidth, bitmap.PixelHeight); bitmap.Save(fileName, new BmpBitmapEncoder()); }
public TextClipboardImplementation(ClipboardFormat format, ClipboardImplementationFactory factory, ClipboardImplementation parent, string source) : base(format, factory, parent) { Source = source; LinkedContent = null; }