A library that makes developing for WinRT easy (well, easier).
The code is being currently used in WriteRT, a creative writing Windows Store app.
Get it from NuGet:
PM> Install-Package Easy
Abstract base class for auto-save functionality, wraps a timer that
periodically performs a save based on the given ISaveProvider
(below).
Specialization of AutoSave<T>
for an ISaveProvider<string>
, enables
auto-save functionality.
// Initialize an auto-save every 10 seconds
var autoSave = new AutoSaveString(provider, TimeSpan.FromSeconds(10));
// Starts atuo-saving every 10 seconds
autoSave.Start();
...
// Stops auto-saving
autoSave.Stop();
Specialization of AutoSave<T>
for an ISaveProvider<bytes[]>
, similar
to the AutoSaveString
above.
Can create unique temporary files and perform transactional file saves.
// Temporary file with guaranteed unique name
IStorageFile temp = await File.CreateTemporaryFileAsync();
// Transactional file save
await File.SaveAsync(temp, "some content");
A generic interface which provides an IStorageFile
object as the
DestinationFile
property and data to be saved of type T
as the Data
property. Classes implementing this interface would encapsulate all data
required to perform a file save (the file to save to and the data to be
saved).
A setting with a default value in case its key is not in the data container.
// Local "foo" setting, default value is 0
var foo = Setting<int>.Local("foo");
// Roaming "bar" setting, default value is "baz"
var bar = Setting<string>.Roaming("bar", "baz");
foo.Value = 42; // setting associated with foo is now 42
string x = bar.Value; // x is now "baz"
Abstract class from which highlighters should derive. Deriving classes
need to implement the DefaultFormatting
method which should reset
formatting to (non-highlighted) default and the AddHighlightRules
which
should contain a list of calls to AddHighligtRule
, mapping regular
expressions to formatting actions.
Look at Easy.Text.Highlight.Markdown
for a sample implementation.
Note highlighting can only run on the UI thread because the
ITextDocument
and other involved WinRT objects cannot be used on other
threads.
Provides Markdown highlighting for a given ITextDocument
.
var highlighter = new Markdown(SomeTextDocument);
// Applies Markdown formatting on the given text
highlighter.Highlight();
Enables string search on an ITextDocument
, selecting the found string.
var search = new Search(SomeTextDocument);
// Highlights the first instance of 'foo' in the text
search.FindFirst("foo");
// Highlights the next instance of 'bar' after the previously found 'foo'
search.FindNext("bar");
...
// Search wraps around to the beginning of the text
search.FindNext("bar");
Provides asynchronous word count on an ITextDocument
.
var wordCount = new WordCount(SomeTextDocument);
int words = await wordCount.Count();
Easily display toast messages. Currently supports text or title + text. Don't forget to mark your app as toast capable in its manifest.
Toast.Show("A toast!");
Toast.Show("Title", "Some content");
Copyright (c) 2013-2014 Vlad Riscutia