mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
Fixed a lot of line issues, few auto
This commit is contained in:
parent
9e4752b114
commit
a187456ac3
@ -13,14 +13,13 @@ namespace FancyZonesEditor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
public Settings ZoneSettings { get { return _settings; } }
|
public Settings ZoneSettings { get; }
|
||||||
|
|
||||||
private Settings _settings;
|
|
||||||
private ushort _idInitial = 0;
|
private ushort _idInitial = 0;
|
||||||
|
|
||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
_settings = new Settings();
|
ZoneSettings = new Settings();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnStartup(object sender, StartupEventArgs e)
|
private void OnStartup(object sender, StartupEventArgs e)
|
||||||
@ -34,7 +33,7 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
if (_idInitial != 0)
|
if (_idInitial != 0)
|
||||||
{
|
{
|
||||||
foreach (LayoutModel model in _settings.DefaultModels)
|
foreach (LayoutModel model in ZoneSettings.DefaultModels)
|
||||||
{
|
{
|
||||||
if (model.Id == _idInitial)
|
if (model.Id == _idInitial)
|
||||||
{
|
{
|
||||||
@ -46,7 +45,7 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
if (foundModel == null)
|
if (foundModel == null)
|
||||||
{
|
{
|
||||||
foreach (LayoutModel model in _settings.CustomModels)
|
foreach (LayoutModel model in ZoneSettings.CustomModels)
|
||||||
{
|
{
|
||||||
if (model.Id == _idInitial)
|
if (model.Id == _idInitial)
|
||||||
{
|
{
|
||||||
@ -60,7 +59,7 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
if (foundModel == null)
|
if (foundModel == null)
|
||||||
{
|
{
|
||||||
foundModel = _settings.DefaultModels[0];
|
foundModel = ZoneSettings.DefaultModels[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
foundModel.IsSelected = true;
|
foundModel.IsSelected = true;
|
||||||
|
@ -91,6 +91,7 @@
|
|||||||
<Compile Include="GridEditorWindow.xaml.cs">
|
<Compile Include="GridEditorWindow.xaml.cs">
|
||||||
<DependentUpon>GridEditorWindow.xaml</DependentUpon>
|
<DependentUpon>GridEditorWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="SplitEventArgs.cs" />
|
||||||
<Compile Include="WindowLayout.xaml.cs">
|
<Compile Include="WindowLayout.xaml.cs">
|
||||||
<DependentUpon>WindowLayout.xaml</DependentUpon>
|
<DependentUpon>WindowLayout.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -85,7 +85,10 @@ namespace FancyZonesEditor
|
|||||||
set { SetValue(ModelProperty, value); }
|
set { SetValue(ModelProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Panel PreviewPanel { get { return Preview; } }
|
public Panel PreviewPanel
|
||||||
|
{
|
||||||
|
get { return Preview; }
|
||||||
|
}
|
||||||
|
|
||||||
private void OnFullSplit(object o, SplitEventArgs e)
|
private void OnFullSplit(object o, SplitEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -84,7 +84,10 @@ namespace FancyZonesEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
private void UpdateSplitter()
|
||||||
{
|
{
|
||||||
@ -238,8 +241,11 @@ namespace FancyZonesEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
public event SplitEventHandler Split;
|
public event SplitEventHandler Split;
|
||||||
|
|
||||||
public event SplitEventHandler FullSplit;
|
public event SplitEventHandler FullSplit;
|
||||||
|
|
||||||
public event MouseEventHandler MergeDrag;
|
public event MouseEventHandler MergeDrag;
|
||||||
|
|
||||||
public event MouseButtonEventHandler MergeComplete;
|
public event MouseButtonEventHandler MergeComplete;
|
||||||
|
|
||||||
private Rectangle _splitter;
|
private Rectangle _splitter;
|
||||||
@ -286,22 +292,4 @@ namespace FancyZonesEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,10 @@ namespace FancyZonesEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Panel PreviewPanel { get { return Body; } }
|
public Panel PreviewPanel
|
||||||
|
{
|
||||||
|
get { return Body; }
|
||||||
|
}
|
||||||
|
|
||||||
private void OnLoaded(object sender, RoutedEventArgs e)
|
private void OnLoaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,8 @@ namespace FancyZonesEditor.Models
|
|||||||
// Free form Layout Model, which specifies independent zone rects
|
// Free form Layout Model, which specifies independent zone rects
|
||||||
public class CanvasLayoutModel : LayoutModel
|
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)
|
if (version == _latestVersion)
|
||||||
{
|
{
|
||||||
@ -19,23 +20,37 @@ namespace FancyZonesEditor.Models
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
// Initialize Reference Size
|
||||||
_referenceWidth = referenceWidth;
|
_referenceWidth = referenceWidth;
|
||||||
_referenceHeight = referenceHeight;
|
_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
|
// ReferenceWidth - the reference width for the layout rect that all Zones are relative to
|
||||||
public int ReferenceWidth
|
public int ReferenceWidth
|
||||||
{
|
{
|
||||||
get { return _referenceWidth; }
|
get
|
||||||
|
{
|
||||||
|
return _referenceWidth;
|
||||||
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_referenceWidth != value)
|
if (_referenceWidth != value)
|
||||||
@ -69,8 +84,7 @@ namespace FancyZonesEditor.Models
|
|||||||
private int _referenceHeight;
|
private int _referenceHeight;
|
||||||
|
|
||||||
// Zones - the list of all zones in this layout, described as independent rectangles
|
// Zones - the list of all zones in this layout, described as independent rectangles
|
||||||
public IList<Int32Rect> Zones { get { return _zones; } }
|
public IList<Int32Rect> Zones { get; } = new List<Int32Rect>();
|
||||||
private IList<Int32Rect> _zones = new List<Int32Rect>();
|
|
||||||
|
|
||||||
// RemoveZoneAt
|
// RemoveZoneAt
|
||||||
// Removes the specified index from the Zones list, and fires a property changed notification for the Zones property
|
// Removes the specified index from the Zones list, and fires a property changed notification for the Zones property
|
||||||
@ -100,7 +114,7 @@ namespace FancyZonesEditor.Models
|
|||||||
|
|
||||||
while (count-- > 0)
|
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++],
|
data[i++] * 256 + data[i++],
|
||||||
data[i++] * 256 + data[i++],
|
data[i++] * 256 + data[i++],
|
||||||
@ -130,7 +144,7 @@ namespace FancyZonesEditor.Models
|
|||||||
// Returns the state of this GridLayoutModel in persisted format
|
// Returns the state of this GridLayoutModel in persisted format
|
||||||
protected override byte[] GetPersistData()
|
protected override byte[] GetPersistData()
|
||||||
{
|
{
|
||||||
byte[] data = new byte[10 + (_zones.Count * 8)];
|
byte[] data = new byte[10 + (Zones.Count * 8)];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
// Common persisted values between all layout types
|
// Common persisted values between all layout types
|
||||||
@ -146,9 +160,9 @@ namespace FancyZonesEditor.Models
|
|||||||
data[i++] = (byte)(_referenceWidth % 256);
|
data[i++] = (byte)(_referenceWidth % 256);
|
||||||
data[i++] = (byte)(_referenceHeight / 256);
|
data[i++] = (byte)(_referenceHeight / 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);
|
||||||
data[i++] = (byte)(rect.X % 256);
|
data[i++] = (byte)(rect.X % 256);
|
||||||
|
@ -10,10 +10,23 @@ namespace FancyZonesEditor.Models
|
|||||||
// Grid-styled Layout Model, which specifies rows, columns, percentage sizes, and row/column spans
|
// Grid-styled Layout Model, which specifies rows, columns, percentage sizes, and row/column spans
|
||||||
public class GridLayoutModel : LayoutModel
|
public class GridLayoutModel : LayoutModel
|
||||||
{
|
{
|
||||||
public GridLayoutModel() : base() { }
|
public GridLayoutModel()
|
||||||
public GridLayoutModel(string name) : base(name) { }
|
: base()
|
||||||
public GridLayoutModel(string name, ushort id) : base(name, id) { }
|
{
|
||||||
public GridLayoutModel(ushort version, string name, ushort id, byte[] data) : base(name, id)
|
}
|
||||||
|
|
||||||
|
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)
|
if (version == c_latestVersion)
|
||||||
{
|
{
|
||||||
|
@ -14,14 +14,18 @@ namespace FancyZonesEditor.Models
|
|||||||
// Manages common properties and base persistence
|
// Manages common properties and base persistence
|
||||||
public abstract class LayoutModel : INotifyPropertyChanged
|
public abstract class LayoutModel : INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
protected LayoutModel() { }
|
protected LayoutModel()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected LayoutModel(string name) : this()
|
protected LayoutModel(string name)
|
||||||
|
: this()
|
||||||
{
|
{
|
||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected LayoutModel(string name, ushort id) : this(name)
|
protected LayoutModel(string name, ushort id)
|
||||||
|
: this(name)
|
||||||
{
|
{
|
||||||
_id = id;
|
_id = id;
|
||||||
}
|
}
|
||||||
|
@ -340,8 +340,7 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
_workArea = new Rect(x, y, width, height);
|
_workArea = new Rect(x, y, width, height);
|
||||||
|
|
||||||
uint monitor = 0;
|
if (uint.TryParse(args[4], out uint monitor))
|
||||||
if (uint.TryParse(args[4], out monitor))
|
|
||||||
{
|
{
|
||||||
Monitor = monitor;
|
Monitor = monitor;
|
||||||
}
|
}
|
||||||
@ -349,7 +348,10 @@ namespace FancyZonesEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IList<LayoutModel> DefaultModels { get { return _defaultModels; } }
|
public IList<LayoutModel> DefaultModels
|
||||||
|
{
|
||||||
|
get { return _defaultModels; }
|
||||||
|
}
|
||||||
|
|
||||||
public ObservableCollection<LayoutModel> CustomModels
|
public ObservableCollection<LayoutModel> CustomModels
|
||||||
{
|
{
|
||||||
|
@ -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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user