Give some usage examples
This commit is contained in:
Родитель
36541c1eea
Коммит
dae033d06b
44
README.md
44
README.md
|
@ -23,6 +23,50 @@ Splat currently supports:
|
|||
additional extension methods to make using them easier.
|
||||
* A way to detect whether you're in a Unit Test runner / Design Mode
|
||||
|
||||
### Cross-platform Image Loading
|
||||
|
||||
```cs
|
||||
//
|
||||
// Load an Image
|
||||
// This code even works in a Portable Library
|
||||
//
|
||||
|
||||
var wc = new WebClient();
|
||||
var imageBytes = await wc.DownloadDataTaskAsync("http://octodex.github.com/images/Professortocat_v2.png");
|
||||
ProfileImage = await BitmapLoader.Current.Load(imageBytes, null /* Use original width */, null /* Use original height */);
|
||||
|
||||
```
|
||||
|
||||
Then later, in your View:
|
||||
|
||||
```
|
||||
ImageView.Source = ViewModel.ProfileImage.ToNative();
|
||||
```
|
||||
|
||||
### Using Cross-Platform Colors and Geometry
|
||||
|
||||
```cs
|
||||
// This System.Drawing class works, even on WinRT or WP8 where it's not supposed to exist
|
||||
// Also, this works in a Portable Library, in your ViewModel
|
||||
ProfileBackgroundAccentColor = new Color(255, 255, 255, 255);
|
||||
```
|
||||
|
||||
Later, in the view, we can use it:
|
||||
|
||||
```
|
||||
ImageView.Background = ViewModel.ProfileBackgroundAccentColor.ToNativeBrush();
|
||||
```
|
||||
|
||||
### Detecting whether you're in a unit test runner
|
||||
|
||||
```cs
|
||||
// If true, we are running unit tests
|
||||
ModeDetector.InUnitTestRunner();
|
||||
|
||||
// If true, we are running inside Blend, so don't do anything
|
||||
ModeDetector.InDesignMode();
|
||||
```
|
||||
|
||||
### How do I install?
|
||||
|
||||
[Always Be NuGetting](https://nuget.org/packages/Splat/). Package contains binaries for:
|
||||
|
|
Загрузка…
Ссылка в новой задаче