Comments (8)
@rzhw Meh, who cares about Windows Phone. What I'm on the fence about is, should the clipboard be at the ViewModel layer (i.e. Splat is a library primarily for writing platform-independent ViewModel code). I could be swayed either way. Thoughts?
from splat.
Good point. My need for clipboard support isn’t too big, so thoughts:
- Idea of vm is to be layer between view + model(s); clipboard could be thought of another model, so it shouldn't be part of helper code for vms
- But there already is image loading/saving. Could also argue images on FS/bundle are also a model. So clipboard is another model that can be supported
- Problem of common interface; Cocoa has multiple pasteboards, WinRT + WPF have different clipboard APIs, there's different data formats that need support, WinPho can't be supported. Needing feature checking = :(
- But images already has a common interface. For clipboard baseline of get+set text, img,
richtext, binary should be fine. Throw exceptions instead of requiring feature checks?
from splat.
How about something like:
public enum ClipboardContentType {
Text,
Html,
Url,
Image,
Binary,
}
public interface IClipboard
{
ClipboardContentType? ContentType { get; } // returns null if clipboard empty
Task<byte[]> Get();
Task Set(byte[] data, ClipboardContentType = Binary);
};
On top of Get and Set, you could make extension methods for strings, images, etc etc.
from splat.
Hm, base of just byte[]/Stream might not be possible, looking through docs for the WPF Clipboard class it looks like it's only possible to get data in predefined formats, seems to be same for WinRT (GetContent/DataPackageView)
from splat.
From some quick reading, looks possible for Cocoa
From the selection, identify or obtain the object or the binary data corresponding to the object.
Binary data must be encapsulated in an NSData object. If you’re going to write another type of object to the pasteboard, it must be a property-list object—that is, an object of one of the following classes: NSString, NSArray, NSDictionary, NSDate, NSNumber, or NSURL. (For more on property-list objects, see Property List Programming Guide.)
and Android
Quickview
A clipboard-based framework for copying and pasting data.
Supports both simple and complex data, including text strings, complex data structures, text and binary stream data, and application assets.
from splat.
Hm, base of just byte[]/Stream might not be possible, looking through docs for the WPF Clipboard class it looks like it's only possible to get data in predefined formats
You should be able to roll through all of the possible binary formats via "ContainsFormat" and see if any of them can be represented as binary (most of them can be).
from splat.
If not, I'd extend it to either text or binary
from splat.
I think coming back to this, it might be better suited to a separate library since doing all the abstraction looks like quite a big task, or at least until something usable comes out.
from splat.
Related Issues (20)
- [BUG] Splat.Microsoft.Extensions.DependencyInjection causes System.InvalidOperationException: Call from invalid thread HOT 16
- [Bug]: Router randomly stops showing views on navigation HOT 9
- WPF, .net 8.0 and Splat latest version: IBitmap.ToNative, FromNative, SplatColor.ToNativeBrush and SplatColor.FromNativeColor not found by compiler. HOT 3
- Change the DI Microsoft to use KeyedServiceProvider insted of ContractDictionary HOT 1
- Dependency Dashboard
- Action Required: Fix Renovate Configuration HOT 1
- Housekeeping: Change MS MicrosoftDependencyResolver to require IKeyedServiceProvider in ctor HOT 2
- [BUG] Splat.Microsoft.Extensions.DependencyInjection never disposes the service locator HOT 1
- [BUG] Project targeting net5.0 won't build with Splat.Drawing installed HOT 3
- PlatformModeDetector.InDesignMode() not working in WPF designer for nested UserControls
- Drop net 5 support HOT 2
- How to Use Splat.DI.SourceGenerator HOT 7
- Update Splat.Autofac README HOT 2
- [BUG] DryIoc resolves Views upon registration HOT 8
- [BUG] Getting dependency from DryIoC container creates dependency object twice HOT 8
- [BUG] RegisterPlatformBitmapLoader doesnt register with framework net6.0-windows HOT 1
- [BUG] Registered Func cant be resolved
- [BUG] System.MissingFieldException HOT 3
- Default Test and Run mode HOT 8
- Optimise DefaultPlatformModeDetector on csproj sdk platforms
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from splat.