Fixing blank lines

This commit is contained in:
Clint Rutkas
2019-12-12 13:26:02 -08:00
parent 826858c170
commit de64b33bb8
13 changed files with 159 additions and 63 deletions

View File

@@ -13,7 +13,7 @@ namespace FancyZonesEditor.Models
{
public CanvasLayoutModel(ushort version, string name, ushort id, byte[] data) : base(name, id)
{
if (version == c_latestVersion)
if (version == _latestVersion)
{
Load(data);
}
@@ -45,12 +45,17 @@ namespace FancyZonesEditor.Models
}
}
}
private int _referenceWidth;
// ReferenceHeight - the reference height for the layout rect that all Zones are relative to
public int ReferenceHeight
{
get { return _referenceHeight; }
get
{
return _referenceHeight;
}
set
{
if (_referenceHeight != value)
@@ -60,6 +65,7 @@ namespace FancyZonesEditor.Models
}
}
}
private int _referenceHeight;
// Zones - the list of all zones in this layout, described as independent rectangles
@@ -128,8 +134,8 @@ namespace FancyZonesEditor.Models
int i = 0;
// Common persisted values between all layout types
data[i++] = (byte)(c_latestVersion / 256);
data[i++] = (byte)(c_latestVersion % 256);
data[i++] = (byte)(_latestVersion / 256);
data[i++] = (byte)(_latestVersion % 256);
data[i++] = 1; // LayoutModelType: 1 == CanvasLayoutModel
data[i++] = (byte)(Id / 256);
data[i++] = (byte)(Id % 256);
@@ -155,9 +161,10 @@ namespace FancyZonesEditor.Models
data[i++] = (byte)(rect.Height / 256);
data[i++] = (byte)(rect.Height % 256);
}
return data;
}
private static ushort c_latestVersion = 0;
private static ushort _latestVersion = 0;
}
}

View File

@@ -20,34 +20,45 @@ namespace FancyZonesEditor.Models
Reload(data);
}
}
// Rows - number of rows in the Grid
public int Rows
{
get { return _rows; }
set
{
get
{
return _rows;
}
set
{
if (_rows != value)
{
_rows = value;
FirePropertyChanged("Rows");
}
}
}
}
}
private int _rows = 1;
// Columns - number of columns in the Grid
public int Columns
{
get { return _cols; }
set
{
get
{
return _cols;
}
set
{
if (_cols != value)
{
_cols = value;
FirePropertyChanged("Columns");
}
}
}
}
}
private int _cols = 1;
// CellChildMap - represents which "children" belong in which grid cells;
@@ -116,6 +127,7 @@ namespace FancyZonesEditor.Models
cellChildMap[row, col] = CellChildMap[row, col];
}
}
layout.CellChildMap = cellChildMap;
int[] rowPercents = new int[rows];
@@ -123,6 +135,7 @@ namespace FancyZonesEditor.Models
{
rowPercents[row] = RowPercents[row];
}
layout.RowPercents = rowPercents;
int[] colPercents = new int[cols];
@@ -130,6 +143,7 @@ namespace FancyZonesEditor.Models
{
colPercents[col] = ColumnPercents[col];
}
layout.ColumnPercents = colPercents;
return layout;
@@ -169,6 +183,7 @@ namespace FancyZonesEditor.Models
index = mapping.Count;
mapping.Add(source);
}
cellChildMap[row, col] = index;
}
}

View File

@@ -26,10 +26,14 @@ namespace FancyZonesEditor.Models
_id = id;
}
// Name - the display name for this layout model - is also used as the key in the registry
// Name - the display name for this layout model - is also used as the key in the registry
public string Name
{
get { return _name; }
get
{
return _name;
}
set
{
if (_name != value)
@@ -39,6 +43,7 @@ namespace FancyZonesEditor.Models
}
}
}
private string _name;
// Id - the unique ID for this layout model - is used to connect fancy zones' ZonesSets with the editor's Layouts
@@ -51,16 +56,22 @@ namespace FancyZonesEditor.Models
{
_id = ++s_maxId;
}
return _id;
}
}
private ushort _id = 0;
// IsSelected (not-persisted) - tracks whether or not this LayoutModel is selected in the picker
// TODO: once we switch to a picker per monitor, we need to move this state to the view
public bool IsSelected
{
get { return _isSelected; }
get
{
return _isSelected;
}
set
{
if (_isSelected != value)
@@ -111,7 +122,7 @@ namespace FancyZonesEditor.Models
LayoutModel model = null;
byte[] data = (byte[])Registry.GetValue(_fullRegistryPath, name, null);
ushort version = (ushort)(data[0] * 256 + data[1]);
ushort version = (ushort)((data[0] * 256) + data[1]);
byte type = data[2];
ushort id = (ushort)((data[3] * 256) + data[4]);
@@ -127,6 +138,7 @@ namespace FancyZonesEditor.Models
{
s_maxId = id;
}
s_customModels.Add(model);
}
}
@@ -134,12 +146,14 @@ namespace FancyZonesEditor.Models
return s_customModels;
}
private static ObservableCollection<LayoutModel> s_customModels = null;
private static ushort s_maxId = 0;
// Callbacks that the base LayoutModel makes to derived types
protected abstract byte[] GetPersistData();
public abstract LayoutModel Clone();
// PInvokes to handshake with fancyzones backend

View File

@@ -29,6 +29,7 @@ namespace FancyZonesEditor
return true;
}
}
return false;
}
}
@@ -70,7 +71,11 @@ namespace FancyZonesEditor
// ZoneCount - number of zones selected in the picker window
public int ZoneCount
{
get { return _zoneCount; }
get
{
return _zoneCount;
}
set
{
if (_zoneCount != value)
@@ -82,12 +87,17 @@ namespace FancyZonesEditor
}
}
}
private int _zoneCount;
// Spacing - how much space in between zones of the grid do you want
public int Spacing
{
get { return _spacing; }
get
{
return _spacing;
}
set
{
if (_spacing != value)
@@ -98,12 +108,17 @@ namespace FancyZonesEditor
}
}
}
private int _spacing;
// ShowSpacing - is the Spacing value used or ignored?
public bool ShowSpacing
{
get { return _showSpacing; }
get
{
return _showSpacing;
}
set
{
if (_showSpacing != value)
@@ -114,12 +129,17 @@ namespace FancyZonesEditor
}
}
}
private bool _showSpacing;
// IsShiftKeyPressed - is the shift key currently being held down
public bool IsShiftKeyPressed
{
get { return _isShiftKeyPressed; }
get
{
return _isShiftKeyPressed;
}
set
{
if (_isShiftKeyPressed != value)
@@ -129,12 +149,17 @@ namespace FancyZonesEditor
}
}
}
private bool _isShiftKeyPressed;
// IsCtrlKeyPressed - is the ctrl key currently being held down
public bool IsCtrlKeyPressed
{
get { return _isCtrlKeyPressed; }
get
{
return _isCtrlKeyPressed;
}
set
{
if (_isCtrlKeyPressed != value)
@@ -144,38 +169,25 @@ namespace FancyZonesEditor
}
}
}
private bool _isCtrlKeyPressed;
public Rect WorkArea
{
get { return _workArea; }
}
private Rect _workArea;
public static uint Monitor
{
get { return _monitor; }
}
private static uint _monitor;
public static uint Monitor { get; private set; }
public static String UniqueKey
{
get { return _uniqueKey; }
}
private static String _uniqueKey;
private String _uniqueRegistryPath;
public static string UniqueKey { get; private set; }
public static String WorkAreaKey
{
get { return _workAreaKey; }
}
private static String _workAreaKey;
private string _uniqueRegistryPath;
public static float Dpi
{
get { return _dpi; }
}
private static float _dpi;
public static string WorkAreaKey { get; private set; }
public static float Dpi { get; private set; }
private int ReadRegistryInt(string valueName, int defaultValue)
{
@@ -225,6 +237,7 @@ namespace FancyZonesEditor
{
rows++;
}
rows--;
cols = ZoneCount / rows;
if (ZoneCount % rows == 0)
@@ -236,6 +249,7 @@ namespace FancyZonesEditor
cols++;
mergeCount = rows - (ZoneCount % rows);
}
_gridModel.Rows = rows;
_gridModel.Columns = cols;
_gridModel.RowPercents = new int[rows];
@@ -285,10 +299,10 @@ namespace FancyZonesEditor
private void ParseCommandLineArgs()
{
_workArea = System.Windows.SystemParameters.WorkArea;
_monitor = 0;
Monitor = 0;
_uniqueRegistryPath = FullRegistryPath;
_uniqueKey = "";
_dpi = 1;
UniqueKey = "";
Dpi = 1;
string[] args = Environment.GetCommandLineArgs();
if (args.Length == 7)
@@ -300,8 +314,8 @@ namespace FancyZonesEditor
// 5 = resolution key (passed back to engine to persist data)
// 6 = monitor DPI (float)
_uniqueKey = args[1];
_uniqueRegistryPath += "\\" + _uniqueKey;
UniqueKey = args[1];
_uniqueRegistryPath += "\\" + UniqueKey;
var parsedLocation = args[4].Split('_');
var x = int.Parse(parsedLocation[0]);
@@ -309,14 +323,14 @@ namespace FancyZonesEditor
var width = int.Parse(parsedLocation[2]);
var height = int.Parse(parsedLocation[3]);
_workAreaKey = args[5];
WorkAreaKey = args[5];
// Try invariant culture first, caller likely uses invariant i.e. "C" locale to construct parameters
foreach (var cultureInfo in new[] { CultureInfo.InvariantCulture, CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture })
{
try
{
_dpi = float.Parse(args[6], cultureInfo);
Dpi = float.Parse(args[6], cultureInfo);
break;
}
catch (FormatException)
@@ -329,13 +343,14 @@ namespace FancyZonesEditor
uint monitor = 0;
if (uint.TryParse(args[4], out monitor))
{
_monitor = monitor;
Monitor = monitor;
}
}
}
public IList<LayoutModel> DefaultModels { get { return _defaultModels; } }
public ObservableCollection<LayoutModel> CustomModels
{
get
@@ -345,9 +360,11 @@ namespace FancyZonesEditor
_customModels = LayoutModel.LoadCustomModels();
_customModels.Insert(0, _blankCustomModel);
}
return _customModels;
}
}
private ObservableCollection<LayoutModel> _customModels;
public static readonly string RegistryPath = "SOFTWARE\\SuperFancyZones";