using System.Windows.Threading; public partial class MainPage : UserControl { int x = 0; public MainPage() { InitializeComponent(); System.Windows.Threading.DispatcherTimer kell = new System.Windows.Threading.DispatcherTimer(); kell.Interval = new TimeSpan(0, 0, 0, 0, 100); // 100 Milliseconds kell.Tick += new EventHandler(tiks); kell.Start(); } public void tiks(object o, EventArgs saatja) { x++; Canvas.SetLeft(ruut1, x); } } Rectangle r1 = new Rectangle(); r1.Fill = new SolidColorBrush(Colors.Blue); r1.Width = 50; r1.Height = 30; juur.Children.Add(r1); Canvas.SetLeft(r1, x); Canvas.SetTop(r1, 200); juur.UpdateLayout(); public void tiks(object o, EventArgs saatja) { x++; Canvas.SetLeft(ruut1, x); Rectangle r1 = new Rectangle(); r1.Fill = new SolidColorBrush(Colors.Blue); r1.Width = 50; r1.Height = 30; juur.Children.Add(r1); Canvas.SetLeft(r1, x); Canvas.SetTop(r1, new Random().Next(100)); juur.UpdateLayout(); r1.MouseLeftButtonDown+=new MouseButtonEventHandler(hiir_alla); } private void hiir_alla(object saatja, MouseButtonEventArgs e) { ((Rectangle)saatja).Fill = new SolidColorBrush(Colors.Green); } void klient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) { //MessageBox.Show(new StreamReader(e.Result).ReadToEnd()); plokk1.Text = new StreamReader(e.Result).ReadToEnd(); } void andmed_kohal(object saatja, UploadStringCompletedEventArgs e) { if (e.Error != null) MessageBox.Show(e.Error.Message); MessageBox.Show(e.Result); } private void nupp1_Click(object sender, RoutedEventArgs e) { WebClient klient = new WebClient(); //klient.UploadStringCompleted += new UploadStringCompletedEventHandler(andmed_kohal); // klient.UploadStringAsync(new Uri("http://localhost:4525/tervitaja.aspx?eesnimi=Kalle"),""); klient.OpenReadAsync(new Uri("http://localhost:4525/tervitaja.aspx?eesnimi="+tekst1.Text)); klient.OpenReadCompleted += new OpenReadCompletedEventHandler(klient_OpenReadCompleted); } BitmapImage bi = new BitmapImage(new Uri("http://localhost:4525/pilt1.png")); p1.Source = bi; Canvas.SetTop(p1, 300); juur.Children.Add(p1);