Jamie Cool .NET Framework Team Microsoft Corporation [email protected] Nick Kramer .NET Framework Team Microsoft Corporation [email protected] Tons of stuff – 2+ talks worth! Part 1 Silverlight + .NET Overview Getting.

Download Report

Transcript Jamie Cool .NET Framework Team Microsoft Corporation [email protected] Nick Kramer .NET Framework Team Microsoft Corporation [email protected] Tons of stuff – 2+ talks worth! Part 1 Silverlight + .NET Overview Getting.

Jamie Cool
.NET Framework Team
Microsoft Corporation
[email protected]
Nick Kramer
.NET Framework Team
Microsoft Corporation
[email protected]
Tons of stuff – 2+ talks worth!
Part 1
Silverlight + .NET Overview
Getting Started
Working with UI
Building custom controls
Part 2
HTTP Networking + XML
Web Services
LINQ
HTML Integration
Rounding it out
Web deployment
Need a ubiquitous platform
Need a secure sandboxed environment
Rich UI experiences beyond server generated HTML
Need a highly capable UI model
Signifigant client-side application logic
Need a highly productive development environment
Highly productive development Framework
Multi-language support, like C# & VB
Contains the latest innovation from Microsoft (ex. LINQ)
AJAX integration
Great tools with Visual Studio & Expression
Cross-platform & cross-browser plugin
Works with Safari, Firefox and IE on MAC & Windows
Fast, easy install process
Browser Host
MS AJAX
Library
DOM
Integration
.NET for Silverlight
Data
LINQ
XLINQ
WPF
Extensible Controls
DLR
Ruby
Python
BCL
Generics Collections
AutoUpdater
V1.1
Legend
XAML
Presentation
Core
Friction-Free
Installer
Legend
CLR Execution Engine
Application
Services
Deploy
Networking
REST
POX
RSS
JSON
SOAP
UI Core
Vector
Text
Animation Images
Inputs
Keyboard Mouse Ink
Media
VC1 WMA
MP3
DRM
Media
Controls
Layout Editing
V1.0
.NET for Silverlight is a factored subset of full .NET
Desktop ~50 MB (Windows only)
Silverlight + .NET Alpha ~ 4 MB (cross platform)
Additional pieces of .NET available in a pay-for-play model
Same core development Framework
The shared apis & technologies are the same
The tools are the same
Highly compatible
Minimal changes needed to move from Silverlight to Desktop
However, not binary compatible by default
All apps run in the sandbox
Conceptually similar to the HTML DOM sandbox
Apps run just like HTML pages – just click a URL
No elevation prompts.
No way to get out of the sandbox
Includes some additional functionality:
Safe isolated storage
Client based file upload controls
Cross domain support in-work
Install the following:
Silverlight V1.1 Alpha
Visual Studio “Orcas” Beta 1
Silverlight Tools Alpha for Visual Studio "Orcas" Beta 1
Expression Blend 2 May Preview
ASP.NET Futures
Everything you need is at www.silverlight.net
Links to downloads & docs
VS object browser a great way to view APIs
A .NET silverlight app includes at least:
A root html file - Default.htm
Script load files - CreateSilverlight.js & Silverlight.js
A root xaml & assembly - YourApp.xaml & YourApp.dll
A .NET Silverlight app is also likely to include:
Other application libraries (your's, Microsoft's or 3rd parties)
Application resources (ex. xaml) – optionally embedded in assembly
Packaging
Loose file support in Alpha 1
Zip package support planned
XAML = eXtensible Application Markup Language
Flexible XML document schema
Examples: WPF, Silverlight, Workflow Foundation
More compact than code
Enables rich tooling support
While still preserving good readability and hand-coding within
text editors
<Canvas
xmlns="http://schemas.microsoft.com/client/2007"
>
<TextBlock FontSize="32" Text="Hello world" />
</Canvas>
Hello world
<TextBlock FontSize="32" Text="Hello world" />
=
TextBlock t = new TextBlock();
t.FontSize = 32;
t.Text = "Hello world";
Is a Drawing Surface
Children have relative positions:
<Canvas Width="250" Height="200">
<Rectangle Canvas.Top="25" Canvas.Left="25"
Width="200" Height="150" Fill="Yellow" />
</Canvas>
The Canvas
The Rectangle
Position relative to first Canvas parent:
<Canvas Background="Light Gray">
<Canvas Canvas.Top="25" Canvas.Left="25"
Width="150" Height="100"
Background="Red">
<Ellipse Canvas.Top="25"
Canvas.Left="25"
Width="150"
Height="75"
Fill=“White" />
</Canvas>
</Canvas>
<Canvas>
<Rectangle/>
</Canvas>
=
Canvas canvas = new Canvas();
Rectangle rectangle = new Rectangle();
canvas.Children.Add(rectangle);
<Canvas>
<Rectangle Canvas.Top="25"/>
</Canvas>
Top property only make sense inside a Canvas
When we add new layouts, do we add new properties to
Rectangle?
Solution: attached properties!
<Rectangle Canvas.Top="25" Canvas.Left="25"/>
=
Rectangle rectangle = new Rectangle();
rectangle.SetValue(Canvas.TopProperty, 25);
rectangle.SetValue(Canvas.LeftProperty, 25);
All elements support them
Transform Types
<RotateTransform />
<ScaleTransform />
<SkewTransform />
<TranslateTransform />
Moves
<MatrixTransform />
Scale, Skew and Translate Combined
<TextBlock Text="Hello World">
<TextBlock.RenderTransform>
<RotateTransform Angle="45" />
</TextBlock.RenderTransform>
</TextBlock>
Property values can be complex objects
Use “property elements” to represent them in XML
<SomeClass.SomeProperty>
<TextBlock>
<TextBlock.RenderTransform>
<RotateTransform Angle="45" />
</TextBlock.RenderTransform>
</TextBlock>
=
TextBlock block = new TextBlock;
RotateTransform transform = new RotateTransform();
Transform.Angle = 45;
block.RenderTransform = transform;
MouseMove
MouseEnter
MouseLeave
MouseLeftButtonDown
MouseLeftButtonUp
KeyUp
KeyDown
GotFocus
LostFocus
Loaded
<Canvas xmlns="…" xmlns:x="…"
MouseEnter="OnMouseEnter">
</Canvas>
=
Canvas canvas = new Canvas();
canvas.MouseEnter += OnMouseEnter;
// or more explicitly:
canvas.MouseEnter += new MouseEventHandler(OnMouseEnter);
<Canvas xmlns="…" xmlns:x="…"
Height="100" Width="100" Background="Red"
x:Name=“canvas”
/>
</Canvas>
Private Sub something _
(ByVal o As Object, ByVal e As MouseEventArgs) _
Handles canvas.MouseEnter
rectangle.Fill = New SolidColorBrush(Colors.Green)
End Sub
<Canvas xmlns="…" xmlns:x="…"
Height="100" Width="100" Background="Red"
MouseEnter="OnMouseEnter"
/>
</Canvas>
void OnMouseEnter(object sender, MouseEventArgs e)
…
}
{
Name your xaml element so you can use it in code
<Rectangle x:Name=“rect”/>
void OnMouseEnter(object sender, MouseEventArgs e)
rect.Height = 75;
}
{
Custom Element = custom class
(Markup = object model)
Use XML namespaces
<prefix:CustomClass/>
XML namespace declaration tells where to find class
xmlns:prefix=
"clr-namespace:SomeNamespace;
assembly=SomeAssembly.dll"
Derive from Control
Eg, public class MyControl : Control
Define the look of the control in xaml
Call InitializeFromXaml(xaml)
Remember the return value
Have a public parameterless constructor
Eg, public MyControl()
Create public properties
Create public events
In terms of graphics/UI/XAML:
v1.1 =
v1.0
+ managed code (CLR)
+ XAML extensibility
+ Control class (user control)
+ sample controls
Button
TextBox (edit)
Scrollbar
Slider
ListBox
CheckBox
RadioButton
ComboBox
1.1 alpha
Sample
No
Sample
Sample
Sample
No
No
No
1.1 thinking
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
WPF
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
TreeView
Accordion
DataGrid
UserControl
1.1 alpha
No
No
No
Yes
1.1 thinking
No
No
No
Yes
WPF
Yes
3rd party
3rd party
Yes
Canvas
Grid (table)
StackPanel
Viewbox
1.1 alpha
Yes
No
No
No
1.1 thinking
Yes
Yes
Yes
Yes
WPF
Yes
Yes
Yes
Yes
Mouse events
Keyboard
events
<.Resources>
Data binding
styling
1.1 alpha
Partial
Partial
1.1 thinking
Yes
Yes
WPF
Yes
Yes
Partial
No
No
Yes
Yes
Yes
Yes
Yes
Yes
1.1 alpha
No
No
3D
Hardware
acceleration
Out of browser No
Off-line
No
Cross-platform Yes
1.1 thinking
No
No
WPF
Yes
Yes
No
No
Yes
Yes
Yes
No
HTTP Networking + XML
Web Services
LINQ
HTML Integration
Rounding it out
Resources
Browser based headers/cookies passed with request
Restricted to same domain access in the Alpha
Cross-domain coming
Make the HTTP Request
Uri dataLocation = new Uri("http://localhost/playerdata.xml");
BrowserHttpWebRequest request = new BrowserHttpWebRequest(dataLocation);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Process the response
StreamReader responseReader = new
StreamReader(response.GetResponseStream());
string RawResponse = responseReader.ReadToEnd();
Core XML reading & writing capabilities in the alpha
RAD XLINQ support coming
Initialize the reader
XmlReader xr = XmlReader.Create(new StringReader(RawResponse));
Find a node & read it’s value
xr.ReadToFollowing("Player");
string playerNodeText = xr.Value;
string playerNameAttribute = xr.GetAttribute("Name");
VS based Proxy Generator enables strongly typed access
ASP.NET JSON services supported in the Alpha
WCF & SOAP support coming
The Web Service to Call
[WebMethod]
public List<Player> GetPlayerList() {
... }
Call the Web Service from the client
baseballService = new BaseballData();
playerList = baseballService.GetPlayerList().ToList();
Sync & Async web services supported in the Alpha
General purpose RAD async support coming
Start the async web service call
baseballService.BeginGetPlayerList(
new AsyncCallback(OnPlayerDataLoaded), null);
Handle the web service completion event
private void OnPlayerDataLoaded(IAsyncResult iar)
{
playerList = baseballService.EndGetPlayerList(iar).ToList();
}
Works with any Web server
Only requirement is to serve Silverlight files to the browser
Ex. xaml, assemblies, resources
ASP.NET is a great platform for Silverlight applications
Use ASP.NET & WCF services from Silverlight
Integrate Media into an ASPX page
Integrate Silverlight content into an ASPX page
Leverage ASP.NET AJAX Extensions and ASP.NET Futures
(May 2007)
Other integration points under way…
LINQ = Language INtegrated Query
Allows query expressions to benefit from compile-time
syntax checkking, static typing & Intellisense
Works on any IEnumerable<T> based info source
Return all players with 20+ home runs, sorted
var filteredPlayers = from p in players
where p.HomeRuns > 20
orderby p.HomeRuns descending
select p;
Supports querying on in memory datasources
Other LINQ technologies forthcoming:
XLINQ = LINQ for XML
Query, parse, create XML
DLINQ = LINQ for relational data
Query, edit, create relational data
HTML access availble in new namespace
using System.Windows.Browser;
Static HtmlPage class provides entry point
HtmlPage.Navigate("http://www.microsoft.com");
String server = HtmlPage.DocumentUri.Host;
Hookup events, call methods, or access properties
HtmlElement myButton = HtmlPage.Document.GetElementByID("myButtonID");
myButton.AttachEvent("onclick", new EventHandler(this.myButtonClicked));
private void myButtonClicked(object sender, EventArgs e)
{ ... }
Mark a property, method or event as Scriptable:
[Scriptable]
public void Search(string Name)
{
…
}
Register a scriptable object:
WebApplication.Current.RegisterScriptableObject("BaseballData", this);
Access the managed object from script:
var control = document.getElementById("Xaml1");
control.Content.BaseballData.Search(input.value);
Other interesting HTML integration scenarios:
Persisent links
Fwd/Back Integration
Notes:
Simple type marshalling only in the Alpha
Complex type support on the way
Enables debugging of Silverlight code on the MAC
Requires a proxy client installed on the MAC
Proxy & setup instructions can be found at:
C:\Program Files\Microsoft Visual Studio
9.0\Silverlight\MacIntel\
Proxy must be running prior to browser activation
Dynamic Languages
Javascript, Python, Ruby
Application Services
Isolated Storage
Safe File Open
ASP.NET Integration
Find out more about these technologies in upcoming sessions…
Talk
Time
Just Glue It! Dynamic Languages in Silverlight
Tues – 11:45
Developing ASP.NET AJAX Controls with Silverlight
Tues – 11:45
Deep Dive on Silverlight Media Integration
Tues - 2:15
Extending the Browser Programming Model with
Silverlight
Building Rich, Interactive E-commerce Applications
Using ASP.NET and Silverlight
Wens – 9:45
Wens – 11:30
Give us feedback
Features you like?
Features you don’t?
What do you want to build?
What existing code & skills will you leverage?
© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions,
it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation.
MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.