Skip to content

Commit

Permalink
Fixed a lot of line issues, few auto
Browse files Browse the repository at this point in the history
  • Loading branch information
crutkas committed Dec 12, 2019
1 parent 9e4752b commit a187456
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 49 deletions.
11 changes: 5 additions & 6 deletions src/modules/fancyzones/editor/FancyZonesEditor/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ namespace FancyZonesEditor
/// </summary>
public partial class App : Application
{
public Settings ZoneSettings { get { return _settings; } }
public Settings ZoneSettings { get; }

private Settings _settings;
private ushort _idInitial = 0;

public App()
{
_settings = new Settings();
ZoneSettings = new Settings();
}

private void OnStartup(object sender, StartupEventArgs e)
Expand All @@ -34,7 +33,7 @@ private void OnStartup(object sender, StartupEventArgs e)

if (_idInitial != 0)
{
foreach (LayoutModel model in _settings.DefaultModels)
foreach (LayoutModel model in ZoneSettings.DefaultModels)
{
if (model.Id == _idInitial)
{
Expand All @@ -46,7 +45,7 @@ private void OnStartup(object sender, StartupEventArgs e)

if (foundModel == null)
{
foreach (LayoutModel model in _settings.CustomModels)
foreach (LayoutModel model in ZoneSettings.CustomModels)
{
if (model.Id == _idInitial)
{
Expand All @@ -60,7 +59,7 @@ private void OnStartup(object sender, StartupEventArgs e)

if (foundModel == null)
{
foundModel = _settings.DefaultModels[0];
foundModel = ZoneSettings.DefaultModels[0];
}

foundModel.IsSelected = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<Compile Include="GridEditorWindow.xaml.cs">
<DependentUpon>GridEditorWindow.xaml</DependentUpon>
</Compile>
<Compile Include="SplitEventArgs.cs" />
<Compile Include="WindowLayout.xaml.cs">
<DependentUpon>WindowLayout.xaml</DependentUpon>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ public GridLayoutModel Model
set { SetValue(ModelProperty, value); }
}

public Panel PreviewPanel { get { return Preview; } }
public Panel PreviewPanel
{
get { return Preview; }
}

private void OnFullSplit(object o, SplitEventArgs e)
{
Expand Down
26 changes: 7 additions & 19 deletions src/modules/fancyzones/editor/FancyZonesEditor/GridZone.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ private bool IsVerticalSplit
}
}

private int SplitterThickness { get { return Math.Max(((App)Application.Current).ZoneSettings.Spacing, 5); } }
private int SplitterThickness
{
get { return Math.Max(((App)Application.Current).ZoneSettings.Spacing, 5); }
}

private void UpdateSplitter()
{
Expand Down Expand Up @@ -238,8 +241,11 @@ protected override void OnMouseUp(MouseButtonEventArgs e)
}

public event SplitEventHandler Split;

public event SplitEventHandler FullSplit;

public event MouseEventHandler MergeDrag;

public event MouseButtonEventHandler MergeComplete;

private Rectangle _splitter;
Expand Down Expand Up @@ -286,22 +292,4 @@ private void DoFullSplit()
}
}
}

public class SplitEventArgs : EventArgs
{
public SplitEventArgs() { }
public SplitEventArgs(Orientation orientation, double offset)
{
_orientation = orientation;
_offset = offset;
}

public Orientation Orientation { get { return _orientation; } }
public double Offset { get { return _offset; } }

private Orientation _orientation;
private double _offset;
}

public delegate void SplitEventHandler(object sender, SplitEventArgs args);
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ private void ZoneSettings_PropertyChanged(object sender, System.ComponentModel.P
}
}

public Panel PreviewPanel { get { return Body; } }
public Panel PreviewPanel
{
get { return Body; }
}

private void OnLoaded(object sender, RoutedEventArgs e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,46 @@ namespace FancyZonesEditor.Models
// Free form Layout Model, which specifies independent zone rects
public class CanvasLayoutModel : LayoutModel
{
public CanvasLayoutModel(ushort version, string name, ushort id, byte[] data) : base(name, id)
public CanvasLayoutModel(ushort version, string name, ushort id, byte[] data)
: base(name, id)
{
if (version == _latestVersion)
{
Load(data);
}
}

public CanvasLayoutModel(string name, ushort id, int referenceWidth, int referenceHeight) : base(name, id)
public CanvasLayoutModel(string name, ushort id, int referenceWidth, int referenceHeight)
: base(name, id)
{
// Initialize Reference Size
_referenceWidth = referenceWidth;
_referenceHeight = referenceHeight;
}

public CanvasLayoutModel(string name, ushort id) : base(name, id) { }
public CanvasLayoutModel(string name, ushort id)
: base(name, id)
{
}

public CanvasLayoutModel(string name) : base(name) { }
public CanvasLayoutModel(string name)
: base(name)
{
}

public CanvasLayoutModel() : base() { }
public CanvasLayoutModel()
: base()
{
}

// ReferenceWidth - the reference width for the layout rect that all Zones are relative to
public int ReferenceWidth
{
get { return _referenceWidth; }
get
{
return _referenceWidth;
}

set
{
if (_referenceWidth != value)
Expand Down Expand Up @@ -69,8 +84,7 @@ public int ReferenceHeight
private int _referenceHeight;

// Zones - the list of all zones in this layout, described as independent rectangles
public IList<Int32Rect> Zones { get { return _zones; } }
private IList<Int32Rect> _zones = new List<Int32Rect>();
public IList<Int32Rect> Zones { get; } = new List<Int32Rect>();

// RemoveZoneAt
// Removes the specified index from the Zones list, and fires a property changed notification for the Zones property
Expand Down Expand Up @@ -100,7 +114,7 @@ private void Load(byte[] data)

while (count-- > 0)
{
_zones.Add(new Int32Rect(
Zones.Add(new Int32Rect(
data[i++] * 256 + data[i++],
data[i++] * 256 + data[i++],
data[i++] * 256 + data[i++],
Expand Down Expand Up @@ -130,7 +144,7 @@ public override LayoutModel Clone()
// Returns the state of this GridLayoutModel in persisted format
protected override byte[] GetPersistData()
{
byte[] data = new byte[10 + (_zones.Count * 8)];
byte[] data = new byte[10 + (Zones.Count * 8)];
int i = 0;

// Common persisted values between all layout types
Expand All @@ -146,9 +160,9 @@ protected override byte[] GetPersistData()
data[i++] = (byte)(_referenceWidth % 256);
data[i++] = (byte)(_referenceHeight / 256);
data[i++] = (byte)(_referenceHeight % 256);
data[i++] = (byte)_zones.Count;
data[i++] = (byte)Zones.Count;

foreach (Int32Rect rect in _zones)
foreach (Int32Rect rect in Zones)
{
data[i++] = (byte)(rect.X / 256);
data[i++] = (byte)(rect.X % 256);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,23 @@ namespace FancyZonesEditor.Models
// Grid-styled Layout Model, which specifies rows, columns, percentage sizes, and row/column spans
public class GridLayoutModel : LayoutModel
{
public GridLayoutModel() : base() { }
public GridLayoutModel(string name) : base(name) { }
public GridLayoutModel(string name, ushort id) : base(name, id) { }
public GridLayoutModel(ushort version, string name, ushort id, byte[] data) : base(name, id)
public GridLayoutModel()
: base()
{
}

public GridLayoutModel(string name)
: base(name)
{
}

public GridLayoutModel(string name, ushort id)
: base(name, id)
{
}

public GridLayoutModel(ushort version, string name, ushort id, byte[] data)
: base(name, id)
{
if (version == c_latestVersion)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ namespace FancyZonesEditor.Models
// Manages common properties and base persistence
public abstract class LayoutModel : INotifyPropertyChanged
{
protected LayoutModel() { }
protected LayoutModel()
{
}

protected LayoutModel(string name) : this()
protected LayoutModel(string name)
: this()
{
Name = name;
}

protected LayoutModel(string name, ushort id) : this(name)
protected LayoutModel(string name, ushort id)
: this(name)
{
_id = id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,16 +340,18 @@ private void ParseCommandLineArgs()

_workArea = new Rect(x, y, width, height);

uint monitor = 0;
if (uint.TryParse(args[4], out monitor))
if (uint.TryParse(args[4], out uint monitor))
{
Monitor = monitor;
}
}
}


public IList<LayoutModel> DefaultModels { get { return _defaultModels; } }
public IList<LayoutModel> DefaultModels
{
get { return _defaultModels; }
}

public ObservableCollection<LayoutModel> CustomModels
{
Expand Down
28 changes: 28 additions & 0 deletions src/modules/fancyzones/editor/FancyZonesEditor/SplitEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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.

using System;
using System.Windows.Controls;

namespace FancyZonesEditor
{
public class SplitEventArgs : EventArgs
{
public SplitEventArgs()
{
}

public SplitEventArgs(Orientation orientation, double offset)
{
Orientation = orientation;
Offset = offset;
}

public Orientation Orientation { get; }

public double Offset { get; }
}

public delegate void SplitEventHandler(object sender, SplitEventArgs args);
}

0 comments on commit a187456

Please sign in to comment.