示例#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));
     }
 }
示例#2
0
        public void CreateComplexItem(double x, double y)
        {
            Rectangle backgroundItem = m_builder.CreateBackgroundItem() as Rectangle;
            Rectangle foregroundItem = m_builder.CreateForegroundItem() as Rectangle;

            RectItemAdapter backgroundAdapter = new RectItemAdapter(backgroundItem);

            backgroundAdapter.X = x;
            backgroundAdapter.Y = y;

            RectItemAdapter foregroundAdapter = new RectItemAdapter(foregroundItem);

            foregroundAdapter.X = x + 50;
            foregroundAdapter.Y = y + 50;

            m_result = new List <UIElement>();
            m_result.Add(backgroundItem);
            m_result.Add(foregroundItem);
        }