Skip to content

Commit

Permalink
Give some usage examples
Browse files Browse the repository at this point in the history
  • Loading branch information
anaisbetts committed Sep 27, 2013
1 parent 36541c1 commit dae033d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit dae033d

Please sign in to comment.