Exemplo n.º 1
0
        /// <summary>
        /// move an object from one grid cell to another
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="position"></param>
        void MoveObject(LayoutToLayoutHost obj, int position)
        {
            int max = gridSize * gridSize - 1;

            if (position > max)
            {
                position = max;
            }
            if (position < 0)
            {
                position = 0;
            }

            //obj.BeginAnimating(false);
            Grid.SetRow(obj.Target, position / gridSize);
            Grid.SetColumn(obj.Target, position % gridSize);
        }
Exemplo n.º 2
0
        void OnLoad(object sender, RoutedEventArgs e)
        {
            Application app = System.Windows.Application.Current;

            Panels.Add(LTLGrid);
            Panels.Add(LTLGrid2);
            Panels.Add(LTLStackPanel);
            Panels.Add(LTLWrapPanel);

            //Debug.WriteLine("Grid children: " + ButtonGrid.Children.Count);

            for (int i = 0; i < numItems; i++)
            {
                LayoutToLayoutTarget target = new LayoutToLayoutTarget();
                Targets.Add(target);
                target.Margin          = new Thickness(5);
                target.MinWidth        = 80; target.MinHeight = 50;
                target.BorderThickness = new Thickness(0);

                Grid.SetRow(target, i / 5);
                Grid.SetColumn(target, i % 5);
                LTLGrid.Children.Add(target);

                LayoutToLayoutHost host = new LayoutToLayoutHost();
                Hosts.Add(host);
                host.BorderThickness = new Thickness(0);

                Button demoButton = new Button();
                demoButton.Content = "# " + i;
                demoButton.Click  += OnAdvanceClick;
                host.Child         = demoButton;

                Canvas.SetLeft(host, 0); Canvas.SetTop(host, 0);
                LTLCanvas.Children.Add(host);

                host.BindToTarget(target);
            }
        }