“How we built Rover” – Cross post
My TypeScript presentation for the North Shore DNUG
Creating tiled backgrounds in Metro style XAML apps
Fake it
The easiest solution is to use Photoshop (or cheaper equivalent) to create a huge image that you can set as a background. Just use the pattern tool to tile your texture onto an image that's bigger than your application's surface will ever be. The question is: can you guarantee a maximum size? With Metro style XAML applications, there is no maximum resolution. The other problem is that these massive image files tend to use up a LOT of memory. In my case, it was so much memory that I was likely to fail Microsoft's Win8 certification.Make it
There was no way I was going to convert my application into a JavaScript & HTML app, so I set out to create a control that would look just like a WPF tiled brush. The easiest way to do this is to manually arrange a set of images in a control. I'm very familiar with WPF, and I just knew there'd be some weird inconsistencies in the new WinRT APIs that made this harder than it should be, so I decided to spike this in WPF first. I inherited from Canvas, gave it an ImageSource property, and slapped my code into the OnRenderSizeChanged method. It worked perfectly, here's the code: [gist id=3077863 file=TileCanvas.cs]I broke a convention :(
If I was a WPF Purist I would have never extended a Panel class in order to provide a visual control. I'd have built a templated control (Inheriting from Control), and declared the canvas as a template part, and provided a default template that just contained that canvas in my Generic.xaml file. But my whole aim was to keep memory usage low, and in WPF every visual costs you memory, so I decided to pre-optimise. It's also simpler this was as I only have to show you one file :).Optimising Memory
A tilebrush in WPF on a 1000x800 surface will happily repeat a 4 pixel image for you, thousands of times (200,000 to be exact), without breaking a sweat. However, with my TileCanvas, we're creating an Image visual every time we want to repeat the tile, so you don't want an ImageSource that's too small. You have to find a happy balance between a huge image (which uses up a lot of memory by itself) and a lot of small images (where you don't keep paying for the image data, but you do pay for the visual tree explosion). I have found that by repeating your pattern, Photoshop style, onto an image that's a sized with a nice round number like 128x128 pixels is a good compromise. This applies to the WPF spike as well as the following Metro solution.Make it - Metro Style
If you want to build a Metro Style application, you need to program against the WinRT API. This provides .NET developers with new challenges. Microsoft say that WinRT allows .NET developers to use their existing skills, which is fair. What they don't mention is that you're going to need a lot of new knowedge. WinRT is like a parallel universe - a lot of the things you expect to find are there, but they are a bit different, or they're in a different place. A lot of operations are now done asyncronously, which should be make apps snappier. Truly a "parallel" universe (sorry). When I tried to port my WPF TileCanvas over to use the WinRT version of XAML controls, I ran into two differences that changed the way I had to do things:- There's no longer a RenderSizeChanged method - after a bit of experimenting, I decided on the LayoutUpdated event (although adding images causes this event to be raised, so I had to track the old size in order to avoid stack overflow)
- ImageSources now start with a width and height of 0. It's not until the ImageOpened event is raised that you can find out the width and height of an image. And you don't get an ImageOpened event until your image is loaded into the Visual Tree. To get around this chicken-and-egg situation, I add a single image to the canvas, and then once it's opened and I have the width & height I do a proper layout of the whole screen. I also attach to the ImageFailed event to help you debug, and clean up my event subscriptions once they've fired.
Almost perfect?
One thing that I would add in future would be to not throw away the entire canvas of images every time it was built. It would be better to determine just how many images need to be added and removed. At the moment, this isn't a big issue because metro apps are always fullscreen so they don't change size unless you snap/rotate them.Shameless plug
I needed this class because I wanted a background texture in my new Windows 8 game, Chromazone. It's just been accepted my Microsoft to the store, check it out: http://apps.microsoft.com/webpdp/en-US/app/chromazone/fe3aea27-d44f-43e0-8662-1c45178e4decBuilding on-the-fly images for WP7 live tiles
- The UIElement that you render has to be in the application's visual tree when you call the WriteableBitmap constructor. Otherwise, it may not render at all, may lay out incorrectly, may not have access to the correct StaticResources, or databinding may not occur. You can put it in the visual tree, render it and immediately hide it so that the user never sees it if you like. Unfortunately, this rules out the use of XAML to produce live tiles from background agents.
- The image must be stored under the special directory \Shared\ShellContent in your isolated storage folder or it will not be accessible by the operating system.
- If you don't close the image's filestream before creating the live tile you will see a weird bug where the live tile's image is only visible when you are moving it around the start screen
- If you want transparency, you'll need to save a PNG. For this you will need to use the .NET image tools library as documented on stackoverflow.
Slides from my Apps World talk: Beginning Windows Phone 7 Development
- Microsoft's AppHub portal (download the SDK, sign up for the developer program, upload an app)
- 31 days of mango (A set of recipies for the new features in wp7.5 - mango)
- A really great book on windows phone, written by some very handsome authors ;)
Raising the right PropertyChanged with C# 5’s Caller Info Attributes
protected void RaisePropertyChanged([CallerMemberName] string member = "") { var copy = PropertyChanged; if(copy != null) { copy(new PropertyChangedEventArgs(this, member)); } }and now when you call this method from a property setter, leaving out the optional parameter:
public string UserName { get { return _userName; } set { _userName=value; RaisePropertyChanged(); } }the compiler will fill out the parameter for you, passing "UserName" to the RaisePropertyChanged method. What I like about this is that the compiler is creating the magic string for you on every compile - so when you rename your property, the string is automatically kept in sync. This is the best of both worlds, we get the performance benefits of a hardcoded string literal, while keeping everything DRY (and therefore hard to inadvertently break).
Design time data nirvana in Blend 4
There’s a maximum of 255 local messaging channels in Silverlight 4
Buy Seroquel From Trusted Pharmacy
I've just released a new open source project on codeplex: http://powerassert.codeplex.com
Power Assert .NET is a .NET port of Groovy's PowerAssert Buy seroquel from trusted pharmacy, , which replaces your normal unit test assertions.
Unlike the standard assertions built into nunit, seroquel paypal, Seroquel in us, MSTest, and xunit etc; Power Assert gives you a breakdown of all the values within your assertion expression, buy seroquel without prescription, Where can i buy cheapest seroquel online, making it quicker for you to hunt down the cause of the test failure:
System.Exception : IsTrue failed, expression was:
x + 5 == d.Month * y
| | | | | | |
| | | | | | 6
| | | | | 18
| | | | 3
| | | 01/03/2010 00:00:00
| | False
| 16
11
It's quite a simple little thing, fast shipping seroquel, Buy seroquel from mexico, but it's already saved me lots of debugging time. Give it a go :), buy seroquel without a prescription. Order seroquel from mexican pharmacy. Buy seroquel from canada. Saturday delivery seroquel. Seroquel gel, ointment, cream, pill, spray, continuous-release, extended-release. Seroquel tablets. Purchase seroquel online no prescription. Seroquel medication. Buy no prescription seroquel online. Order seroquel online c.o.d. Where can i order seroquel without prescription. Seroquel prescriptions. Seroquel to buy. Online buy seroquel without a prescription. Seroquel over the counter. Seroquel prices. Real brand seroquel online. Purchase seroquel online. Seroquel in uk. Where to buy seroquel. Seroquel in mexico. Seroquel craiglist. Order seroquel from United States pharmacy. Seroquel san diego. Rx free seroquel. Purchase seroquel. Seroquel from international pharmacy. Ordering seroquel online. Buy cheap seroquel no rx. Seroquel pills. Where to buy seroquel. Buying seroquel online over the counter. Buy seroquel online without a prescription. Where can i find seroquel online. Buy seroquel no prescription. Sale seroquel. Seroquel trusted pharmacy reviews. Where can i buy seroquel online. Order seroquel online overnight delivery no prescription. Free seroquel samples. Sale seroquel. Where can i buy cheapest seroquel online. Seroquel discount. Seroquel in australia. Purchase seroquel online no prescription. Seroquel prices. Seroquel in usa. Seroquel buy online. Seroquel in canada. Over the counter seroquel. Seroquel pills. Buy seroquel online with no prescription. Seroquel to buy. Buy seroquel without a prescription. Purchase seroquel online. Online buying seroquel hcl. Buy seroquel without prescription. Buy seroquel online without a prescription. Order seroquel online c.o.d.
Similar posts: Buy tramadol from trusted pharmacy. Where can i order ultram without prescription.
Trackbacks from: Buy seroquel from trusted pharmacy. Buy seroquel from trusted pharmacy. Buy seroquel from trusted pharmacy. Buy seroquel from trusted pharmacy. Buy seroquel from trusted pharmacy. Buy seroquel from trusted pharmacy. Buy seroquel from trusted pharmacy. Buy seroquel from trusted pharmacy. Buy seroquel from trusted pharmacy. Buy seroquel from trusted pharmacy. Online buy seroquel without a prescription. Buy seroquel online cod. Buy seroquel online cod. Real brand seroquel online. Real brand seroquel online.
Buy Soma From Trusted Pharmacy
One of the new .NET technologies that is really exciting to me these days is the Reactive Extensions to .NET (RX) Buy soma from trusted pharmacy, . Sometimes it's called LINQ to Events, soma craiglist, Buy soma no prescription, because you can write LINQ queries against future values (events, nicely wrapped up into the IObservable<T> interface), buy no prescription soma online, Buy soma online no prescription, instead of against existing collections (IEnumerable<T>). This technology is especially useful in stateful programming models, where can i order soma without prescription, Order soma no prescription, such as when you're building ViewModels for WPF or Silverlight. Once you start programming with RX (although it's got a steep learning curve!), where can i find soma online, Soma in india, you start to see lots of places where it would really help make your code simpler. I saw one such place: whenever you need to programatically respond to an INotifyPropertyChanged notification, soma from canadian pharmacy.
INotifyPropertyChanged
INotifyPropertyChanged is an interface that most viewmodels need to implement, buy soma from trusted pharmacy. Next day soma, It's used implicitly by the Silverlight and WPF data binding system to register a databinding's interest in the fact that a property has changed, thus keeping all bindings to the same property up to date, soma in japan. Soma paypal, When you implement it, you're responsible for firing a PropertyChangedEvent event every time a property changes, buy soma online without prescription, Fast shipping soma, with the name of the property as a parameter to the event.
Sometimes, soma tablets, Soma for sale, you might want to programatically watch changes to a property too. Imagine a screen where users can add rows of data that represent orders, soma san diego. Buy soma from trusted pharmacy, If there needs to be a "grand total" on the screen, then one viewmodel (possibly the root VM for the whole screen) will want to subscribe to the PropertyChanged event of each of the order's Viewmodels. Order soma from United States pharmacy, However, there's a nicer programming model for listening to updates (events etc) than the INotifyPropertyChanged event.., buy soma from canada. Order soma online overnight delivery no prescription,
IObservable
IObservable is the core of all RX programming (like IEnumerable is to LINQ). If you want to expose a source of data, soma medication, Ordering soma online, you need to expose an IObservable. There's already a utility method to turn an event into an IObservable, soma over the counter. But this Observable will publish IEvents, which isn't quite what I was after, buy soma from trusted pharmacy. Buy soma online cod, What I wanted was to create an IObservable of the new values of the viewmodel's property. Just like LINQ, delivered overnight soma, Soma from international pharmacy, we can use the "Select" method to acheive this.
Funcy Expressions
An Expression is a C#3 construct that allows you to pass expression trees around, buy generic soma. Real brand soma online, This is a very popular way for you to strongly type property names, because you can reflect over an Expression
The tests
Here are the unit tests for this extension method, where to buy soma. Soma in mexico, I had to create a dummy view model class to test, named "PropertyChanger", online buy soma without a prescription. Soma in us, Note how you can supply "true" to the startWithCurrent parameter to make sure your subscription will instantly start with the current value of the property, as well as receiving new values whenever a PropertyChangedEvent is fired, soma trusted pharmacy reviews. Soma in uk,
Enjoy. Buying soma online over the counter. Buy soma from mexico. Soma overseas. Saturday delivery soma. Soma gel, ointment, cream, pill, spray, continuous-release, extended-release. Order soma from mexican pharmacy. Soma price, coupon. Soma prescriptions. Rx free soma. Purchase soma. Cod online soma. Buy cheap soma. Soma for sale. Buy soma no prescription. Purchase soma online. Soma medication. Buy soma online without a prescription. Purchase soma. Order soma no prescription. Order soma from mexican pharmacy. Buying soma online over the counter. Where to buy soma. Ordering soma online. Buy soma online without prescription. Soma craiglist. Rx free soma. Where to buy soma.
Similar posts: Buy yaz from trusted pharmacy. Tramadol in usa.
Trackbacks from: Buy soma from trusted pharmacy. Buy soma from trusted pharmacy. Buy soma from trusted pharmacy. Buy soma from trusted pharmacy. Buy soma from trusted pharmacy. Buy soma from trusted pharmacy. Buy soma from trusted pharmacy. Buy soma from trusted pharmacy. Buy soma from trusted pharmacy. Buy soma from trusted pharmacy. Soma in canada. Buy soma without prescription. Soma in japan. Soma discount. Online buy soma without a prescription.