Exemplo n.º 1
0
 private void create_click(object sender, RoutedEventArgs e)
 {
     CreateDialog dialog = new CreateDialog();
     dialog.Owner = this;
     dialog.ShowDialog();
     var items = dialog.Elements;
     Random randomGenerator = new Random();
     foreach(var item in items)
     {
         grid.Children.Add(item);
         Rectangle rectElement = item as Rectangle;
         RectItemAdapter adapter = new RectItemAdapter(rectElement);
         adapter.X = randomGenerator.Next(0, (int)(Width - 100));
         adapter.Y = randomGenerator.Next(0, (int)(Height - 100));
     }
 }
Exemplo n.º 2
0
        private void create_click(object sender, RoutedEventArgs e)
        {
            CreateDialog dialog = new CreateDialog();

            dialog.Owner = this;
            dialog.ShowDialog();
            var    items           = dialog.Elements;
            Random randomGenerator = new Random();

            foreach (var item in items)
            {
                grid.Children.Add(item);
                Rectangle rectElement = item as Rectangle;
                Thickness margin      = rectElement.Margin;
                margin.Left        = randomGenerator.Next(0, (int)(Width - 100));
                margin.Top         = randomGenerator.Next(0, (int)(Height - 100));
                rectElement.Margin = margin;
            }
        }