Exemplo n.º 1
0
        public GridControl()
        {
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            ContentPanel cell = new ContentPanel();

            grid.Children.Add(cell);
        }
Exemplo n.º 2
0
        public static void DeleteEmptyRowsAndColumns(ContentPanel contentPanel)
        {
            DragDropGrid grid = contentPanel.Parent as DragDropGrid;

            if (grid != null)
            {
                Actions.DeleteEmptyRowsAndColumns(grid);
            }
        }
Exemplo n.º 3
0
        public Root()
        {
            this.MinWidth  = 400;
            this.MinHeight = 400;

            contentPanel = new ContentPanel()
            {
                Margin = new Thickness(16)
            };
            this.Children.Add(contentPanel);
            contentPanel.Children.Add(new GridControl());
        }
Exemplo n.º 4
0
        public static void DeleteContentPanelContents(ContentPanel contentPanel)
        {
            DragDropGrid grid = contentPanel.Parent as DragDropGrid;

            if (grid != null)
            {
                int columnIndex = Grid.GetColumn(contentPanel);
                int rowIndex    = Grid.GetRow(contentPanel);
                Actions.RemoveCell(grid, columnIndex, rowIndex);
                return;
            }
            Actions.RemoveElementFromPanel(contentPanel, contentPanel.Children[0]);
        }
Exemplo n.º 5
0
 public static void Delete(Panel panel, FrameworkElement toDelete)
 {
     using (Transaction())
     {
         ContentPanel contentPanel = panel as ContentPanel;
         if (contentPanel != null)
         {
             DeleteContentPanelContents(contentPanel);
             DeleteEmptyRowsAndColumns(contentPanel);
         }
         else
         {
             RemoveElementFromPanel(panel, toDelete);
         }
         Actions.InvalidateLayout(panel);
     }
 }
Exemplo n.º 6
0
        private bool[,] GetOccupancyMatrixExcludingEmptyContentPanels()
        {
            bool[,] matrix = new bool[this.ColumnDefinitions.Count, this.RowDefinitions.Count];

            foreach (FrameworkElement child in this.Children)
            {
                ContentPanel contentPanel = child as ContentPanel;
                if (contentPanel != null && contentPanel.Children.Count == 0)
                {
                    continue;
                }
                int column = Grid.GetColumn(child);
                int row    = Grid.GetRow(child);
                matrix[column, row] = true;
            }
            return(matrix);
        }
Exemplo n.º 7
0
        public void InsertRowDefinitionCore(RowDefinition rowDefinition, int rowIndex)
        {
            foreach (FrameworkElement child in this.Children)
            {
                int childRow = Grid.GetRow(child);
                if (childRow >= rowIndex)
                {
                    Grid.SetRow(child, childRow + 1);
                }
            }

            this.RowDefinitions.Insert(rowIndex, rowDefinition);

            for (int i = 0; i < this.ColumnDefinitions.Count; i++)
            {
                ContentPanel cell = new ContentPanel();
                Grid.SetColumn(cell, i);
                Grid.SetRow(cell, rowIndex);
                this.Children.Add(cell);
            }
        }