Search This Blog

Saturday, January 21, 2012

HTML5 - Details

The aim of the element is to provide native support for a feature common on the Web—a collapsible box that has a title, and more info or functionality hidden away.

The HTML5 details element can be used to expand the relevant addional information and hide the content when needed. <details> element is accompanied with optional <summary> element. <details> is the wrapper for all the content we want to show and hide, and <summary> contains the summary and title of the section.

Currently, this feature only available on Chrome.

<details>

<summary>My Summary</summary>

<UL>
<LI>Content 1</LI>
<LI>Content 2</LI>
<LI>Content 3</LI>
</UL>

</details>

Tuesday, January 17, 2012

WCF 4.0 new feature - Default Endpoints

WCF 3.x services required at least one endpoint or you'd get an exception.
WCF 4.0 comes with default endpoints. Windows Communication Foundation (WCF) looks at the configured mappings and decides on which binding to use for a particular based address.
If you have defined at least one endpoint, you won't get default endpoints.

WCF defines a default protocol mapping between transport protocol schemes (e.g., http, net.tcp, net.pipe, etc) and the built-in WCF bindings. The default protocol mapping is found in the .NET 4 machine.config.comments file and it looks like this:


<protocolMapping>

    <add scheme="http" binding="basicHttpBinding"/>
    <add scheme="net.tcp" binding="netTcpBinding"/>
    <add scheme="net.pipe" binding="netNamedPipeBinding"/>
    <add scheme="net.msmq" binding="netMsmqBinding"/>
</protocolMapping>

Sunday, January 15, 2012

Code Review Workflow with TFS 2012 and VS 2012

Visual Studio 2012 and Team Foundation Server 2012 introduce the feature called code review workflow and allow developers to request and perform code reviews using Team Explorer. A code review task also behaves as a work item and can be assigned to one or more developers as a review request(s).
The reviewer can accept or decline the review, and respond to any messages or queries associated with the code review, add annotations and more.

Once the code reviewer finished reviewing the code, he can assign it back to the requester. Visual Studio 2012 displays the code by using a “Diff” format, showing the original code and the changes made by the developer requesting the review. This feature enables the reviewer to quickly understand the scope of the changes and work more efficiently.

Saturday, January 14, 2012

HTML5 Feature Support Detection

None of the browsers currently fully supports HTML5. HTML5 browser support timeline for any given browser is also not clear. So, it is vital for HTML5 developers to know whether a specific HTML5 feature is supported on a given client’s browser or not.

Modernizr is a JavaScript library that can be leveraged by developers to detect whether a given HTML5 feature is supported on the client’s browser or not. So, Modernizr can be very useful in developing HTML5 applications.

These are few ways HTML5 developers can use Modernizr in their HTML5 development efforts.

1. Modernizr.[HTML5 feature name] returns true or false for a given HTML5 feature and developers can write program logics accordingly.

<!doctype html>
  <html>
   <head>
     <title>Modernizr Basics</title>
     <script src="scripts/modernizr-2.0.6.min.js"></script>

       <script>

          if (Modernizr.localstorage) {
              // Use Local Storage
          } else {
             // Do not use Local Storage
          }
         </script>

     </head>

  <body>
  </body>
</html>

2. Modernizr.load() allows developers to load different scripts based on whether a given HTML5 feature is supported in the client’s browser or not.


Modernizr.load({

     test: Modernizr.geolocation,
     yep : 'Script1.js',
     nope: 'Script2.js'
});

test: The Modernizr property you want to detect.

yep: The location of the script you want to load if the test succeeds. Use an array for multiple scripts.
nope: The location of the script you want to load if the test fails. Use an array for multiple scripts.
3. Modernizr.[HTML5 feature name]? can be used to implement fallback behavior if the browser does not support given HTML5 feature.
    var audio = new Audio();
    audio.src = Modernizr.audio.ogg ? 'background.ogg' :
    Modernizr.audio.mp3 ? 'background.mp3' :
    'background.m4a';
    audio.play();

Friday, January 13, 2012

Silverlight 5 - Double Click and N-Click Support Edit

Silverlight 5 has introduced the concept of a click count. This works for both the left and right mouse buttons. This can be accomplished by the ClickCount property of the MouseButtonEventArgs class. This property tells you how many times the user has rapidly clicked the mouse button. 

XAML

<Grid x:Name="LayoutRoot" Background="White">
<Rectangle x:Name="ClickRectangle" Height="85" Width="93"
   HorizontalAlignment="Left" VerticalAlignment="Top" Margin="30,40,0,0"
   Stroke="Black" StrokeThickness="1" Fill="#FFE82A2A"
   MouseLeftButtonDown="RectMouseLeftButtonDown" />
</Grid>


C# Source Code

private TimeSpan _clickDelay = TimeSpan.FromMilliseconds(300);
private int _clickCount = 0;
private DispatcherTimer _timer = new DispatcherTimer();

void RectMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
// This code would never allow for a triple click

//if (e.ClickCount == 2)

// MessageBox.Show("Double click!");

//else if (e.ClickCount == 3)

// MessageBox.Show("Triple click!");

_clickCount = e.ClickCount;

    if (e.ClickCount >= 2 && !_timer.IsEnabled)
   {
        // wait to see if we get a triple click
       _timer.Interval = _clickDelay;
       _timer.Tick += TimerTick;
       _timer.Start();
     }
else if (e.ClickCount < 2)
    {
      _timer.Stop();
    }
}
private void TimerTick(object sender, EventArgs e)
{
     _timer.Stop();
    _timer.Tick -= TimerTick;

      if (_clickCount == 2)
      OnRectDoubleClick();
      else if (_clickCount == 3)
      OnRectTripleClick();
}

private void OnRectDoubleClick()
{
    MessageBox.Show("Double Click!");
}

private void OnRectTripleClick()
{
    MessageBox.Show("Triple Click!");
}