private void FixRectangles(TableSplitConfiguration configuration) { var cells = new bool[configuration.Rows, configuration.Columns]; var list = new List <Rectangle>(configuration.Rectangles); configuration.Rectangles.RemoveAll(x => list.Where(y => y != x).Any(y => y.IntersectsWith(x))); foreach (var r in configuration.Rectangles.ToList()) { if (r.X < 0 || r.X + r.Width > configuration.Columns || r.Y < 0 || r.Y + r.Height > configuration.Rows) { configuration.Rectangles.Remove(r); continue; } for (var i = r.X; i < r.X + r.Width; i++) { for (var j = r.Y; j < r.Y + r.Height; j++) { cells[j, i] = true; } } } for (var i = 0; i < cells.GetLength(0); i++) { for (var j = 0; j < cells.GetLength(1); j++) { if (!cells[i, j]) { configuration.Rectangles.Add(new Rectangle(j, i, 1, 1)); } } } }
private void RemoveInvalidCells(MapDocumentContainer container, TableSplitConfiguration config) { var recs = config.Rectangles.ToList(); foreach (var control in container.Table.Controls.OfType <Control>().ToList()) { var pos = container.Table.GetPositionFromControl(control); var mdc = container.MapDocumentControls.FirstOrDefault(x => x.Control.Control == control); if (recs.Any(x => x.X == pos.Column && x.Y == pos.Row)) { continue; } container.Table.Controls.Remove(control); if (mdc == null) { continue; } container.MapDocumentControls.Remove(mdc); mdc.Control.Control.Dispose(); } }
public ViewportWindow(TableSplitConfiguration configuration) { InitializeComponent(); SplitControl.Configuration = configuration; }
private void FixRectangles(TableSplitConfiguration configuration) { var cells = new bool[configuration.Rows, configuration.Columns]; var list = new List<Rectangle>(configuration.Rectangles); configuration.Rectangles.RemoveAll(x => list.Where(y => y != x).Any(y => y.IntersectsWith(x))); foreach (var r in configuration.Rectangles.ToList()) { if (r.X < 0 || r.X + r.Width > configuration.Columns || r.Y < 0 || r.Y + r.Height > configuration.Rows) { configuration.Rectangles.Remove(r); continue; } for (var i = r.X; i < r.X + r.Width; i++) { for (var j = r.Y; j < r.Y + r.Height; j++) { cells[j, i] = true; } } } for (var i = 0; i < cells.GetLength(0); i++) { for (var j = 0; j < cells.GetLength(1); j++) { if (!cells[i,j]) configuration.Rectangles.Add(new Rectangle(j, i, 1, 1)); } } }