begin process at 2010 02 10 04:01:01
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

WPF

 > CHRONOMÈTRE EN WPF

CHRONOMÈTRE EN WPF


 Information sur la source

Note :
9,5 / 10 - par 2 personnes
9,50 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :WPF Source .NET ( DotNet ) Classé sous :WPF, chronomètre, DateTime, timespan, xaml Niveau :Débutant Date de création :29/05/2008 Date de mise à jour :30/05/2008 15:52:14 Vu / téléchargé :8 389 / 383

Auteur : poiuytrez3

Ecrire un message privé
Site perso
Commentaire sur cette source (5)
Ajouter un commentaire et/ou une note

 Description

Cliquez pour voir la capture en taille normale
Petit Chronomètre réalisé en WPF. En fait c'est la copie conforme de celui que j'ai en vrai!
Compilé avec Visual Studio 2008 et réalisé partiellement avec Expression Blend.

Source

  • /////////////////////////////////////////////////////////////////////////
  • // MyChono.cs
  • /////////////////////////////////////////////////////////////////////////
  • using System;
  • using System.Collections.Generic;
  • using System.Text;
  • namespace Chronometre
  • {
  • public class MyChrono
  • {
  • int centiSeconds;
  • int seconds;
  • int minutes;
  • int hours;
  • DateTime dateStarted;
  • DateTime datePaused;
  • bool paused;
  • private bool isLaunched; // True when timer launched
  • public MyChrono()
  • {
  • centiSeconds = 0;
  • seconds = 0;
  • minutes = 0;
  • hours = 0;
  • isLaunched = false;
  • paused = false;
  • }
  • public void Start()
  • {
  • isLaunched = true;
  • // If the chrono has been paused
  • if (paused == true)
  • {
  • // Resume
  • TimeSpan t = DateTime.Now.Subtract(datePaused);
  • dateStarted = dateStarted.Add(t);
  • }
  • // Else : not been paused
  • else
  • dateStarted = DateTime.Now;
  • }
  • public void Stop()
  • {
  • isLaunched = false;
  • datePaused = DateTime.Now;
  • paused = true;
  • }
  • public void Reset()
  • {
  • isLaunched = false;
  • paused = false;
  • dateStarted = DateTime.Now;
  • datePaused = DateTime.Now;
  • }
  • public bool isChronoLaunched
  • {
  • get //get accessor method
  • {
  • return isLaunched;
  • }
  • }
  • public override String ToString()
  • {
  • DateTime DateNow = DateTime.Now;
  • TimeSpan Difference = DateNow - dateStarted;
  • StringBuilder builder = new StringBuilder(11);
  • builder.Append(Difference.Hours.ToString("d2"));
  • builder.Append(":");
  • builder.Append(Difference.Minutes.ToString("d2"));
  • builder.Append(":");
  • builder.Append(Difference.Seconds.ToString("d2"));
  • builder.Append(":");
  • builder.Append((Difference.Milliseconds.ToString("d2")).Substring(0,2));
  • return builder.ToString();
  • }
  • public String Now()
  • {
  • DateTime dateNow = DateTime.Now;
  • StringBuilder builder = new StringBuilder(8);
  • builder.Append(dateNow.Hour.ToString("d2"));
  • builder.Append(":");
  • builder.Append(dateNow.Minute.ToString("d2"));
  • builder.Append(":");
  • builder.Append(dateNow.Second.ToString("d2"));
  • return builder.ToString();
  • }
  • }
  • }
  • /////////////////////////////////////////////////////////////////////////
  • // Window1.xaml.cs
  • /////////////////////////////////////////////////////////////////////////
  • using System;
  • using System.IO;
  • using System.Net;
  • using System.Windows;
  • using System.Windows.Controls;
  • using System.Windows.Data;
  • using System.Windows.Media;
  • using System.Windows.Media.Animation;
  • using System.Windows.Navigation;
  • using System.Windows.Threading;
  • namespace Chronometre
  • {
  • public partial class Window1
  • {
  • enum Modes { timer, clock }
  • int mode; // Mode
  • DispatcherTimer dispatcherTimer;
  • DispatcherTimer clockTimer;
  • MyChrono chrono;
  • public Window1()
  • {
  • this.InitializeComponent();
  • // Insert code required on object creation below this point.
  • mode = (int)Modes.timer;
  • // Setup the timer
  • dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
  • dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
  • dispatcherTimer.Interval = new TimeSpan(0,0,0,0,10);
  • clockTimer = new System.Windows.Threading.DispatcherTimer();
  • clockTimer.Tick += new EventHandler(clockTimer_Tick);
  • clockTimer.Interval = new TimeSpan(0, 0, 1);
  • clockTimer.Start();
  • chrono = new MyChrono();
  • }
  • private void clockTimer_Tick(object sender, EventArgs e)
  • {
  • lblClockDisplay.Content = chrono.Now();
  • }
  • // When the timer tick
  • private void dispatcherTimer_Tick(object sender, EventArgs e)
  • {
  • lblTime.Content = chrono.ToString();
  • }
  • // When the mode button is clicked
  • private void btnMode_Click(object sender, RoutedEventArgs e)
  • {
  • // Set all the mode's labels ton unvisible
  • lblTimer.Visibility = Visibility.Hidden;
  • lblPeacer.Visibility = Visibility.Hidden;
  • lblClock.Visibility = Visibility.Hidden;
  • lblTime.Visibility = Visibility.Hidden;
  • lblPeacerDisplay.Visibility = Visibility.Hidden;
  • lblClockDisplay.Visibility = Visibility.Hidden;
  • // Increment
  • mode++;
  • mode = mode%2;
  • // Set if the labels are visible or not
  • Console.WriteLine("le mode : " + mode);
  • if (mode == (int)Modes.timer)
  • {
  • lblTimer.Visibility = Visibility.Visible;
  • lblTime.Visibility = Visibility.Visible;
  • }
  • /*else if (mode == (int)Modes.peacer)
  • {
  • lblPeacer.Visibility = Visibility.Visible;
  • lblPeacerDisplay.Visibility = Visibility.Visible;
  • }*/
  • else if (mode == (int)Modes.clock)
  • {
  • lblClock.Visibility = Visibility.Visible;
  • lblClockDisplay.Visibility = Visibility.Visible;
  • }
  • }
  • private void BtnClose_Click(object sender, RoutedEventArgs e)
  • {
  • this.Close();
  • }
  • private void BtnStartStop_Click(object sender, RoutedEventArgs e)
  • {
  • if (mode == (int)Modes.timer)
  • {
  • if (!chrono.isChronoLaunched)
  • {
  • chrono.Start();
  • dispatcherTimer.Start();
  • }
  • else
  • {
  • chrono.Stop();
  • dispatcherTimer.Stop();
  • }
  • }
  • }
  • private void BtnReset_Click(object sender, RoutedEventArgs e)
  • {
  • if (mode == (int)Modes.timer)
  • {
  • chrono.Stop();
  • chrono.Reset();
  • dispatcherTimer.Stop();
  • lblTime.Content = "00:00:00:00";
  • }
  • }
  • private void DragChrono(object sender, System.Windows.Input.MouseButtonEventArgs e)
  • {
  • this.DragMove();
  • }
  • }
  • }
  • ////////////////////////////////////////////////////////////////////////////////////////////
  • // Window1.xaml
  • ////////////////////////////////////////////////////////////////////////////////////////////<Window
  • xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  • xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  • x:Class="Chronometre.Window1"
  • x:Name="Window"
  • Title="Chronomètre"
  • Width="640" Height="480" AllowsTransparency="True" WindowStyle="None" Background="{x:Null}">
  • <Window.Resources>
  • <Storyboard x:Key="OnClick1"/>
  • <Style x:Key="ButtonFocusVisual">
  • <Setter Property="Control.Template">
  • <Setter.Value>
  • <ControlTemplate>
  • <Rectangle SnapsToDevicePixels="true" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="2"/>
  • </ControlTemplate>
  • </Setter.Value>
  • </Setter>
  • </Style>
  • <LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
  • <GradientStop Color="#F3F3F3" Offset="0"/>
  • <GradientStop Color="#EBEBEB" Offset="0.5"/>
  • <GradientStop Color="#DDDDDD" Offset="0.5"/>
  • <GradientStop Color="#CDCDCD" Offset="1"/>
  • </LinearGradientBrush>
  • <SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
  • <Style x:Key="ButtonChrono" TargetType="{x:Type Button}">
  • <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
  • <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
  • <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
  • <Setter Property="BorderThickness" Value="1"/>
  • <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  • <Setter Property="HorizontalContentAlignment" Value="Center"/>
  • <Setter Property="VerticalContentAlignment" Value="Center"/>
  • <Setter Property="Padding" Value="1"/>
  • <Setter Property="Template">
  • <Setter.Value>
  • <ControlTemplate TargetType="{x:Type Button}">
  • <ControlTemplate.Resources>
  • <Storyboard x:Key="OnClick1">
  • <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
  • <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFE38E19"/>
  • <SplineColorKeyFrame KeyTime="00:00:00.3000000" Value="sc#1, 0.283148736, 0.768151164, 0.009721218"/>
  • <SplineColorKeyFrame KeyTime="00:00:01" Value="#FFE38E19"/>
  • </ColorAnimationUsingKeyFrames>
  • <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
  • <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFD06C"/>
  • <SplineColorKeyFrame KeyTime="00:00:00.3000000" Value="sc#1, 0.806952238, 0.9559733, 0.610495567"/>
  • <SplineColorKeyFrame KeyTime="00:00:01" Value="#FFFFD06C"/>
  • </ColorAnimationUsingKeyFrames>
  • <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
  • <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
  • <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="4"/>
  • <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/>
  • </DoubleAnimationUsingKeyFrames>
  • <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="1x" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Offset)" Storyboard.TargetName="ellipse">
  • <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
  • <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/>
  • </DoubleAnimationUsingKeyFrames>
  • <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Offset)" Storyboard.TargetName="ellipse">
  • <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
  • <SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
  • </DoubleAnimationUsingKeyFrames>
  • </Storyboard>
  • <Storyboard x:Key="clignote">
  • <ColorAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
  • <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
  • <SplineColorKeyFrame KeyTime="00:00:01" Value="#FF39FF00"/>
  • <SplineColorKeyFrame KeyTime="00:00:02" Value="#FF000000"/>
  • </ColorAnimationUsingKeyFrames>
  • <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Shape.StrokeThickness)">
  • <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
  • <SplineDoubleKeyFrame KeyTime="00:00:01" Value="2"/>
  • <SplineDoubleKeyFrame KeyTime="00:00:02" Value="1"/>
  • </DoubleAnimationUsingKeyFrames>
  • </Storyboard>
  • </ControlTemplate.Resources>
  • <Grid Width="67.5" Height="44">
  • <Ellipse RenderTransformOrigin="0.5,0.5" Stroke="#FF000000" Margin="0,0,0,0" x:Name="ellipse">
  • <Ellipse.RenderTransform>
  • <TransformGroup>
  • <ScaleTransform ScaleX="1" ScaleY="1"/>
  • <SkewTransform AngleX="0" AngleY="0"/>
  • <RotateTransform Angle="0"/>
  • <TranslateTransform X="0" Y="0"/>
  • </TransformGroup>
  • </Ellipse.RenderTransform>
  • <Ellipse.Fill>
  • <RadialGradientBrush>
  • <GradientStop Color="#FFFFD06C" Offset="0"/>
  • <GradientStop Color="#FFE38E19" Offset="1"/>
  • </RadialGradientBrush>
  • </Ellipse.Fill>
  • </Ellipse>
  • </Grid>
  • <ControlTemplate.Triggers>
  • <Trigger Property="IsMouseOver" Value="True">
  • <Trigger.EnterActions>
  • <BeginStoryboard x:Name="clignote_BeginStoryboard" Storyboard="{StaticResource clignote}"/>
  • </Trigger.EnterActions>
  • <Trigger.ExitActions>
  • <StopStoryboard BeginStoryboardName="clignote_BeginStoryboard"/>
  • </Trigger.ExitActions>
  • </Trigger>
  • <EventTrigger RoutedEvent="FrameworkElement.Loaded"/>
  • <Trigger Property="IsKeyboardFocused" Value="true"/>
  • <Trigger Property="ToggleButton.IsChecked" Value="true"/>
  • <Trigger Property="IsEnabled" Value="false">
  • <Setter Property="Foreground" Value="#ADADAD"/>
  • </Trigger>
  • <Trigger Property="IsPressed" Value="True">
  • <Trigger.EnterActions>
  • <BeginStoryboard x:Name="OnClick1_BeginStoryboard" Storyboard="{StaticResource OnClick1}"/>
  • </Trigger.EnterActions>
  • </Trigger>
  • </ControlTemplate.Triggers>
  • </ControlTemplate>
  • </Setter.Value>
  • </Setter>
  • </Style>
  • <Style x:Key="ModeButton" TargetType="{x:Type Button}">
  • <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
  • <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
  • <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
  • <Setter Property="BorderThickness" Value="1"/>
  • <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  • <Setter Property="HorizontalContentAlignment" Value="Center"/>
  • <Setter Property="VerticalContentAlignment" Value="Center"/>
  • <Setter Property="Padding" Value="1"/>
  • <Setter Property="Template">
  • <Setter.Value>
  • <ControlTemplate TargetType="{x:Type Button}">
  • <ControlTemplate.Resources>
  • <Storyboard x:Key="Timeline1">
  • <ColorAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
  • <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
  • <SplineColorKeyFrame KeyTime="00:00:01" Value="#FF39FF00"/>
  • <SplineColorKeyFrame KeyTime="00:00:02" Value="#FF000000"/>
  • </ColorAnimationUsingKeyFrames>
  • </Storyboard>
  • <Storyboard x:Key="OnClick">
  • <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
  • <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFE38E19"/>
  • <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FF91E319"/>
  • <SplineColorKeyFrame KeyTime="00:00:01" Value="#FFE38E19"/>
  • </ColorAnimationUsingKeyFrames>
  • <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Offset)">
  • <SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
  • <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
  • <SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
  • </DoubleAnimationUsingKeyFrames>
  • <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
  • <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
  • <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
  • <SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/>
  • </DoubleAnimationUsingKeyFrames>
  • <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
  • <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFD06C"/>
  • <SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FFFFF76C"/>
  • <SplineColorKeyFrame KeyTime="00:00:01" Value="#FFFFD06C"/>
  • </ColorAnimationUsingKeyFrames>
  • </Storyboard>
  • </ControlTemplate.Resources>
  • <Grid>
  • <Path Stretch="Fill" Stroke="#FF000000" Margin="1.768,-2.49,2.261,-0.5" x:Name="path" VerticalAlignment="Stretch" Height="Auto" Data="M7.667056,-0.16723592 L54.331773,-0.16778772 C54.331773,-0.16778772 57.331558,0.4993614 63.331674,-1.8343669 69.451225,-4.2145487 59.332635,21.171333 53.999371,23.838667 48.666107,26.506 34.66602,27.1732 28.666148,23.17216 28.666148,23.17216 14.33354,16.170131 6.333711,9.1683588 6.333711,9.1683588 1.6667451,7.1679536 2.3333975,2.8335234 3.00005,-1.5009067 7.667056,-0.16723592 7.667056,-0.16723592 z">
  • <Path.Fill>
  • <RadialGradientBrush>
  • <GradientStop Color="#FFFFD06C" Offset="0"/>
  • <GradientStop Color="#FFE38E19" Offset="1"/>
  • </RadialGradientBrush>
  • </Path.Fill>
  • </Path>
  • </Grid>
  • <ControlTemplate.Triggers>
  • <Trigger Property="IsMouseOver" Value="True">
  • <Trigger.EnterActions>
  • <BeginStoryboard x:Name="Timeline1_BeginStoryboard" Storyboard="{StaticResource Timeline1}"/>
  • </Trigger.EnterActions>
  • <Trigger.ExitActions>
  • <StopStoryboard BeginStoryboardName="Timeline1_BeginStoryboard"/>
  • </Trigger.ExitActions>
  • </Trigger>
  • <Trigger Property="IsKeyboardFocused" Value="true"/>
  • <Trigger Property="ToggleButton.IsChecked" Value="true"/>
  • <Trigger Property="IsEnabled" Value="false">
  • <Setter Property="Foreground" Value="#ADADAD"/>
  • </Trigger>
  • <Trigger Property="IsPressed" Value="True">
  • <Trigger.EnterActions>
  • <BeginStoryboard x:Name="OnClick_BeginStoryboard" Storyboard="{StaticResource OnClick}"/>
  • </Trigger.EnterActions>
  • </Trigger>
  • </ControlTemplate.Triggers>
  • </ControlTemplate>
  • </Setter.Value>
  • </Setter>
  • </Style>
  • <FontFamily x:Key="FontChrono">Humnst777 Lt BT</FontFamily>
  • </Window.Resources>
  • <Window.Triggers>
  • <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="BtnStop"/>
  • <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="BtnReset"/>
  • <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="btnMode"/>
  • <EventTrigger RoutedEvent="ButtonBase.Click" SourceName="BtnClose"/>
  • </Window.Triggers>
  • <Grid>
  • <Button RenderTransformOrigin="0.5,0.5" x:Name="BtnStop" Style="{DynamicResource ButtonChrono}" Height="43.305" Content="Button" HorizontalAlignment="Right" Margin="0,59.705,169.111,0" VerticalAlignment="Top" Width="72.451" Click="BtnStartStop_Click">
  • <Button.RenderTransform>
  • <TransformGroup>
  • <ScaleTransform ScaleX="1" ScaleY="1"/>
  • <SkewTransform AngleX="0" AngleY="0"/>
  • <RotateTransform Angle="44.745"/>
  • <TranslateTransform X="0" Y="0"/>
  • </TransformGroup>
  • </Button.RenderTransform>
  • </Button>
  • <Button RenderTransformOrigin="0.5,0.5" x:Name="BtnClose" Style="{DynamicResource ButtonChrono}" Height="43.305" Content="Button" Margin="274.438,19.038,293.111,0" VerticalAlignment="Top" Click="BtnClose_Click">
  • <Button.RenderTransform>
  • <TransformGroup>
  • <ScaleTransform ScaleX="1" ScaleY="1"/>
  • <SkewTransform AngleX="0" AngleY="0"/>
  • <RotateTransform Angle="0"/>
  • <TranslateTransform X="0" Y="0"/>
  • </TransformGroup>
  • </Button.RenderTransform>
  • </Button>
  • <Button RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" Margin="146.437,61.705,0,0" x:Name="BtnReset" Style="{DynamicResource ButtonChrono}" VerticalAlignment="Top" Width="72.451" Height="43.305" Content="Button" Click="BtnReset_Click">
  • <Button.RenderTransform>
  • <TransformGroup>
  • <ScaleTransform ScaleX="1" ScaleY="1"/>
  • <SkewTransform AngleX="0" AngleY="0"/>
  • <RotateTransform Angle="-46.887"/>
  • <TranslateTransform X="0" Y="0"/>
  • </TransformGroup>
  • </Button.RenderTransform>
  • </Button>
  • <Path Stretch="Fill" Stroke="#FF000000" Margin="134.797,36.574,156.323,8" x:Name="Coque" Data="F1 M171.953,376.332 C161.04538,376.332 152.203,385.17438 152.203,396.082 152.203,406.98962 161.04538,415.832 171.953,415.832 182.86063,415.832 191.703,406.98962 191.703,396.082 191.703,385.17438 182.86063,376.332 171.953,376.332 z M160.8188,0.51317179 C172.70158,0.65379781 178.703,0.83199362 178.703,0.83199372 178.891,0.81008102 289.82605,-10.859599 330.06485,89.443733 369.20163,186.99997 333.44241,336.59485 333.44241,336.59485 323.12469,362.75375 305.88052,431.35153 180.58833,434.17569 33.588947,444.67569 15.349137,325.70868 15.349136,325.70868 15.286747,325.48871 -20.762596,198.27933 19.702114,90.372581 50.076893,9.372551 125.17045,0.091297753 160.8188,0.51317179 z">
  • <Path.Fill>
  • <RadialGradientBrush>
  • <GradientStop Color="#FF827A7A" Offset="1"/>
  • <GradientStop Color="#FFF0F0F0" Offset="0.024"/>
  • </RadialGradientBrush>
  • </Path.Fill>
  • </Path>
  • <Path Stretch="Fill" Stroke="#FF000000" Margin="164.582,73.99,185.867,176.5" x:Name="TourGeonaute" Data="M220.5,300 L406.5,301.5 C406.5,301.5 444.00038,300 444.00038,265.5 444.00038,231 448.5,219 433.5,159 418.5,99 307.31189,106.98749 307.31189,106.98749 307.31189,106.98749 214.49999,99.000432 194.99996,151.50032 175.49992,204.00021 182.99975,267 182.99975,267 182.99975,267 187.50008,300 220.5,300 z">
  • <Path.Fill>
  • <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
  • <GradientStop Color="#FFECD27F" Offset="0.986"/>
  • <GradientStop Color="#FFE38B14" Offset="0"/>
  • </LinearGradientBrush>
  • </Path.Fill>
  • </Path>
  • <Button HorizontalAlignment="Right" Margin="0,0,207.667,146.5" Style="{DynamicResource ModeButton}" VerticalAlignment="Bottom" Width="68" Height="26" Content="Button" x:Name="btnMode" Click="btnMode_Click" />
  • <TextBlock RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" Margin="163.414,79.927,0,0" x:Name="txtReset" VerticalAlignment="Top" Width="57" Height="21.53" Text="reset" TextAlignment="Center" TextWrapping="Wrap">
  • <TextBlock.RenderTransform>
  • <TransformGroup>
  • <ScaleTransform ScaleX="1" ScaleY="1"/>
  • <SkewTransform AngleX="0" AngleY="0"/>
  • <RotateTransform Angle="-48.444"/>
  • <TranslateTransform X="0" Y="0"/>
  • </TransformGroup>
  • </TextBlock.RenderTransform>
  • </TextBlock>
  • <TextBlock RenderTransformOrigin="0.5,0.5" x:Name="txtClose" Height="21.53" Text="close" TextAlignment="Center" TextWrapping="Wrap" Margin="281.414,40.927,301.586,0" VerticalAlignment="Top">
  • <TextBlock.RenderTransform>
  • <TransformGroup>
  • <ScaleTransform ScaleX="1" ScaleY="1"/>
  • <SkewTransform AngleX="0" AngleY="0"/>
  • <RotateTransform Angle="0"/>
  • <TranslateTransform X="0" Y="0"/>
  • </TransformGroup>
  • </TextBlock.RenderTransform>
  • </TextBlock>
  • <TextBlock RenderTransformOrigin="0.5,0.5" x:Name="txtStart" Width="57" Height="21.53" Text="start | stop" TextAlignment="Center" TextWrapping="Wrap" HorizontalAlignment="Right" Margin="0,79.927,188.586,0" VerticalAlignment="Top">
  • <TextBlock.RenderTransform>
  • <TransformGroup>
  • <ScaleTransform ScaleX="1" ScaleY="1"/>
  • <SkewTransform AngleX="0" AngleY="0"/>
  • <RotateTransform Angle="44.312"/>
  • <TranslateTransform X="0" Y="0"/>
  • </TransformGroup>
  • </TextBlock.RenderTransform>
  • </TextBlock>
  • <Rectangle Fill="#FFFFFFFF" Stroke="#FF000000" RadiusX="6.5" RadiusY="6.5" Margin="194,139,220,223"/>
  • <Grid Margin="194,139,220,223">
  • <Label Margin="8,8,8,16" Content="00:00:00:00" FontFamily="{DynamicResource FontChrono}" FontSize="36" FontWeight="Normal" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="lblTime" />
  • <Label Margin="8,8,8,16" Content="30" FontFamily="{DynamicResource FontChrono}" FontSize="36" FontWeight="Normal" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="lblPeacerDisplay" Visibility="Hidden" />
  • <Label Margin="8,8,8,16" Content="00:00:00" FontFamily="{DynamicResource FontChrono}" FontSize="36" FontWeight="Normal" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="lblClockDisplay" Visibility="Hidden" />
  • <Label HorizontalAlignment="Left" Margin="34.664,0,0,-5.332" x:Name="lblTimer" VerticalAlignment="Bottom" Width="37.333" Height="25.334" Content="TIMER" FontFamily="{DynamicResource FontChrono}" FontSize="8"/>
  • <Label x:Name="lblPeacer" Height="25.334" Content="PEACER" FontFamily="{DynamicResource FontChrono}" FontSize="8" Visibility="Hidden" Margin="89.997,0,98.67,-5.332" VerticalAlignment="Bottom"/>
  • <Label x:Name="lblClock" Height="25.334" Content="CLOCK" FontFamily="{DynamicResource FontChrono}" FontSize="8" Visibility="Hidden" HorizontalAlignment="Right" Margin="0,0,40.004,-5.332" VerticalAlignment="Bottom" Width="37.333"/>
  • </Grid>
  • <TextBlock RenderTransformOrigin="0.5,0.5" x:Name="lblMode" Text="mode" TextAlignment="Center" TextWrapping="Wrap" HorizontalAlignment="Right" Margin="0,0,240.667,172.5" VerticalAlignment="Bottom" Width="35" Height="21.53" Foreground="#FF615C5C">
  • <TextBlock.RenderTransform>
  • <TransformGroup>
  • <ScaleTransform ScaleX="1" ScaleY="1"/>
  • <SkewTransform AngleX="0" AngleY="0"/>
  • <RotateTransform Angle="0"/>
  • <TranslateTransform X="0" Y="0"/>
  • </TransformGroup>
  • </TextBlock.RenderTransform>
  • </TextBlock>
  • <Path Fill="#FF827A7A" Stretch="Fill" Stroke="{x:Null}" HorizontalAlignment="Right" Margin="0,0,231.833,180.833" VerticalAlignment="Bottom" Width="7.334" Height="6" Data="M401.33333,294 L407.66701,293.66667 404.66684,298.67148 z"/>
  • <Label Margin="193.998,92,226.002,0" VerticalAlignment="Top" Height="43" Content="Chronomètre" FontFamily="{DynamicResource FontChrono}" FontSize="24" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
  • <Grid Margin="248.666,0,273.333,84.667" VerticalAlignment="Bottom" Height="43.333">
  • <Label HorizontalAlignment="Left" Margin="8,15.333,0,8" x:Name="lblModele" Width="27.334" Content="mtd" FontFamily="{DynamicResource FontChrono}" FontSize="10"/>
  • <Label Margin="28.667,14,32.001,1.333" x:Name="lblModele2" Content="5 O O" FontFamily="{DynamicResource FontChrono}" FontSize="18"/>
  • <Ellipse Fill="{x:Null}" Stroke="#FFE38E19" StrokeThickness="3" Margin="45.334,20,52.667,3.333" x:Name="ellPetitChrono"/>
  • <Ellipse Fill="#FFE38E19" Stroke="#FFE38E19" StrokeThickness="3" HorizontalAlignment="Left" Margin="44.498,21.499,0,17.667" Width="4.333"/>
  • <Ellipse Fill="#FFE38E19" Stroke="#FFE38E19" StrokeThickness="3" Width="4.333" HorizontalAlignment="Left" Margin="52.831,17.499,0,0" VerticalAlignment="Top" Height="4.167"/>
  • <Ellipse Fill="#FFE38E19" Stroke="#FFE38E19" StrokeThickness="3" HorizontalAlignment="Right" Margin="0,21.499,52.504,17.667" Width="4.333"/>
  • </Grid>
  • </Grid>
  • </Window>
/////////////////////////////////////////////////////////////////////////
// MyChono.cs
/////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Text;

namespace Chronometre
{

    public class MyChrono
    {
        int centiSeconds;
        int seconds;
        int minutes;
        int hours;
        DateTime dateStarted;
        DateTime datePaused;
        bool paused;
        private bool isLaunched;        // True when timer launched

        public MyChrono()
        {
            
            centiSeconds = 0;
            seconds = 0;
            minutes = 0;
            hours = 0;
            isLaunched = false;
            paused = false;
        }

        public void Start()
        {
            isLaunched = true;

            // If the chrono has been paused
            if (paused == true)
            {
                // Resume
                TimeSpan t = DateTime.Now.Subtract(datePaused);
                dateStarted = dateStarted.Add(t);
            }
            // Else : not been paused
            else
                dateStarted = DateTime.Now;

 
        }

        public void Stop()
        {
            isLaunched = false;
            datePaused = DateTime.Now;
            paused = true;
        }

        public void Reset()
        {
            isLaunched = false;
            paused = false;
            dateStarted = DateTime.Now;
            datePaused = DateTime.Now;

        }

        public bool isChronoLaunched
        {
            get  //get accessor method
            {
                return isLaunched;
            }
            
        }


        public override String ToString()
        {
   

            DateTime DateNow = DateTime.Now;
            TimeSpan Difference = DateNow - dateStarted;

            StringBuilder builder = new StringBuilder(11);
            builder.Append(Difference.Hours.ToString("d2"));
            builder.Append(":");
            builder.Append(Difference.Minutes.ToString("d2"));
            builder.Append(":");
            builder.Append(Difference.Seconds.ToString("d2"));
            builder.Append(":");
            builder.Append((Difference.Milliseconds.ToString("d2")).Substring(0,2));

            return builder.ToString();
        }

        public String Now()
        {
            DateTime dateNow = DateTime.Now;
            StringBuilder builder = new StringBuilder(8);
            builder.Append(dateNow.Hour.ToString("d2"));
            builder.Append(":");
            builder.Append(dateNow.Minute.ToString("d2"));
            builder.Append(":");
            builder.Append(dateNow.Second.ToString("d2"));

            return builder.ToString();
        }
    }
}
/////////////////////////////////////////////////////////////////////////
// Window1.xaml.cs
/////////////////////////////////////////////////////////////////////////


using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Threading;

namespace Chronometre
{
	public partial class Window1
	{
        enum Modes { timer, clock }
        int mode;       // Mode
        DispatcherTimer dispatcherTimer;
        DispatcherTimer clockTimer;
        MyChrono chrono;

		public Window1()
		{
			this.InitializeComponent();
			
			// Insert code required on object creation below this point.
            mode = (int)Modes.timer;

            // Setup the timer
            dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0,0,0,0,10);

            clockTimer = new System.Windows.Threading.DispatcherTimer();
            clockTimer.Tick += new EventHandler(clockTimer_Tick);
            clockTimer.Interval = new TimeSpan(0, 0, 1);
            clockTimer.Start();


            chrono = new MyChrono();

		}

        private void clockTimer_Tick(object sender, EventArgs e)
        {
            lblClockDisplay.Content = chrono.Now();
        }

        // When the timer tick
        private void dispatcherTimer_Tick(object sender, EventArgs e)
        {
            lblTime.Content = chrono.ToString();

            

            


        }


        // When the mode button is clicked
        private void btnMode_Click(object sender, RoutedEventArgs e)
        {
            // Set all the mode's labels ton unvisible
            lblTimer.Visibility = Visibility.Hidden;
            lblPeacer.Visibility = Visibility.Hidden;
            lblClock.Visibility = Visibility.Hidden;
            
            

            lblTime.Visibility = Visibility.Hidden;
            lblPeacerDisplay.Visibility = Visibility.Hidden;
            lblClockDisplay.Visibility = Visibility.Hidden;

            // Increment
            mode++;
            mode = mode%2;

            // Set if the labels are visible or not
            Console.WriteLine("le mode : " + mode);
            if (mode == (int)Modes.timer)
            {
                lblTimer.Visibility = Visibility.Visible;
                lblTime.Visibility = Visibility.Visible;
            }
            /*else if (mode == (int)Modes.peacer)
            {
                lblPeacer.Visibility = Visibility.Visible;
                lblPeacerDisplay.Visibility = Visibility.Visible;
            }*/
            else if (mode == (int)Modes.clock)
            {
                lblClock.Visibility = Visibility.Visible;
                lblClockDisplay.Visibility = Visibility.Visible;
            }
        }

        private void BtnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void BtnStartStop_Click(object sender, RoutedEventArgs e)
        {
            if (mode == (int)Modes.timer)
            {
                if (!chrono.isChronoLaunched)
                {

                    chrono.Start();
                    dispatcherTimer.Start();

                }
                else
                {
                    chrono.Stop();
                    dispatcherTimer.Stop();


                }
            }

        }

        private void BtnReset_Click(object sender, RoutedEventArgs e)
        {
            if (mode == (int)Modes.timer)
            {
                chrono.Stop();
                chrono.Reset();
                dispatcherTimer.Stop();
                lblTime.Content = "00:00:00:00";
            }
        }

        private void DragChrono(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            this.DragMove();
        }

 


	}
}

////////////////////////////////////////////////////////////////////////////////////////////
// Window1.xaml
////////////////////////////////////////////////////////////////////////////////////////////<Window
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	x:Class="Chronometre.Window1"
	x:Name="Window"
	Title="Chronomètre"
	Width="640" Height="480" AllowsTransparency="True" WindowStyle="None" Background="{x:Null}">

	<Window.Resources>
		<Storyboard x:Key="OnClick1"/>
		<Style x:Key="ButtonFocusVisual">
			<Setter Property="Control.Template">
				<Setter.Value>
					<ControlTemplate>
						<Rectangle SnapsToDevicePixels="true" Stroke="Black" StrokeDashArray="1 2" StrokeThickness="1" Margin="2"/>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
			<GradientStop Color="#F3F3F3" Offset="0"/>
			<GradientStop Color="#EBEBEB" Offset="0.5"/>
			<GradientStop Color="#DDDDDD" Offset="0.5"/>
			<GradientStop Color="#CDCDCD" Offset="1"/>
		</LinearGradientBrush>
		<SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
		<Style x:Key="ButtonChrono" TargetType="{x:Type Button}">
			<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
			<Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
			<Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
			<Setter Property="BorderThickness" Value="1"/>
			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
			<Setter Property="HorizontalContentAlignment" Value="Center"/>
			<Setter Property="VerticalContentAlignment" Value="Center"/>
			<Setter Property="Padding" Value="1"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Button}">
						<ControlTemplate.Resources>
							<Storyboard x:Key="OnClick1">
								<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
									<SplineColorKeyFrame KeyTime="00:00:00" Value="#FFE38E19"/>
									<SplineColorKeyFrame KeyTime="00:00:00.3000000" Value="sc#1, 0.283148736, 0.768151164, 0.009721218"/>
									<SplineColorKeyFrame KeyTime="00:00:01" Value="#FFE38E19"/>
								</ColorAnimationUsingKeyFrames>
								<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
									<SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFD06C"/>
									<SplineColorKeyFrame KeyTime="00:00:00.3000000" Value="sc#1, 0.806952238, 0.9559733, 0.610495567"/>
									<SplineColorKeyFrame KeyTime="00:00:01" Value="#FFFFD06C"/>
								</ColorAnimationUsingKeyFrames>
								<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
									<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
									<SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="4"/>
									<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/>
								</DoubleAnimationUsingKeyFrames>
								<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="1x" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Offset)" Storyboard.TargetName="ellipse">
									<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
									<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/>
								</DoubleAnimationUsingKeyFrames>
								<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Offset)" Storyboard.TargetName="ellipse">
									<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
									<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
								</DoubleAnimationUsingKeyFrames>
							</Storyboard>
							<Storyboard x:Key="clignote">
								<ColorAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
									<SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
									<SplineColorKeyFrame KeyTime="00:00:01" Value="#FF39FF00"/>
									<SplineColorKeyFrame KeyTime="00:00:02" Value="#FF000000"/>
								</ColorAnimationUsingKeyFrames>
								<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(Shape.StrokeThickness)">
									<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
									<SplineDoubleKeyFrame KeyTime="00:00:01" Value="2"/>
									<SplineDoubleKeyFrame KeyTime="00:00:02" Value="1"/>
								</DoubleAnimationUsingKeyFrames>
							</Storyboard>
						</ControlTemplate.Resources>
						<Grid Width="67.5" Height="44">
							<Ellipse RenderTransformOrigin="0.5,0.5" Stroke="#FF000000" Margin="0,0,0,0" x:Name="ellipse">
								<Ellipse.RenderTransform>
									<TransformGroup>
										<ScaleTransform ScaleX="1" ScaleY="1"/>
										<SkewTransform AngleX="0" AngleY="0"/>
										<RotateTransform Angle="0"/>
										<TranslateTransform X="0" Y="0"/>
									</TransformGroup>
								</Ellipse.RenderTransform>
								<Ellipse.Fill>
									<RadialGradientBrush>
										<GradientStop Color="#FFFFD06C" Offset="0"/>
										<GradientStop Color="#FFE38E19" Offset="1"/>
									</RadialGradientBrush>
								</Ellipse.Fill>
							</Ellipse>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsMouseOver" Value="True">
								<Trigger.EnterActions>
									<BeginStoryboard x:Name="clignote_BeginStoryboard" Storyboard="{StaticResource clignote}"/>
								</Trigger.EnterActions>
								<Trigger.ExitActions>
									<StopStoryboard BeginStoryboardName="clignote_BeginStoryboard"/>
								</Trigger.ExitActions>
							</Trigger>
							<EventTrigger RoutedEvent="FrameworkElement.Loaded"/>
							<Trigger Property="IsKeyboardFocused" Value="true"/>
							<Trigger Property="ToggleButton.IsChecked" Value="true"/>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground" Value="#ADADAD"/>
							</Trigger>
							<Trigger Property="IsPressed" Value="True">
								<Trigger.EnterActions>
									<BeginStoryboard x:Name="OnClick1_BeginStoryboard" Storyboard="{StaticResource OnClick1}"/>
								</Trigger.EnterActions>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<Style x:Key="ModeButton" TargetType="{x:Type Button}">
			<Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
			<Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
			<Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
			<Setter Property="BorderThickness" Value="1"/>
			<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
			<Setter Property="HorizontalContentAlignment" Value="Center"/>
			<Setter Property="VerticalContentAlignment" Value="Center"/>
			<Setter Property="Padding" Value="1"/>
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Button}">
						<ControlTemplate.Resources>
							<Storyboard x:Key="Timeline1">
								<ColorAnimationUsingKeyFrames BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Stroke).(SolidColorBrush.Color)">
									<SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
									<SplineColorKeyFrame KeyTime="00:00:01" Value="#FF39FF00"/>
									<SplineColorKeyFrame KeyTime="00:00:02" Value="#FF000000"/>
								</ColorAnimationUsingKeyFrames>
							</Storyboard>
							<Storyboard x:Key="OnClick">
								<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
									<SplineColorKeyFrame KeyTime="00:00:00" Value="#FFE38E19"/>
									<SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FF91E319"/>
									<SplineColorKeyFrame KeyTime="00:00:01" Value="#FFE38E19"/>
								</ColorAnimationUsingKeyFrames>
								<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[1].(GradientStop.Offset)">
									<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
									<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/>
									<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
								</DoubleAnimationUsingKeyFrames>
								<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
									<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
									<SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
									<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0"/>
								</DoubleAnimationUsingKeyFrames>
								<ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="path" Storyboard.TargetProperty="(Shape.Fill).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
									<SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFFD06C"/>
									<SplineColorKeyFrame KeyTime="00:00:00.2000000" Value="#FFFFF76C"/>
									<SplineColorKeyFrame KeyTime="00:00:01" Value="#FFFFD06C"/>
								</ColorAnimationUsingKeyFrames>
							</Storyboard>
						</ControlTemplate.Resources>
						<Grid>
							<Path Stretch="Fill" Stroke="#FF000000" Margin="1.768,-2.49,2.261,-0.5" x:Name="path" VerticalAlignment="Stretch" Height="Auto" Data="M7.667056,-0.16723592 L54.331773,-0.16778772 C54.331773,-0.16778772 57.331558,0.4993614 63.331674,-1.8343669 69.451225,-4.2145487 59.332635,21.171333 53.999371,23.838667 48.666107,26.506 34.66602,27.1732 28.666148,23.17216 28.666148,23.17216 14.33354,16.170131 6.333711,9.1683588 6.333711,9.1683588 1.6667451,7.1679536 2.3333975,2.8335234 3.00005,-1.5009067 7.667056,-0.16723592 7.667056,-0.16723592 z">
								<Path.Fill>
									<RadialGradientBrush>
										<GradientStop Color="#FFFFD06C" Offset="0"/>
										<GradientStop Color="#FFE38E19" Offset="1"/>
									</RadialGradientBrush>
								</Path.Fill>
							</Path>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsMouseOver" Value="True">
								<Trigger.EnterActions>
									<BeginStoryboard x:Name="Timeline1_BeginStoryboard" Storyboard="{StaticResource Timeline1}"/>
								</Trigger.EnterActions>
								<Trigger.ExitActions>
									<StopStoryboard BeginStoryboardName="Timeline1_BeginStoryboard"/>
								</Trigger.ExitActions>
							</Trigger>
							<Trigger Property="IsKeyboardFocused" Value="true"/>
							<Trigger Property="ToggleButton.IsChecked" Value="true"/>
							<Trigger Property="IsEnabled" Value="false">
								<Setter Property="Foreground" Value="#ADADAD"/>
							</Trigger>
							<Trigger Property="IsPressed" Value="True">
								<Trigger.EnterActions>
									<BeginStoryboard x:Name="OnClick_BeginStoryboard" Storyboard="{StaticResource OnClick}"/>
								</Trigger.EnterActions>
							</Trigger>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
		<FontFamily x:Key="FontChrono">Humnst777 Lt BT</FontFamily>
	</Window.Resources>
	<Window.Triggers>
		<EventTrigger RoutedEvent="ButtonBase.Click" SourceName="BtnStop"/>
		<EventTrigger RoutedEvent="ButtonBase.Click" SourceName="BtnReset"/>
		<EventTrigger RoutedEvent="ButtonBase.Click" SourceName="btnMode"/>
		<EventTrigger RoutedEvent="ButtonBase.Click" SourceName="BtnClose"/>
	</Window.Triggers>
	<Grid>
		<Button RenderTransformOrigin="0.5,0.5" x:Name="BtnStop" Style="{DynamicResource ButtonChrono}" Height="43.305" Content="Button" HorizontalAlignment="Right" Margin="0,59.705,169.111,0" VerticalAlignment="Top" Width="72.451" Click="BtnStartStop_Click">
			<Button.RenderTransform>
				<TransformGroup>
					<ScaleTransform ScaleX="1" ScaleY="1"/>
					<SkewTransform AngleX="0" AngleY="0"/>
					<RotateTransform Angle="44.745"/>
					<TranslateTransform X="0" Y="0"/>
				</TransformGroup>
			</Button.RenderTransform>
		</Button>
		<Button RenderTransformOrigin="0.5,0.5" x:Name="BtnClose" Style="{DynamicResource ButtonChrono}" Height="43.305" Content="Button" Margin="274.438,19.038,293.111,0" VerticalAlignment="Top" Click="BtnClose_Click">
			<Button.RenderTransform>
				<TransformGroup>
					<ScaleTransform ScaleX="1" ScaleY="1"/>
					<SkewTransform AngleX="0" AngleY="0"/>
					<RotateTransform Angle="0"/>
					<TranslateTransform X="0" Y="0"/>
				</TransformGroup>
			</Button.RenderTransform>
		</Button>
		<Button RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" Margin="146.437,61.705,0,0" x:Name="BtnReset" Style="{DynamicResource ButtonChrono}" VerticalAlignment="Top" Width="72.451" Height="43.305" Content="Button" Click="BtnReset_Click">
			<Button.RenderTransform>
				<TransformGroup>
					<ScaleTransform ScaleX="1" ScaleY="1"/>
					<SkewTransform AngleX="0" AngleY="0"/>
					<RotateTransform Angle="-46.887"/>
					<TranslateTransform X="0" Y="0"/>
				</TransformGroup>
			</Button.RenderTransform>
		</Button>
		<Path Stretch="Fill" Stroke="#FF000000" Margin="134.797,36.574,156.323,8" x:Name="Coque" Data="F1 M171.953,376.332 C161.04538,376.332 152.203,385.17438 152.203,396.082 152.203,406.98962 161.04538,415.832 171.953,415.832 182.86063,415.832 191.703,406.98962 191.703,396.082 191.703,385.17438 182.86063,376.332 171.953,376.332 z M160.8188,0.51317179 C172.70158,0.65379781 178.703,0.83199362 178.703,0.83199372 178.891,0.81008102 289.82605,-10.859599 330.06485,89.443733 369.20163,186.99997 333.44241,336.59485 333.44241,336.59485 323.12469,362.75375 305.88052,431.35153 180.58833,434.17569 33.588947,444.67569 15.349137,325.70868 15.349136,325.70868 15.286747,325.48871 -20.762596,198.27933 19.702114,90.372581 50.076893,9.372551 125.17045,0.091297753 160.8188,0.51317179 z">
			<Path.Fill>
				<RadialGradientBrush>
					<GradientStop Color="#FF827A7A" Offset="1"/>
					<GradientStop Color="#FFF0F0F0" Offset="0.024"/>
				</RadialGradientBrush>
			</Path.Fill>
		</Path>
		<Path Stretch="Fill" Stroke="#FF000000" Margin="164.582,73.99,185.867,176.5" x:Name="TourGeonaute" Data="M220.5,300 L406.5,301.5 C406.5,301.5 444.00038,300 444.00038,265.5 444.00038,231 448.5,219 433.5,159 418.5,99 307.31189,106.98749 307.31189,106.98749 307.31189,106.98749 214.49999,99.000432 194.99996,151.50032 175.49992,204.00021 182.99975,267 182.99975,267 182.99975,267 187.50008,300 220.5,300 z">
			<Path.Fill>
				<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
					<GradientStop Color="#FFECD27F" Offset="0.986"/>
					<GradientStop Color="#FFE38B14" Offset="0"/>
				</LinearGradientBrush>
			</Path.Fill>
		</Path>
		<Button HorizontalAlignment="Right" Margin="0,0,207.667,146.5" Style="{DynamicResource ModeButton}" VerticalAlignment="Bottom" Width="68" Height="26" Content="Button" x:Name="btnMode" Click="btnMode_Click" />
		<TextBlock RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" Margin="163.414,79.927,0,0" x:Name="txtReset" VerticalAlignment="Top" Width="57" Height="21.53" Text="reset" TextAlignment="Center" TextWrapping="Wrap">
			<TextBlock.RenderTransform>
				<TransformGroup>
					<ScaleTransform ScaleX="1" ScaleY="1"/>
					<SkewTransform AngleX="0" AngleY="0"/>
					<RotateTransform Angle="-48.444"/>
					<TranslateTransform X="0" Y="0"/>
				</TransformGroup>
			</TextBlock.RenderTransform>
		</TextBlock>
		<TextBlock RenderTransformOrigin="0.5,0.5" x:Name="txtClose" Height="21.53" Text="close" TextAlignment="Center" TextWrapping="Wrap" Margin="281.414,40.927,301.586,0" VerticalAlignment="Top">
			<TextBlock.RenderTransform>
				<TransformGroup>
					<ScaleTransform ScaleX="1" ScaleY="1"/>
					<SkewTransform AngleX="0" AngleY="0"/>
					<RotateTransform Angle="0"/>
					<TranslateTransform X="0" Y="0"/>
				</TransformGroup>
			</TextBlock.RenderTransform>
		</TextBlock>
		<TextBlock RenderTransformOrigin="0.5,0.5" x:Name="txtStart" Width="57" Height="21.53" Text="start | stop" TextAlignment="Center" TextWrapping="Wrap" HorizontalAlignment="Right" Margin="0,79.927,188.586,0" VerticalAlignment="Top">
			<TextBlock.RenderTransform>
				<TransformGroup>
					<ScaleTransform ScaleX="1" ScaleY="1"/>
					<SkewTransform AngleX="0" AngleY="0"/>
					<RotateTransform Angle="44.312"/>
					<TranslateTransform X="0" Y="0"/>
				</TransformGroup>
			</TextBlock.RenderTransform>
		</TextBlock>
		<Rectangle Fill="#FFFFFFFF" Stroke="#FF000000" RadiusX="6.5" RadiusY="6.5" Margin="194,139,220,223"/>
		<Grid Margin="194,139,220,223">
			<Label Margin="8,8,8,16" Content="00:00:00:00" FontFamily="{DynamicResource FontChrono}" FontSize="36" FontWeight="Normal" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="lblTime" />
            <Label Margin="8,8,8,16" Content="30" FontFamily="{DynamicResource FontChrono}" FontSize="36" FontWeight="Normal" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="lblPeacerDisplay" Visibility="Hidden" />
            <Label Margin="8,8,8,16" Content="00:00:00" FontFamily="{DynamicResource FontChrono}" FontSize="36" FontWeight="Normal" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Name="lblClockDisplay" Visibility="Hidden" />
            <Label HorizontalAlignment="Left" Margin="34.664,0,0,-5.332" x:Name="lblTimer" VerticalAlignment="Bottom" Width="37.333" Height="25.334" Content="TIMER" FontFamily="{DynamicResource FontChrono}" FontSize="8"/>
			<Label x:Name="lblPeacer" Height="25.334" Content="PEACER" FontFamily="{DynamicResource FontChrono}" FontSize="8" Visibility="Hidden" Margin="89.997,0,98.67,-5.332" VerticalAlignment="Bottom"/>
			<Label x:Name="lblClock" Height="25.334" Content="CLOCK" FontFamily="{DynamicResource FontChrono}" FontSize="8" Visibility="Hidden" HorizontalAlignment="Right" Margin="0,0,40.004,-5.332" VerticalAlignment="Bottom" Width="37.333"/>
		</Grid>
		<TextBlock RenderTransformOrigin="0.5,0.5" x:Name="lblMode" Text="mode" TextAlignment="Center" TextWrapping="Wrap" HorizontalAlignment="Right" Margin="0,0,240.667,172.5" VerticalAlignment="Bottom" Width="35" Height="21.53" Foreground="#FF615C5C">
			<TextBlock.RenderTransform>
				<TransformGroup>
					<ScaleTransform ScaleX="1" ScaleY="1"/>
					<SkewTransform AngleX="0" AngleY="0"/>
					<RotateTransform Angle="0"/>
					<TranslateTransform X="0" Y="0"/>
				</TransformGroup>
			</TextBlock.RenderTransform>
		</TextBlock>
		<Path Fill="#FF827A7A" Stretch="Fill" Stroke="{x:Null}" HorizontalAlignment="Right" Margin="0,0,231.833,180.833" VerticalAlignment="Bottom" Width="7.334" Height="6" Data="M401.33333,294 L407.66701,293.66667 404.66684,298.67148 z"/>
		<Label Margin="193.998,92,226.002,0" VerticalAlignment="Top" Height="43" Content="Chronomètre" FontFamily="{DynamicResource FontChrono}" FontSize="24" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/>
		<Grid Margin="248.666,0,273.333,84.667" VerticalAlignment="Bottom" Height="43.333">
			<Label HorizontalAlignment="Left" Margin="8,15.333,0,8" x:Name="lblModele" Width="27.334" Content="mtd" FontFamily="{DynamicResource FontChrono}" FontSize="10"/>
			<Label Margin="28.667,14,32.001,1.333" x:Name="lblModele2" Content="5 O O" FontFamily="{DynamicResource FontChrono}" FontSize="18"/>
			<Ellipse Fill="{x:Null}" Stroke="#FFE38E19" StrokeThickness="3" Margin="45.334,20,52.667,3.333" x:Name="ellPetitChrono"/>
			<Ellipse Fill="#FFE38E19" Stroke="#FFE38E19" StrokeThickness="3" HorizontalAlignment="Left" Margin="44.498,21.499,0,17.667" Width="4.333"/>
			<Ellipse Fill="#FFE38E19" Stroke="#FFE38E19" StrokeThickness="3" Width="4.333" HorizontalAlignment="Left" Margin="52.831,17.499,0,0" VerticalAlignment="Top" Height="4.167"/>
			<Ellipse Fill="#FFE38E19" Stroke="#FFE38E19" StrokeThickness="3" HorizontalAlignment="Right" Margin="0,21.499,52.504,17.667" Width="4.333"/>
		</Grid>
	</Grid>
</Window>

 Conclusion

Le bouton fermer se situe en haut du Chronomètre


 Fichier Zip

Les Membres Club peuvent télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !

Télécharger le zip


 Historique

30 mai 2008 15:52:15 :
Ajout du déplacement (Drag)

 Sources du même auteur

Source avec Zip Source avec une capture Source .NET (Dotnet) PUISSANCE 4

 Sources de la même categorie

Source .NET (Dotnet) WPF MOVENEXT ET MOVEPREVIOUS par muffin516
Source avec Zip Source avec une capture Source .NET (Dotnet) ROBOT À DESSINER par Warny
Source avec Zip Source avec une capture Source .NET (Dotnet) [WPF .NET 3.5] USER CONTROL INFO BOX par Kite37
Source avec Zip Source avec une capture Source .NET (Dotnet) [C# .NET 3.5 WPF] SLIDER CIRCULAIRE par Kite37
Source avec Zip Source avec une capture Source .NET (Dotnet) SERVICES WINDOWS par thebestdrummer

 Sources en rapport avec celle ci

Source avec Zip Source .NET (Dotnet) CODE SOURCE DE L'ARTICLE "WPF : 10 BONNES RAISONS DE CHOISIR... par odahan
Source avec Zip Source avec une capture Source .NET (Dotnet) TETRIS WPF par max12
Source avec Zip Source avec une capture Source .NET (Dotnet) CUBE-IT: PETIT JEU EN WPF par Bidou
Source avec Zip Source avec une capture Source .NET (Dotnet) PETIT EXEMPLE UTILISANT XAML ET WPF par Bidou
Source avec Zip Source .NET (Dotnet) LECTEUR AUDIO WPF par herve_labenere

Commentaires et avis

Commentaire de UNi le 02/06/2008 09:08:01 9/10

Rien que pour l'interface, si tu l'a fais avec expression blend tu m?rite un 10 ! LoL le code est sympa manque juste des commentaires !

Commentaire de poiuytrez3 le 02/06/2008 13:52:56

Merci.

En effet, l'interface est faite avec blend! Tu veux que je mette plus de commentaires sur le C# ? Je m'en occupe dans la semaine. Pour le xaml, je ne sais pas si c'est n?c?ssaire vu que tu peux ouvrir le projet avec blend.

poiuytrez

Commentaire de xXTitouffXx le 20/07/2008 15:07:52 10/10

Je trouve l'interface su-per-be ! Génial ! Mais le code m'a l'air un peu chargé, non ? J'en ai fait un, il m'a suffit de lui dire d'ajouter +1 aux valeurs à chaque tick, et il marche. Mais, le défaut : Les millièmes sont un peu lentes...

Commentaire de xXTitouffXx le 20/07/2008 15:09:14

J'ai d'ailleurs fait un chrono-compte à rebours.

Commentaire de poiuytrez3 le 20/07/2008 19:46:27

Merci ! Mais le +1 au tick n'est pas terrible même si c'est la solution la plus simple, tu perds 1 seconde toute les 5 secondes...........

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

problème du chargement de la première forme WPF [ par ralf9 ] Salut ! j'aimerais commencer a faire du WPF en utilisant C# et Expression Blend 2 ! et déjà ça me décourage vraiment ! Voila, a chaque fois que je dé [Xaml]WPF ItemsSources et ItemTemplate without ListBox [ par Theridion1 ] Bonjour,Pour illustrer mon soucis je part sur le Sample suivant :http://msdn.microsoft.com/en-us/library/system.windows.documents.tablecell.aspx &lt;! nom du jour de la semaine datetime format [ par olibara ] BonjourPour construire une chaine date "20081111" a partir d"un datetime, je faisDateTime.Now.ToString("yyyyMMdd");Mais comment faire si je veux avoir Problème lors de la détection de mes Addin-in (System.Addin) [ par teddyalbina ] Bonjour j'ai un soucis avec System.Addin qui ne détecte pas mes addins. Cela fait plusieurs jours que je cherche une solution mais je sèche donc voici Probème de détection AddIn incompréhensible [ par teddyalbina ] Bonjour,J'ai posté il a plusieurs jours un message concernant mes problèmes avec System.AddIn. Après avoir retourné et lu 50 fois mon code je n'ai rie Probléme de Date [ par floflo69290 ] Bonjour,Je viens de reprendre une application en C# et j'ai un soucis :Je récupére les valeurs du jour, mois et année avec des string et je voudrais r Drag and Drop entre deux treeview WPF c# [ par onizuka29 ] Bonjour, je voudrais faire une application WPF en C# avec deux treeviews, un contenant l'explorateur du poste et l'autre celui du serveur.Le problème DATETIME à null [ par Fo0Zie ] Bonjour à tous,J'ai une txtBoxDate, qui contient une date qui peut-être null.J'utilise SQL Server 2005 pour ma BdD, mon date dans ma table est au form WPF - value dans un combobox [ par wally88 ] Bonjour, Comment ajouter les valeurs dans une collection d'item d'un combobox en wpf.Avec un dataset j'y arrive, mais en "dur" on ne peut pas ?Merci. Caroussel3D en WPF bindé avec une liste d'objet [ par poiuytrez3 ] Bonjour,Je cherche à faire un carroussel 3D en WPF, ou plutôt utiliser un carroussel existant et le binder avec une list d'objet.J'ai beaucoup de mal,


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,608 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales