using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; namespace SilverlightApplication1 { public partial class leht3 : UserControl { Random r = new Random(); // KeyValuePair hoidla = new KeyValuePair(); Dictionary hoidla = new Dictionary(); public leht3() { InitializeComponent(); } private void hyppa(object sender, MouseButtonEventArgs e) { Shape kujund = sender as Shape; Canvas.SetLeft(kujund, r.Next(500)); Canvas.SetTop(kujund, r.Next(500)); if (hoidla.ContainsKey(kujund.Name)) { hoidla[kujund.Name]++; } else { hoidla[kujund.Name] = 1; } tekst1.Text = ""; foreach(var nimetus in hoidla.Keys){ tekst1.Text += nimetus + ": " + hoidla[nimetus] + "\n"; } } } }