Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ protected void OnSaveApplyTemplate(object sender, RoutedEventArgs e)
}

model.Persist();

MainWindowSettingsModel settings = ((App)Application.Current).MainWindowSettings;
settings.SetAppliedModel(model);
}

App.FancyZonesEditorIO.SerializeZoneSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@
<TextBlock x:Name="numberOfZonesHeader"
Text="{x:Static props:Resources.NumberOfZones}"
Margin="0,16,0,0"
Foreground="{DynamicResource PrimaryForegroundBrush}" />
Foreground="{DynamicResource PrimaryForegroundBrush}"
Visibility="{Binding Path=Type, Converter={StaticResource LayoutTypeTemplateToVisibilityConverter}}" />
<StackPanel Margin="0,6,0,0"
Orientation="Horizontal"
Visibility="{Binding Path=Type, Converter={StaticResource LayoutTypeTemplateToVisibilityConverter}}">
Expand Down
28 changes: 9 additions & 19 deletions src/modules/fancyzones/editor/FancyZonesEditor/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,33 +286,23 @@ private void NewLayoutDialog_PrimaryButtonClick(ModernWpf.Controls.ContentDialog

if (GridLayoutRadioButton.IsChecked == true)
{
// 1:1 Copy from MainWindowSettingsModel, so probably needs to be refactored / combined.
int multiplier = 10000;
int zoneCount = 3;

GridLayoutModel columnsModel = new GridLayoutModel(LayoutNameText.Text, LayoutType.Columns)
GridLayoutModel gridModel = new GridLayoutModel(LayoutNameText.Text, LayoutType.Columns)
{
Rows = 1,
RowPercents = new List<int>(1) { multiplier },
RowPercents = new List<int>(1) { GridLayoutModel.GridMultiplier },
};

columnsModel.CellChildMap = new int[1, zoneCount];
columnsModel.Columns = zoneCount;
columnsModel.ColumnPercents = new List<int>(zoneCount);

for (int i = 0; i < 3; i++)
{
columnsModel.CellChildMap[0, i] = i;
columnsModel.ColumnPercents.Add(((multiplier * (i + 1)) / zoneCount) - ((multiplier * i) / zoneCount));
}

selectedLayoutModel = columnsModel;
selectedLayoutModel = gridModel;
}
else
{
selectedLayoutModel = new CanvasLayoutModel(LayoutNameText.Text, LayoutType.Blank);
selectedLayoutModel = new CanvasLayoutModel(LayoutNameText.Text, LayoutType.Custom)
{
TemplateZoneCount = 0,
};
}

selectedLayoutModel.InitTemplateZones();

App.Overlay.CurrentDataContext = selectedLayoutModel;
var mainEditor = App.Overlay;
Hide();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand All @@ -14,7 +14,7 @@ public class GridLayoutModel : LayoutModel
// Non-localizable strings
public const string ModelTypeID = "grid";

private const int _multiplier = 10000;
public const int GridMultiplier = 10000;

// hard coded data for all the "Priority Grid" configurations that are unique to "Grid"
private static readonly byte[][] _priorityData = new byte[][]
Expand Down Expand Up @@ -78,10 +78,10 @@ public int Columns
public int[,] CellChildMap { get; set; }

// RowPercents - represents the %age height of each row in the grid
public List<int> RowPercents { get; set; }
public List<int> RowPercents { get; set; } = new List<int>();

// ColumnPercents - represents the %age width of each column in the grid
public List<int> ColumnPercents { get; set; }
public List<int> ColumnPercents { get; set; } = new List<int>();

// ShowSpacing - flag if free space between cells should be presented
public bool ShowSpacing
Expand Down Expand Up @@ -170,13 +170,11 @@ public GridLayoutModel(GridLayoutModel other)
}
}

RowPercents = new List<int>(_rows);
for (int row = 0; row < _rows; row++)
{
RowPercents.Add(other.RowPercents[row]);
}

ColumnPercents = new List<int>(_cols);
for (int col = 0; col < _cols; col++)
{
ColumnPercents.Add(other.ColumnPercents[col]);
Expand Down Expand Up @@ -306,7 +304,7 @@ private void InitRows()

// Note: This is NOT equal to _multiplier / ZoneCount and is done like this to make
// the sum of all RowPercents exactly (_multiplier).
RowPercents.Add(((_multiplier * (i + 1)) / TemplateZoneCount) - ((_multiplier * i) / TemplateZoneCount));
RowPercents.Add(((GridMultiplier * (i + 1)) / TemplateZoneCount) - ((GridMultiplier * i) / TemplateZoneCount));
}

_rows = TemplateZoneCount;
Expand All @@ -323,7 +321,7 @@ private void InitColumns()

// Note: This is NOT equal to _multiplier / ZoneCount and is done like this to make
// the sum of all RowPercents exactly (_multiplier).
ColumnPercents.Add(((_multiplier * (i + 1)) / TemplateZoneCount) - ((_multiplier * i) / TemplateZoneCount));
ColumnPercents.Add(((GridMultiplier * (i + 1)) / TemplateZoneCount) - ((GridMultiplier * i) / TemplateZoneCount));
}

_cols = TemplateZoneCount;
Expand Down Expand Up @@ -356,12 +354,12 @@ private void InitGrid()
// done like this to make the sum of all RowPercents exactly (_multiplier).
for (int row = 0; row < rows; row++)
{
RowPercents.Add(((_multiplier * (row + 1)) / rows) - ((_multiplier * row) / rows));
RowPercents.Add(((GridMultiplier * (row + 1)) / rows) - ((GridMultiplier * row) / rows));
}

for (int col = 0; col < cols; col++)
{
ColumnPercents.Add(((_multiplier * (col + 1)) / cols) - ((_multiplier * col) / cols));
ColumnPercents.Add(((GridMultiplier * (col + 1)) / cols) - ((GridMultiplier * col) / cols));
}

int index = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ private enum DeviceIdParts
public static readonly string RegistryPath = "SOFTWARE\\SuperFancyZones";
public static readonly string FullRegistryPath = "HKEY_CURRENT_USER\\" + RegistryPath;

private const int _multiplier = 10000;

public bool IsCustomLayoutActive
{
get
Expand Down Expand Up @@ -71,15 +69,15 @@ public MainWindowSettingsModel()
_columnsModel = new GridLayoutModel(Properties.Resources.Template_Layout_Columns, LayoutType.Columns)
{
Rows = 1,
RowPercents = new List<int>(1) { _multiplier },
RowPercents = new List<int>(1) { GridLayoutModel.GridMultiplier },
};
_columnsModel.InitTemplateZones();
DefaultModels.Add(_columnsModel);

_rowsModel = new GridLayoutModel(Properties.Resources.Template_Layout_Rows, LayoutType.Rows)
{
Columns = 1,
ColumnPercents = new List<int>(1) { _multiplier },
ColumnPercents = new List<int>(1) { GridLayoutModel.GridMultiplier },
};
_rowsModel.InitTemplateZones();
DefaultModels.Add(_rowsModel);
Expand Down