Slides from casual talk I gave during Appspirina X-mas 2012 edition in BlackSheep club in Warsaw/Poland (Dec 28th). Slides as well as the talk itself are very casual too, but I hope some of you may find the information valuable.
9. In common
• Windows 8 app targeting touch devices
• Relatively simple (in scope ~= 1 month)
• B2B model:
• I’m just the dev and advisory guy
• Product design, management and
ownership => customer side
sobota, 5 stycznia 13
10. Top differences
• Customer types:
• Corporate vs. Startup entity
• Technology:
• C# & Xaml vs. C++, Xaml & DirectX
• Design
• Core „Metro” vs. 95% custom
• In-app business model {free vs. paid}
sobota, 5 stycznia 13
11. Top differences
• Customer types:
• Corporate vs. Startup entity
• Technology:
• C# & Xaml vs. C++, Xaml & DirectX
• Design
• Core „Metro” vs. 95% custom
• In-app business model {free vs. paid}
sobota, 5 stycznia 13
12. Team, process &
communication
• Roles and competences
• think carefully about communication inside the team
• especially when customer is part of the team
• Tools:
• for prototyping
• for testing
• for software and design requirements
• „Agile” approach
• short iterations vs. discussion about „imperfect product”
• milestones and again appropriate communication with the customer
sobota, 5 stycznia 13
17. Design
• When porting from Web/IOS:
• New features (non existing on other platforms)
• Snap View
• Search, Share contracts
• Understanding of Metro Design principles
• If only possible everything asynchronous
• (Data = Content) Driven Development
• Expression Blend, tricky yet unavoidable and handy tool
for design keen developers.
sobota, 5 stycznia 13
18. CPP vs. C#
experience
• Easy part:
• Xaml is the same and behaves the same, you can
trust it and your skills
• Great async support with PPL Tasks
• still, remember about the Dispatcher
• Challenges:
• WinRT projection to C# != projection to C++
• DirectX mappings, then it’s cool too.
• Understanding of share contract
sobota, 5 stycznia 13
19. WinRT in C++ from
C-sharpers’
• Basic Platform::String example:
• In C++:
• initializer,
• cast to std::wstring
• ::Begin, ::End iterators
• array [] wchar_t indexer
• Concat method & operators
• AND THAT’S ALL WHAT YOU HAVE
sobota, 5 stycznia 13
20. WinRT in C++ from
C-sharpers’
• How to sub divide, search and execute other usual string
operations?
• cast to std::wstring and go with STL
• Pros: great interaction with STL
• Cons: stupid question rather: why the heck so basic
object is so limited?
• .. and there is more diffs like that, C#‘ers will catch them
often
sobota, 5 stycznia 13
23. Dynamic Binding
and Cache
Windows::UI::Xaml::Media::Imaging::BitmapImage^
bitmapSrc
=
ref
new
Windows::UI::Xaml::Media::Imaging::BitmapImage();
bitmapSrc-‐>CreateOptions
=
BitmapCreateOptions::IgnoreImageCache;
bitmapSrc-‐>UriSource
=
uri;
img-‐>CacheMode
=
nullptr;
img-‐>Source
=
bitmapSrc;
LoadListView-‐>Items-‐>Append(img);
...
sobota, 5 stycznia 13
24. Dynamic Binding
and Cache
Windows::UI::Xaml::Media::Imaging::BitmapImage^
bitmapSrc
=
ref
new
Windows::UI::Xaml::Media::Imaging::BitmapImage();
bitmapSrc-‐>CreateOptions
=
BitmapCreateOptions::IgnoreImageCache;
bitmapSrc-‐>UriSource
=
uri;
img-‐>CacheMode
=
nullptr;
img-‐>Source
=
bitmapSrc;
LoadListView-‐>Items-‐>Append(img);
...
...
file-‐>DeleteAsync();
auto
item
=
(Image^)LoadListView-‐>Items-‐>GetAt(selected);
auto
src
=
(BitmapImage^)item-‐>Source;
src-‐>UriSource
=
nullptr;
//If
you
don’t
clear
it,
cache
stays
//even
if
all
IgnoreCache,
CacheMode
properties
//are
set
well
LoadListView-‐>Items-‐>RemoveAt(selected);
...
sobota, 5 stycznia 13
25. Resource
Management
• BitmapSource <=> DirectX/WIC
• Different Resolutions, DPI and
Proportions
• Xaml based positioning
• Renderer’s rescale capabilities
• Res/Snap/DPI Detection
sobota, 5 stycznia 13
26. Direct 2D paths,
nice stuff and bad stuff
• Nice stuff, it handles ink over bezier curves well!
• It lacks of BitmapBrush for Bezier strokes
• BitmapBrush can only fill closed paths
• Sampling on your own:
strokeGeometry-‐>ComputePointAtLength(
...
)
• Blending is kind of tricky:
• ID2D1Image -> D2D1Bitmap tricks for eraser
sobota, 5 stycznia 13
27. Sharing API
challenges
RandomAccessStreamReference^
imp
=
nullptr;
ComPtr<IStream>
stream;
StorageFile^
file
=
SaveToFileForSharing();
auto
p
=
file-‐>Path;
ras
=
RandomAccessStreamReference::CreateFromFile(file);
e-‐>Request-‐>Data-‐>Properties-‐>Title
=
"Hello
from
Bord
by
Pixle";
//e-‐>Request-‐>Data-‐>SetUri(
...
);
//e-‐>Request-‐>Data-‐>SetText(
...
);
//e-‐>Request-‐>Data-‐>SetUri(
...
);
e-‐>Request-‐>Data-‐>SetBitmap(ras);
e-‐>Request-‐>Data-‐>ResourceMap-‐>Insert("chalkImage.jpg",
ras);
e-‐>Request-‐>Data-‐>SetHtmlFormat(HtmlFormatHelper::CreateHtmlFormat(L"<p>Look
what
I've
drawn
with
a
very
cool
app
called
Bord:
<img
src='chalkImage.jpg'></
p>"));
sobota, 5 stycznia 13
28. Sharing API
challenges
• Publisher side has no control:
• it exposes as many formats as possible (crazy tactic)
• and hopes that consumer will interpret it well
• Share JPG through SetBitmap and send it to Mail:
• it converts it to PNG and (100kb JPG => 4.5MB PNG)
• Messages accepts only URL
• if you want to send there Facebook message with picture, you have to publish
picture in the cloud first, you cannot upload it from local storage anyhow.
• You expose something in a format
• App „A” interprets it well, app B screwed the thing around in embarassing
way. There is no option that you’d like to keep format exposed to „A” and
block to „B”
sobota, 5 stycznia 13
29. Of course there is
more
• but we have only 30 minutes, so...
sobota, 5 stycznia 13
30. .. to summarize
• C++ experience is much better than Win32/MFC/whatever old-school
Windows development
• Even though WinRT is in C++ (WRL) there is still lot of API
inconsequence in projections.
• for Xaml only apps, it’s 1st class citizen if the language is the
preference, but you have to be patient to mix Cx/ISO and WinRT/
STL routines
• (or wrap it well if project is bigger or you’re the architecture junkie)
• DirectX 11.1 lacks of good documentation - if you lack experience,
you’ll have to experiment a lot!
• It integrates great with STL and COM (via WRL)
• It has great async support (PPL)
sobota, 5 stycznia 13
31. Thank you
daniel.biesiada@ushine.pl
sobota, 5 stycznia 13