Showing posts with label HTML5. Show all posts
Showing posts with label HTML5. Show all posts

Thursday, June 13, 2013

What's New in the .NET Framework 4.5?

This topic contains a summary of key new features and improvements in the following areas of the .NET Framework 4.5. This topic does not provide comprehensive information and is subject to change. For general information about the .NET Framework, see Getting Started with the .NET Framework. For supported platforms, see System Requirements. For download links and installation instructions, see Installing the .NET Framework 4.5.



.NET for Windows Store apps

Windows Store apps are designed for specific form factors and leverage the power of the Windows operating system. A subset of the .NET Framework 4.5 is available for building Windows Store apps for Windows by using C# or Visual Basic. This subset is called .NET for Windows Store apps and is discussed in an overview in the Windows Dev Center.


Portable Class Libraries

The Portable Class Library project in Visual Studio 2012 enables you to write and build managed assemblies that work on multiple .NET Framework platforms. Using a Portable Class Library project, you choose the platforms (such as Windows Phone and .NET for Windows Store apps) to target. The available types and members in your project are automatically restricted to the common types and members across these platforms.


Core New Features and Improvements

The following features and improvements were added to the common language runtime and to .NET Framework classes:
  • Ability to reduce system restarts by detecting and closing .NET Framework 4 applications during deployment. See Reducing System Restarts During .NET Framework 4.5 Installations.
  • Support for arrays that are larger than 2 gigabytes (GB) on 64-bit platforms. This feature can be enabled in the application configuration file. See the gcAllowVeryLargeObjects element, which also lists other restrictions on object size and array size.
  • Better performance through background garbage collection for servers. When you use server garbage collection in the .NET Framework 4.5, background garbage collection is automatically enabled. See the Background Server Garbage Collection section of the Fundamentals of Garbage Collection topic.
  • Background just-in-time (JIT) compilation, which is optionally available on multi-core processors to improve application performance. See ProfileOptimization.
  • Ability to limit how long the regular expression engine will attempt to resolve a regular expression before it times out. See the Regex.MatchTimeout property.
  • Ability to define the default culture for an application domain. See the CultureInfo class.
  • Console support for Unicode (UTF-16) encoding. See the Console class.
  • Support for versioning of cultural string ordering and comparison data. See the SortVersion class.
  • Better performance when retrieving resources. See Packaging and Deploying Resources in Desktop Apps.
  • Zip compression improvements to reduce the size of a compressed file. See the System.IO.Compression namespace.
  • Ability to customize a reflection context to override default reflection behavior through the CustomReflectionContext class.
  • Support for the 2008 version of the Internationalized Domain Names in Applications (IDNA) standard when the System.Globalization.IdnMapping class is used on Windows 8.
  • Delegation of string comparison to the operating system, which implements Unicode 6.0, when the .NET Framework is used on Windows 8. When running on other platforms, the .NET Framework includes its own string comparison data, which implements Unicode 5.x. See the String class and the Remarks section of the SortVersion class.
  • Type reflection support split between Type and TypeInfo classes. See Reflection in the .NET Framework for Windows Store Apps.

Managed Extensibility Framework (MEF)

The Managed Extensibility Framework (MEF) provides the following new features:
  • Support for generic types.
  • Convention-based programming model that enables you to create parts based on naming conventions rather than attributes.
  • Multiple scopes.
  • A subset of MEF that you can use when you create Windows Store apps. This subset is available as a downloadable package from the NuGet Gallery. To install the package, open your project in Visual Studio 2012, choose Manage NuGet Packages from the Project menu, and search online for the Microsoft.Composition package.
     
Asynchronous File Operations

In the .NET Framework 4.5, new asynchronous features were added to the C# and Visual Basic languages. These features add a task-based model for performing asynchronous operations. To use this new model, use the asynchronous methods in the I/O classes. See Asynchronous File I/O.
 

Tools

Resource File Generator (Resgen.exe) enables you to create a .resw file for use in Windows Store apps from a .resources file embedded in a .NET Framework assembly. For more information, see Resgen.exe (Resource File Generator).
Managed Profile Guided Optimization (Mpgo.exe) enables you to improve application startup time, memory utilization (working set size), and throughput by optimizing native image assemblies. The command-line tool generates profile data for native image application assemblies. See Mpgo.exe (Managed Profile Guided Optimization Tool).


Parallel Computing

The .NET Framework 4.5 provides several new features and improvements for parallel computing. These include improved performance, increased control, improved support for asynchronous programming, a new dataflow library, and improved support for parallel debugging and performance analysis. See the entry What’s New for Parallelism in .NET 4.5 in the Parallel Programming with .NET blog.


Web

ASP.NET 4.5 includes the following new features:
  • Support for new HTML5 form types.
  • Support for model binders in Web Forms. These let you bind data controls directly to data-access methods, and automatically convert user input to and from .NET Framework data types.
  • Support for unobtrusive JavaScript in client-side validation scripts.
  • Improved handling of client script through bundling and minification for improved page performance.
  • Integrated encoding routines from the AntiXSS library (previously an external library) to protect from cross-site scripting attacks.
  • Support for WebSockets protocol.
  • Support for reading and writing HTTP requests and responses asynchronously.
  • Support for asynchronous modules and handlers.
  • Support for content distribution network (CDN) fallback in the ScriptManager control.

Networking

The .NET Framework 4.5 provides a new programming interface for HTTP applications. For more information, see the new System.Net.Http and System.Net.Http.Headers namespaces.
Support is also included for a new programming interface for accepting and interacting with a WebSocket connection by using the existing HttpListener and related classes. For more information, see the new System.Net.WebSockets namespace and the HttpListener class.
In addition, the .NET Framework 4.5 includes the following networking improvements:
  • RFC-compliant URI support. For more information, see Uri and related classes.
  • Support for Internationalized Domain Name (IDN) parsing. For more information, see Uri and related classes.
  • Support for Email Address Internationalization (EAI). For more information, see the System.Net.Mail namespace.
  • Improved IPv6 support. For more information, see the System.Net.NetworkInformation namespace.
  • Dual-mode socket support. For more information, see the Socket and TcpListener classes.


Windows Presentation Foundation (WPF)

In the .NET Framework 4.5, Windows Presentation Foundation (WPF) contains changes and improvements in the following areas:
  • The new Ribbon control, which enables you to implement a ribbon user interface that hosts a Quick Access Toolbar, Application Menu, and tabs.
  • The new INotifyDataErrorInfo interface, which supports synchronous and asynchronous data validation.
  • New features for the VirtualizingPanel and Dispatcher classes.
  • Improved performance when displaying large sets of grouped data, and by accessing collections on non-UI threads.
  • Data binding to static properties, data binding to custom types that implement the ICustomTypeProvider interface, and retrieval of data binding information from a binding expression.
  • Repositioning of data as the values change (live shaping).
  • Ability to check whether the data context for an item container is disconnected.
  • Ability to set the amount of time that should elapse between property changes and data source updates.
  • Improved support for implementing weak event patterns. Also, events can now accept markup extensions.

Windows Communication Foundation (WCF)

In the .NET Framework 4.5, the following features have been added to make it simpler to write and maintain Windows Communication Foundation (WCF) applications:
  • Simplification of generated configuration files.
  • Support for contract-first development.
  • Ability to configure ASP.NET compatibility mode more easily.
  • Changes in default transport property values to reduce the likelihood that you will have to set them.
  • Updates to the XmlDictionaryReaderQuotas class to reduce the likelihood that you will have to manually configure quotas for XML dictionary readers.
  • Validation of WCF configuration files by Visual Studio as part of the build process, so you can detect configuration errors before you run your application.
  • New asynchronous streaming support.
  • New HTTPS protocol mapping to make it easier to expose an endpoint over HTTPS with Internet Information Services (IIS).
  • Ability to generate metadata in a single WSDL document by appending ?singleWSDL to the service URL.
  • Websockets support to enable true bidirectional communication over ports 80 and 443 with performance characteristics similar to the TCP transport.
  • Support for configuring services in code.
  • XML Editor tooltips.
  • ChannelFactory caching support.
  • Binary encoder compression support.
  • Support for a UDP transport that enables developers to write services that use "fire and forget" messaging. A client sends a message to a service and expects no response from the service.
  • Ability to support multiple authentication modes on a single WCF endpoint when using the HTTP transport and transport security.
  • Support for WCF services that use internationalized domain names (IDNs).
 

Windows Workflow Foundation (WF)

Several new features have been added to Windows Workflow Foundation (WF) in the .NET Framework 4.5. These new features include:
  • State machine workflows, which were first introduced as part of the .NET Framework 4.0.1 (.NET Framework 4 Platform Update 1). This update included several new classes and activities that enabled developers to create state machine workflows. These classes and activities were updated for the .NET Framework 4.5 to include:
    • The ability to set breakpoints on states.
    • The ability to copy and paste transitions in the workflow designer.
    • Designer support for shared trigger transition creation.
    • Activities for creating state machine workflows, including: StateMachine, State, and Transition.
  • Enhanced Workflow Designer features such as the following:
    • Enhanced workflow search capabilities in Visual Studio, including Quick Find and Find in Files.
    • Ability to automatically create a Sequence activity when a second child activity is added to a container activity, and to include both activities in the Sequence activity.
    • Panning support, which enables the visible portion of a workflow to be changed without using the scroll bars.
    • A new Document Outline view that shows the components of a workflow in a tree-style outline view and lets you select a component in the Document Outline view.
    • Ability to add annotations to activities.
    • Ability to define and consume activity delegates by using the workflow designer.
    • Auto-connect and auto-insert for activities and transitions in state machine and flowchart workflows.
  • Storage of the view state information for a workflow in a single element in the XAML file, so you can easily locate and edit the view state information.
  • A NoPersistScope container activity to prevent child activities from persisting.
  • Support for C# expressions:
    • Workflow projects that use Visual Basic will use Visual Basic expressions, and C# workflow projects will use C# expressions.
    • C# workflow projects that were created in Visual Studio 2010 and that have Visual Basic expressions are compatible with C# workflow projects that use C# expressions.
  • Versioning enhancements:
    • The new WorkflowIdentity class, which provides a mapping between a persisted workflow instance and its workflow definition.
    • Side-by-side execution of multiple workflow versions in the same host, including WorkflowServiceHost.
    • In Dynamic Update, the ability to modify the definition of a persisted workflow instance.
  • Contract-first workflow service development, which provides support for automatically generating activities to match an existing service contract.

Thursday, June 6, 2013

Building Apps for Windows Phone 8

It’s a very exciting time for developers! Last week, we launched Windows 8 and Surface. Microsoft launched Windows Phone 8 and introduced some awesome new smartphone devices. Today, we’re kicking off the Build conference, where we’ll join with thousands of developers in person, and with hundreds of thousands virtually, to explore the opportunities available with Microsoft platforms and tools. And now, in conjunction with yesterday’s Windows Phone 8 news and with our goal of having tools available on the same cadence as the platforms, I’m very excited to share that the Windows Phone SDK 8.0, including Visual Studio Express 2012 for Windows Phone, is now available for download.
With Windows 8, Windows Phone 8, and Windows Azure, developers using Visual Studio 2012 can build experiences that span the Windows ecosystem, from desktops to laptops to tablets to smartphones to the cloud. And with that in mind, today’s release of the Windows Phone SDK 8.0 enables some exciting new capabilities for developers, such as using C++ and DirectX to build stunning experiences, enabling in-app purchases to sell virtual and digital good within apps, helping developers to streamline their efforts with the advances we’ve made in Visual Studio 2012 and .NET, and more.
The Windows Phone SDK 8.0 works with the Visual Studio 2012 and enables you to get started today building great apps for both Windows Phone 8 and Windows Phone 7.x. It includes emulators for both environments, including the ability to validate for multiple chassis, and support for simulating various network conditions (e.g. ‘2G’, ‘3G’). It includes new templates for developing Windows Phone apps, such as for building apps with Direct3D, and it sports enhanced diagnostics for analyzing apps, such as power and network profiling and responsiveness monitoring. It enables building native apps as well as building managed apps that consume native libraries. It enables much easier portability between Windows 8 apps and Windows Phone 8 apps. It includes .NET portable library support, so you can write your libraries once and reuse them across all your apps. The list goes on.
As an avid user of Windows Phone, I’m looking forward to downloading and using the stellar apps you all create.

For a more in-depth tour through what’s new for developers in the Windows Phone SDK 8.0, see the Visual Studio team, .NET team, and Blend team blogs.

Wednesday, May 29, 2013

Real World - CSS3

If you’re reading this, the chances are you’ve seen some of the amazing things that have been done in CSS3. Unfortunately, most of them aren’t practical for you, or your clients.

No longer, I say!

Below is a carefully-curated list of real-world examples and snippets of CSS3 that can be safely used to enhance any piece of work you create.

To use any of the following snippets,
you’ll need to include a CSS file.
Please, feel free to ask me for the CSS file.

  1. Recreating the <blink> tag

    This was, by far, the best tag in HTML. Unfortunately, it got dropped due to its lack of semantics. Well, it’s back.

    This is some blinking text.
    This is some <span class="blink">blinking</span> text.
  2. Recreating the <marquee> tag

    You know when I said that <blink> was the best tag? Well, I lied. Presenting: a valid CSS3 marquee.

    You spin me right round, baby. Like a record, baby. You spin me right round, baby. Like a record, baby.
    <div class="marquee" style="width: 380px;"><p><span>You spin me right round, baby.
    Like a record, baby.</span><span>You spin me right round, baby. Like a record, baby. 
    </span></p></div>
  3. Peekaboo!

    Is your client not listening to any of your opinions, is throwing a tantrum when it comes to the invoice, or is generally acting like a toddler? They might be a toddler. If so, this will help.

    I see you!
    <p class="peekaboo">I see you!</p>
  4. Wibble-Wobble

    Got a fidgety client, who makes lots of stinging remarks? They’ll bee happy when their page wobbles, then.

    The 2nd man to walk on the moon was Buzz Aldrin.
    The 2nd man to walk on the moon was <span class="wobble">Buzz</span> Aldrin.
  5. The Third Degree

    It won’t take too much detective work to find this handy little snippet.

    Something’s not quite level here.
    <span class="third-degree">Something&rsquo;s not quite level here.</span>
  6. WordArt

    Finally, a standards-compliant way to unleash the best type in the world!

    WordArt

    <h1 class="wordart" title="WordArt!">WordArt!</h1>
  7. Nausea

    Remember spinning on roundabouts as a kid? I hated ‘em. After seeing this, hopefully you will too!
    Woah-oah-oah!
     
     
    <span class="nausea">Woah-oah-oah!</span>
  8. The Perfect Typography

    Why bother choosing a font, when you know what you and your client wants?


    It’s perfect!
     
    <p class="perfect">It's perfect!</p> 

Sunday, May 26, 2013

Style Scope with HTML5 Canvas

When working with HTML5 Canvas, we're constantly interacting with the canvas context object, which contains an abundance of cool styling properties and drawing methods.  For a typical block of code that draws something onto the canvas, we draw a path, set a handful of context properties to style whatever it is we're drawing, and then use methods like fill() and stroke() to actually draw things onto the canvas.  Piece of cake, right?
But what happens if we're creating large, complex canvas applications, and we have lots of methods and functions that draw things onto the canvas which can be executed in any order?  We certainly don't want styles from different parts of our code base leaking into other parts of the code base.  Here's an example:

Code Editor














As you can see, we're calling drawTransparentSquare() followed by drawSquare().  Since objects can be modified by reference in JavaScript, when the first function set the global alpha property to 0.5, the style leaked over into the next function call and made the second square transparent as well.  This obviously wasn't the desired result.
So what can we do do?  Should each of our methods and functions reset the context styles like a CSS reset for each function?  Although this could be achievable by creating a resetStyles() function which loops through all of the styling properties and sets them to their default values, it seems a bit odd to constantly reset all of the style properties each time a function call is made.  Is there a better way?

Style Scope Induction


Style scope refers to the scope of styling inside of code blocks, similar to the notion of variable scoping inside of code blocks.  When writing JavaScript code, for example, it's good practice to split the code base into a collection of modular methods and functions, such that variables created within each function are scoped only to that particular function, and aren't accessible outside of it.  This is called variable scope induction.  What we need here, is a way to induce style scope within a function, or any other block of code, in such a way that the styles applied to the context don't leak over into other functions or blocks of code.

The HTML5 Canvas State Stack: A Diamond in the Rough


One of the most powerful, and probably the most overlooked features of the HTML5 canvas, is the state stack.  The state stack stores snapshots of styles and transformations in a stack data structure via the save() method of the canvas context.  What's even more important is that we can also use the state stack to restore snapshots of styles and transformations with the restore() method.
So how can we use the state stack to induce style scope?  If we use the save() method at the beginning of a function definition, we can save the state of the canvas context in the state stack.  Once the state is saved, we can apply several context styles, draw things, and then restore the state stack back to the initial state with the restore() method.  Viola, we've just induced style scope.

HTML5 Canvas

Welcome to Basic Tutorials! In these tutorials we'll focus on the fundamental drawing capabilities of the HTML5 Canvas.

HTML5 Canvas Basic Tutorials Prerequisites


All you need to get started with Basic Tutorials is a modern browser such as Google Chrome, Firefox, Safari, Opera, or IE9, a good working knowledge of JavaScript, and a simple text editor like notepad.

HTML5 Canvas Element Tutorial


The HTML5 Canvas element is an HTML tag similar to the div, a or table tag, with the exception that its contents are rendered with JavaScript.  In order to leverage the HTML5 Canvas, we'll need to place the canvas tag somewhere inside the HTML document, access the canvas tag with JavaScript, create a context, and then utilize the HTML5 Canvas API to draw visualizations.

When using canvas, it's important to understand the difference between the canvas element and the canvas context, as often times people get these confused.  The canvas element is the actual DOM node that's embedded in the HTML page.  The canvas context is an object with properties and methods that you can use to render graphics inside the canvas element.  The context can be 2d or webgl (3d).
Each canvas element can only have one context.  If we use the getContext() method multiple times, it will return a reference to the same context object.

Wednesday, May 22, 2013

Differences Between HTML4 And HTML5

Now that we've seen how to use some of the newer whiz-bang features of the draft HTML5 standard, it's time to take a few steps back and take a look at some of the other differences between HTML4 and HTML5.

This article is intended to be a useful overview, not an exhaustive reference, but remember that things are still and always changing. You also may want to refer to this document for the actual details of the HTML5 specification itself.

The first thing you should know is that, perhaps for the first time, the development of a language standard is acknowledging the real world. In order to keep file compatibility with the current standard - which is technically HTML 4.01 - the brave decision was made to separate the way the web browser renders files from the way we, as developers, must write them. So the browser, or "user agent", must still process HTML4 constructs like the center element, because there will still be millions of files on the Internet that happen to use it. But we won't be writing any more HTML with center; it's simply being dropped from the language (use CSS instead). This compatibility goes both ways: older browsers can (and will) simply ignore HTML5 code without screwing things up.

No More Frames


This is great news to those of us who slogged through the 1990s. To be exact, the elements frame, frameset, and noframes are being removed from the language, as well as acronym, applet, basefont, big , blink, center , dir, font, isindex, strike , tt and u. All of these can be handled using CSS or other methods.

You'll also have to learn to get along without using tables for layout; while tables themselves are still part of HTML5, they're not intended for placing pixels any more. Here's what the spec says:

"Tables must not be used as layout aids. Historically, some Web authors have misused tables in HTML as a way to control their page layout. This usage is non-conforming, because tools attempting to extract tabular data from such documents would obtain very confusing results."

So all the attributes that let people create those perfectly laid-out, tinted tables are gone, like align, bgcolor, border, cellpadding, cellspacing, height, nowrap, rules, valign, and the big one: width. The mantra: use CSS instead.

I've been trying my best to break it to you slowly, but frankly, all presentational elements are coming out of HTML5. My advice: learn lots more CSS, until you can quote chapter and verse in your sleep.

 

Good News


The good news is that even though this is a big change, it's a change for the better. Browsers of the future (just another month or two!) will become more powerful because of the move towards the cloud, so that they'll be able to handle more on their own. We've already seen that with things like Ajax, and now with video/audio embedding and such, it will be far easier for us to code in a straight forward manner and let the browser figure out the details. For instance, new structure elements include article, aside, figcaption, figure, footer, header, hgroup, nav, section, and summary, all of which refer to the structure of the document itself and leave rendering to the browser.

There are still some new elements that deal with text on a detailed level, however: you'll code wbr when you think it's possible to do a line break, but the browser will decide for you. Another hint element is bdi, used to mark an area where bidirectional text formatting can be done (primarily for mixing left-right and right-left languages in a single document). Its complement, bdo, lets you explicitly override and force a particular directionality. For even more slick internationalization, the elements ruby, rp, and rt are included for ruby annotations, which are meant for pronunciation aids rather than for Ruby On Rails programmers.

The more high-level new elements include things like canvas, meant for specifying an area for drawing a bitmapped graphic on the fly, such as a data graph or game graphic; meter is a placeholder for a numeric measurement of an expected size (and is eerily similar to format in ancient FORTRAN), while progress is its graphical counterpart, to be used where you want a progress bar. Last, but not least, there are the multimedia elements (audio, video, source, embed).

 

Friday, May 17, 2013

HTML5 New Elements

New Elements in HTML5

The internet, and the use of the internet, has changed a lot since HTML 4.01 became a standard in 1999.
Today, several elements in HTML 4.01 are obsolete, never used, or not used the way they were intended. All those elements are removed or re-written in HTML5.
To better handle today's internet use, HTML5 also includes new elements for drawing graphics, adding media content, better page structure, better form handling, and several APIs to drag/drop elements, find Geolocation, include web storage, application cache, web workers, etc.
  • The New Canvas Element

  • New Media Elements

  • New Form Elements

  • New Semantic/Structural Elements

 HTML5 offers new elements for better structure: We will discuss all these elements in next article.

Tuesday, October 25, 2011

Silverlight better than HTML5?

In a recent entry in the Silverlight blog entitled The Future of Silverlight Brad Becker, Director of Product Management, makes the case for Silverlight's superiority.
He points out that:
On the web, the purpose of Silverlight has never been to replace HTML; it's to do the things that HTML (and other technologies) couldn't in a way that was easy for developers to tap into.
There are many Microsoft developers who, once they have understood the Silverlight idea, think that for webapplication Silverlight is a complete solution and HTML is only needed to host the plug-in - and in many ways this is true. If you have taken to Silverlight then there is a very real question of why do you need HTML5?
After paying lip service to HTML5 the blog then goes on to list the features that Silverlight offers. All quite unnecessary in the sense that all you really have to know is that Silverlight delivers .NET into the browser - well perhaps not the full .NET framework but a good chunk of it. So for once a Microsoft advocate perhaps isn't really delivering the hardest possible sell. What hereally should be telling us is that Silverlight gives you desktop development facilities that run in the browser. While you could make the same claims for Flash its desktop credentials are something of an afterthought.
The blog then goes on to claim that Silverlight is fast and efficient and more consistent than HTML5 will be. The point being made is that while Microsoft is creating test suites to ensure that HTML5 and CSS3 works the same on all browsers Silverlight doesn't need such treatment because there is only one Silverlight. Well this is true but it's also because there is only one Silverlight implementation and it isn't open source.
Interestingly one of the more subtle implied criticisms of HTML5 and new standards is their glacial speed of production. The blog points out the Microsoft has delivered four major versions of Silverlight in in half thetime that HTML5 has been under development.
All true but this misses the point - Silverlight needed four revisions to reach the first acceptable version, i.e. Silverlight 4.0. Earlier version were arguably betas and work in progress released to get ahead and test the market.
The real edge that Silverlight has is that not only does itbring desktop development to the web it also provides a single environment that will run on the desktop and perhaps most importantly on Windows Phone 7. If Phone 7 is a success it will drag Silverlight along with it - making it the single most important Microsoft technology since the introduction of .NET.

Java once boasted that it was the language that you could "write once run many" but Silverlight seems to bemanaging to make this claim real without anyone really taking notice. Cross-browser compatibility is excellent and cross-platform support is good with Moonlight on Linux improving all the time.

When you read the blog you have to say that its advocacy of Silverlight is understated in a way that is deferential to HTML5 and industry standards. Microsoft seems to want to avoid upsetting the open source/openstandards community and as a result it can't really push Silverlight as hard as it might - it seems to lack the driveto "go for the jugular".
Yes HTML5 is nice, but it will take time before a significant number of users have browsers that support it. If you can swallow the bitter pill of using a proprietary add-in technology then Silverlight really does a lot more and it does it now.

Silverlight should be causing as much of a stir as HTML5.