Beispiel #1
0
        public GridControl()
        {
            grid.ColumnDefinitions.Add(new ColumnDefinition());
            grid.RowDefinitions.Add(new RowDefinition());
            ContentPanel cell = new ContentPanel();

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

            if (grid != null)
            {
                Actions.DeleteEmptyRowsAndColumns(grid);
            }
        }
Beispiel #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());
        }
Beispiel #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]);
        }
Beispiel #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);
     }
 }
Beispiel #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);
        }
Beispiel #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);
            }
        }