Git Product home page Git Product logo

q42.winrt's Introduction

Q42.WinRT

Open source library for Windows Phone and Windows 8 C#/XAML applications. This library was originally developed for Windows 8, but most functionality is also compatible with Windows Phone. The library is focused on web connected and data driven applications. It includes helpers to easily cache data from API calls and cache web images to the local storage.

This library helps to maximize code reuse between Windows 8 and Windows Phone 8

Please checkout the included sample application for Windows 8 and Windows Phone.

Or download directly from NuGet:

Looking for the old version compatible with Windows 8.0? Last 8.0 commit / NuGet package 1.0.14.42

What's included?

With this library comes a fully functional sample application that shows off most of the functionality. There's also a unit test project included.

Data Windows 8 Windows Phone
DataLoader x x
DataCache x x
WebDataCache x x
StorageHelper x x
SettingsHelper x x
ImageExtensions.CacheUri x x
Converters Windows 8 Windows Phone
VisibilityConverter x x
InverseVisibilityConverter x x
ByteToStringConverter x x
StringFormatConverter x
TextToLowerConverter x
Helpers Windows 8 Windows Phone
Util.GetAppVersion x
Util.GetOsVersion x
Util.GetMachineName x
Controls Windows 8 Windows Phone
WrapPanel x
Background Parallax x
UserControl Flyout x

Data

  • DataLoader - Input a task, enables easy binding to Loading / Finished / Error properties (show progress bar as long as task is running)
  • DataCache - Input a Cache Key and API call. Will run the task to get the response (for example a web call with json result) and write it to the cache. On next call, will return response directly from cache. Can be used in combination with DataLoader.
  • DataLoader.LoadCacheThenRefreshAsync - Input two methods which get data from cache and web. Callback will fire twice. You can bind to the dataloader to show a progress bar.
  • WebDataCache - Input an URI. Will get the data from the web and write raw bytes to local storage. On next call, it will return the cached data from the local storage.
  • StorageHelper - Save and retreive objects to the local storage. Json or XML serialization is used.
  • SettingsHelper - Save and retreive settings (wrapper around the different settings api's on Windows 8 or Windows Phone)
  • ImageExtensions.CacheUri - Alternative to Source property for images. Will get image from web and cache it. On a next run, will return cached image.

Converters

  • VisibilityConverter - Convert anything to visibility, works with bools, ints, strings, objects etc
  • InverseVisibilityConverter - Inverse of the VisibilityConverter
  • ByteToStringConverter - Converts bytes to a nice string, like 5.14 MB
  • StringFormatConverter - String format helper
  • TextToLowerConverter - Converts all text to lower text

Helpers

  • Util.GetAppVersion - Gets the application version as formatted string (1.0.0.0)
  • Util.GetOsVersion - Gets the version of the OS (for now: Windows NT 6.2, can change in the future)
  • Util.GetMachineName - Returns the machine name

Controls

  • WrapPanel - WrapPanel ported from Silverlight. Allows variable sized controls and wraps to a new line when needed.
  • Background Parallax - Creates a background parallax effect like on the Windows 8 start screen
  • UserControl Flyout - Flyout that hosts a UserControl with custom data. Can be used to create a Settings Flyout and have full control over the layout

How To Install?

Download the source including the sample code from GitHub or install from NuGet:

How To Use?

Check out the included sample app and unit tests for Windows 8 and Windows Phone.

DataLoader introduction

Let's say you have a long running async operation which gets some data from the web.

var result = await LoadWebData();

You want to show a nice progress bar when you're busy loading the data. Use the DataLoader for that, it wraps around your existing code. Place this code in your ViewModel:

//public property you can bind to
public DataLoader DL { get; set; }

//Place this in the constructor of your ViewModel:
DL = new DataLoader();

//Somewhere where you want to start loading data
var result = await DL.LoadAsync(() => LoadWebData());

You can now bind your ProgressBar to the DataLoader's IsBusy property in your XAML:

<ProgressBar IsIndeterminate="{Binding DL.IsBusy}"></ProgressBar>

For more advanced scenarios, see the included sample apps and unit tests.

DataCache introduction

Let's say you want to cache the result when you grab some data from an external source

List<MyData> result = await DataCache.GetAsync("your_key", () => LoadWebData());

The next time you do the same call, you get the cached result. You can combine this with the DataLoader to show a ProgressBar:

List<MyData> result = await DL.LoadAsync(() => DataCache.GetAsync("your_key", () => LoadWebData()));

For more advanced scenarios, see the included sample apps and unit tests.

License

Q42.WinRT is licensed under MIT. Refer to license.txt for more information.

Contributions

Contributions are welcome. Fork this repository and send a pull request if you have something useful to add.

Credits

Open Source Project Credits

Some code is used from other open source projects.

Related Projects

Other useful WinRT / Windows 8 projects.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.