using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes; namespace WpfApplication21
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
System.Windows.Threading.DispatcherTimer timer;
public MainWindow()
{
this.InitializeComponent();
// Insert code required on object creation below this point.
}
private void btn1_Click(object sender, System.Windows.RoutedEventArgs e)
{
}
private void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
Rect workArea = SystemParameters.WorkArea;
Window window = sender as Window;
timer = new System.Windows.Threading.DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += new EventHandler(timer_Tick);
this.timer.Start();
//Window.Left = workArea.Width - window.Width;
}
void timer_Tick(object sender, EventArgs e)
{
int sc=DateTime.Now.Second.GetHashCode();
sc = sc*6; // считаем минуты
RotateTransform rotateSC1 =new RotateTransform(sc);
img1.RenderTransform = rotateSC1;
//----------------------------------------------------
int mn=DateTime.Now.Minute.GetHashCode();
mn = mn*6; // считаем минуты
RotateTransform rotateMN1 =new RotateTransform(mn);
img2.RenderTransform = rotateMN1;
//----------------------------------------------------
int cc=DateTime.Now.Hour.GetHashCode();
//cc = cc + (mn/60);
cc = cc*30; // считаем минуты
RotateTransform rotateCC1 =new RotateTransform(cc);
img3.RenderTransform = rotateCC1;
}
}
}
// http://demenev.ucoz.ru/forum/
// где img1,img2,img3 - стрелки часов соответственно, установленные в положении 12 часов