Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
BRH 48
#DOTNET 34
#ASP.NET 29
jQuery 22
ASP.NET 20
.NET 20
WPF 9
jquery interview questions 9
jquery faq 8
ASP.NET4 8

Archive · View All
February 2011 10
September 2011 4
August 2011 4
July 2011 4
May 2011 4
April 2011 4
March 2011 4
October 2011 4
June 2011 4
January 2011 4

Sliverlight5 – ClickCount (Multiple Click) on left and right mouse button

Apr 18 2011 11:01AM by Hima   

The ClickCount concept was introduced in silverlight5 . This makes support for multi-click input on left and right mouse button . This makes our life easy to implement features like double click or triple click . The ClickCount property  is available on MouseButtonEventArgs class. This property is used to count number of clicks for mouse left or right button.Now SL5 does the job for us and makes easy , we do not need to capture or fire events separately for double click or triple click. So now let us see how to implement it in action

First we need to have Silverlight5 tools for VS2010 Sp1 from here .

Once you download tools and install ,  Create New Silverlight web project .

 XAML Code

<UserControl xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  x:Class="SilverlightApplication2.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">

    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
            <ColumnDefinition Width="auto" />
        </Grid.ColumnDefinitions>
        
        <Grid.RowDefinitions>
            <RowDefinition  Height="auto"></RowDefinition>
            <RowDefinition  Height="auto"></RowDefinition>
            <RowDefinition  Height="auto"></RowDefinition>
        </Grid.RowDefinitions>
        
        <Rectangle Grid.Column="0"  Margin="10" Height="100" Width="100" Fill="Red" MouseLeftButtonDown="Border_MouseLeftButtonDown"></Rectangle>

        <ComboBox x:Name="cboInsert"   
            Grid.Column ="1"  Margin="1" Height="20" Width="123">
         </ComboBox>
        <Button x:Name="btnReset" Margin="1" Grid.Row="2" Click="btnReset_Click" >Reset</Button>
        <TextBlock x:Name="txtBlock" Grid.Column="3" Height="123" Width="100">Hima</TextBlock>
    </Grid>
</UserControl>

Implementing Multiple Click

It is such simple  and easy to  implement, here is the code for that.

public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }
        
       
        private void btnReset_Click(object sender, RoutedEventArgs e)
        {
           cboInsert.Items.Clear();
           txtBlock.Text = "";
        }

        
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            cboInsert.Items.Add(e.ClickCount);

            if (e.ClickCount == 0)
            {
                txtBlock.Text = "Nothing is clicked";
            }

            else if (e.ClickCount == 1)
            {
                txtBlock.Text = "Single Click";
            }

            else if (e.ClickCount == 2)
            {
                txtBlock.Text = "Double Click";
            }
            else if (e.ClickCount == 3)
            {
                txtBlock.Text = "Triple Click";
            }
            else
            {
               txtBlock.Text = "Clicked " + e.ClickCount + " times";
               // MessageBox.Show("Clicked " + e.ClickCount + " times");
            }
        }
    }

Output

Click on the rectangle using Mouse , the following output displays when we click on it 7 times.

clickcount

I just added textbclock to show the clicked items, reset button to reset items in dropdown and text block . The code is self explanatory , e.ClickCount gets the count of mouse left button click. So now  we can write what ever so the logic once the event get captured.

Note

There is no limit for the click. you can try clicking slowly and fast by playing with it.

This is mainly useful in Gaming, 3D, Music , Specialized programs .

These are the events supported MouseLeftButtonDown, MouseLeftButtonUp, MouseRightButtonDown, MouseRightButtonUp

Tags: BRH, Silverlight5, new features of silverlight5, mouseleftbutton down, clickcount,


Hima
31 · 6% · 1776
0
Liked
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

1  Comments  

  • http://beyondrelational.com/blogs/hima/archive/2011/04/14/what-s-new-in-silverlight5.aspx

    commented on Apr 19 2011 2:59AM
    Hima
    31 · 6% · 1776

Your Comment


Sign Up or Login to post a comment.

    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]