diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs index 012c37466e..ee004ae6c4 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/GridEditor.xaml.cs @@ -558,22 +558,23 @@ namespace FancyZonesEditor Settings settings = ((App)Application.Current).ZoneSettings; - int spacing = settings.ShowSpacing ? settings.Spacing : 0; + int spacing, gutter; + spacing = gutter = settings.ShowSpacing ? settings.Spacing : 0; int cols = model.Columns; int rows = model.Rows; - double totalWidth = arrangeSize.Width - (spacing * (cols + 1)); - double totalHeight = arrangeSize.Height - (spacing * (rows + 1)); + double totalWidth = arrangeSize.Width - (gutter * 2) - (spacing * (cols - 1)); + double totalHeight = arrangeSize.Height - (gutter * 2) - (spacing * (rows - 1)); - double top = spacing; + double top = gutter; for (int row = 0; row < rows; row++) { double cellHeight = _rowInfo[row].Recalculate(top, totalHeight); top += cellHeight + spacing; } - double left = spacing; + double left = gutter; for (int col = 0; col < cols; col++) { double cellWidth = _colInfo[col].Recalculate(left, totalWidth); diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/GridZone.xaml b/src/modules/fancyzones/editor/FancyZonesEditor/GridZone.xaml index 5473f5ff1b..d7c37d979b 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/GridZone.xaml +++ b/src/modules/fancyzones/editor/FancyZonesEditor/GridZone.xaml @@ -7,7 +7,7 @@ mc:Ignorable="d" Background="LightGray" BorderThickness="1" - BorderBrush="DarkGray" + BorderBrush="SlateGray" Opacity="0.5" d:DesignHeight="450" d:DesignWidth="800"> diff --git a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs index 5d1105d05a..c3bf46400f 100644 --- a/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs +++ b/src/modules/fancyzones/editor/FancyZonesEditor/LayoutPreview.xaml.cs @@ -98,98 +98,9 @@ namespace FancyZonesEditor } } - private void RenderActualScalePriview(GridLayoutModel grid) - { - int rows = grid.Rows; - int cols = grid.Columns; - - RowColInfo[] rowInfo = new RowColInfo[rows]; - for (int row = 0; row < rows; row++) - { - rowInfo[row] = new RowColInfo(grid.RowPercents[row]); - } - - RowColInfo[] colInfo = new RowColInfo[cols]; - for (int col = 0; col < cols; col++) - { - colInfo[col] = new RowColInfo(grid.ColumnPercents[col]); - } - - Settings settings = ((App)Application.Current).ZoneSettings; - - int spacing = settings.ShowSpacing ? settings.Spacing : 0; - - int width = (int)SystemParameters.WorkArea.Width; - int height = (int)SystemParameters.WorkArea.Height; - - double totalWidth = width - (spacing * (cols + 1)); - double totalHeight = height - (spacing * (rows + 1)); - - double top = spacing; - for (int row = 0; row < rows; row++) - { - double cellHeight = rowInfo[row].Recalculate(top, totalHeight); - top += cellHeight + spacing; - } - - double left = spacing; - for (int col = 0; col < cols; col++) - { - double cellWidth = colInfo[col].Recalculate(left, totalWidth); - left += cellWidth + spacing; - } - - Viewbox viewbox = new Viewbox - { - Stretch = Stretch.Uniform, - }; - Body.Children.Add(viewbox); - Canvas frame = new Canvas - { - Width = width, - Height = height, - }; - viewbox.Child = frame; - - for (int row = 0; row < rows; row++) - { - for (int col = 0; col < cols; col++) - { - int i = grid.CellChildMap[row, col]; - if (((row == 0) || (grid.CellChildMap[row - 1, col] != i)) && - ((col == 0) || (grid.CellChildMap[row, col - 1] != i))) - { - Rectangle rect = new Rectangle(); - left = colInfo[col].Start; - top = rowInfo[row].Start; - Canvas.SetTop(rect, top); - Canvas.SetLeft(rect, left); - - int maxRow = row; - while (((maxRow + 1) < rows) && (grid.CellChildMap[maxRow + 1, col] == i)) - { - maxRow++; - } - - int maxCol = col; - while (((maxCol + 1) < cols) && (grid.CellChildMap[row, maxCol + 1] == i)) - { - maxCol++; - } - - rect.Width = colInfo[maxCol].End - left; - rect.Height = rowInfo[maxRow].End - top; - rect.StrokeThickness = 1; - rect.Stroke = Brushes.DarkGray; - rect.Fill = Brushes.LightGray; - frame.Children.Add(rect); - } - } - } - } - - private void RenderSmallScalePriview(GridLayoutModel grid) + private void RenderGridPreview(GridLayoutModel grid) { + Body.RowDefinitions.Clear(); foreach (int percent in grid.RowPercents) { RowDefinition def = new RowDefinition @@ -199,6 +110,7 @@ namespace FancyZonesEditor Body.RowDefinitions.Add(def); } + Body.ColumnDefinitions.Clear(); foreach (int percent in grid.ColumnPercents) { ColumnDefinition def = new ColumnDefinition @@ -209,7 +121,8 @@ namespace FancyZonesEditor } Settings settings = ((App)Application.Current).ZoneSettings; - Thickness margin = new Thickness(settings.ShowSpacing ? settings.Spacing / 20 : 0); + int divisor = IsActualSize ? 2 : 20; + Thickness margin = new Thickness(settings.ShowSpacing ? settings.Spacing / divisor : 0); List visited = new List(); @@ -224,25 +137,25 @@ namespace FancyZonesEditor Rectangle rect = new Rectangle(); Grid.SetRow(rect, row); Grid.SetColumn(rect, col); - int rowSpan = 1; + int span = 1; int walk = row + 1; while ((walk < grid.Rows) && grid.CellChildMap[walk, col] == childIndex) { - rowSpan++; + span++; walk++; } - Grid.SetRowSpan(rect, rowSpan); + Grid.SetRowSpan(rect, span); - int columnSpan = 1; + span = 1; walk = col + 1; while ((walk < grid.Columns) && grid.CellChildMap[row, walk] == childIndex) { - columnSpan++; + span++; walk++; } - Grid.SetColumnSpan(rect, columnSpan); + Grid.SetColumnSpan(rect, span); rect.Margin = margin; rect.StrokeThickness = 1; @@ -254,20 +167,6 @@ namespace FancyZonesEditor } } - private void RenderGridPreview(GridLayoutModel grid) - { - Body.RowDefinitions.Clear(); - Body.ColumnDefinitions.Clear(); - if (IsActualSize) - { - RenderActualScalePriview(grid); - } - else - { - RenderSmallScalePriview(grid); - } - } - private void RenderCanvasPreview(CanvasLayoutModel canvas) { Body.RowDefinitions.Clear();