Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Creating an application like Google Desktop in WPF and C#

, 28 Jul 2011
This article explains how to create an application like Google Desktop in WPF.
<UserControl x:Class="Appbar.Clock"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" d:DesignHeight="200" d:DesignWidth="200"
             Loaded="UserControl_Loaded">
    <Grid>
        <!-- Rows -->
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        
        <!-- Main circle -->
        <Ellipse Grid.RowSpan="8" Fill="LightGray" Stroke="Gray" />

        <!-- Markers -->
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="0" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="30" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="60" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="90" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="120" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="150" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="180" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="210" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="240" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="270" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="300" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,2">
            <Rectangle.RenderTransform>
                <RotateTransform Angle="330" />
            </Rectangle.RenderTransform>
        </Rectangle>
        
        <!-- Ellipse for hiding part of markers -->
        <Ellipse Grid.RowSpan="2" Fill="LightGray" Margin="10" />

        <!-- Clockwises -->
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,50">
            <Rectangle.RenderTransform>
                <RotateTransform x:Name="hour" Angle="-180" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Black" Margin="0,0,0,30">
            <Rectangle.RenderTransform>
                <RotateTransform x:Name="minute" Angle="-180" />
            </Rectangle.RenderTransform>
        </Rectangle>
        <Rectangle Grid.Row="1" Width="1" Fill="Gray" Margin="0,0,0,4">
            <Rectangle.RenderTransform>
                <RotateTransform x:Name="second" Angle="-180" />
            </Rectangle.RenderTransform>
        </Rectangle>

        <!-- Fixing clockwises -->
        <Ellipse Grid.RowSpan="2" Fill="Gray" Width="5" Height="5" />
    </Grid>
</UserControl>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

TeapotDev

Poland Poland

My homepage
Follow on   Twitter

| Advertise | Privacy | Mobile
Web02 | 2.8.140827.1 | Last Updated 28 Jul 2011
Article Copyright 2011 by TeapotDev
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid