mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
fx cop & FZ editor part 1 of many (#11241)
* fixing first set of host of bugs * objects are already set to defaults * shifting to string.is null / empty * setters * fixing stylecop oops * checking in the FxCop dep but commenting it out for easier coming back
This commit is contained in:
@@ -174,9 +174,12 @@ namespace FancyZonesEditor
|
|||||||
public static void ShowExceptionReportMessageBox(string reportData)
|
public static void ShowExceptionReportMessageBox(string reportData)
|
||||||
{
|
{
|
||||||
var fileStream = File.OpenWrite(ErrorReportLogFile);
|
var fileStream = File.OpenWrite(ErrorReportLogFile);
|
||||||
var sw = new StreamWriter(fileStream);
|
using (var sw = new StreamWriter(fileStream))
|
||||||
sw.Write(reportData);
|
{
|
||||||
sw.Flush();
|
sw.Write(reportData);
|
||||||
|
sw.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
ShowReportMessageBox(fileStream.Name);
|
ShowReportMessageBox(fileStream.Name);
|
||||||
@@ -185,8 +188,11 @@ namespace FancyZonesEditor
|
|||||||
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs args)
|
private void OnUnhandledException(object sender, UnhandledExceptionEventArgs args)
|
||||||
{
|
{
|
||||||
var fileStream = File.OpenWrite(CrashReportLogFile);
|
var fileStream = File.OpenWrite(CrashReportLogFile);
|
||||||
var sw = new StreamWriter(fileStream);
|
using (var sw = new StreamWriter(fileStream))
|
||||||
sw.Write(FormatException((Exception)args.ExceptionObject));
|
{
|
||||||
|
sw.Write(FormatException((Exception)args.ExceptionObject));
|
||||||
|
}
|
||||||
|
|
||||||
fileStream.Close();
|
fileStream.Close();
|
||||||
|
|
||||||
ShowReportMessageBox(fileStream.Name);
|
ShowReportMessageBox(fileStream.Name);
|
||||||
|
|||||||
@@ -66,6 +66,10 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="ModernWpfUI" Version="0.9.4" />
|
<PackageReference Include="ModernWpfUI" Version="0.9.4" />
|
||||||
|
<!--<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
</PackageReference>-->
|
||||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|||||||
@@ -75,18 +75,26 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
public struct Zone
|
public struct Zone
|
||||||
{
|
{
|
||||||
public int Index;
|
public int Index { get; set; }
|
||||||
public int Left;
|
|
||||||
public int Top;
|
public int Left { get; set; }
|
||||||
public int Right;
|
|
||||||
public int Bottom;
|
public int Top { get; set; }
|
||||||
|
|
||||||
|
public int Right { get; set; }
|
||||||
|
|
||||||
|
public int Bottom { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct Resizer
|
public struct Resizer
|
||||||
{
|
{
|
||||||
public Orientation Orientation;
|
public Orientation Orientation { get; set; }
|
||||||
public List<int> NegativeSideIndices; // all zones to the left/up, in order
|
|
||||||
public List<int> PositiveSideIndices; // all zones to the right/down, in order
|
// all zones to the left/up, in order
|
||||||
|
public List<int> NegativeSideIndices { get; set; }
|
||||||
|
|
||||||
|
// all zones to the right/down, in order
|
||||||
|
public List<int> PositiveSideIndices { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Zone> _zones;
|
private List<Zone> _zones;
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ namespace FancyZonesEditor
|
|||||||
MagneticSnap snapX = new MagneticSnap(GridData.PrefixSum(Model.ColumnPercents).GetRange(1, Model.ColumnPercents.Count - 1), actualSize.Width);
|
MagneticSnap snapX = new MagneticSnap(GridData.PrefixSum(Model.ColumnPercents).GetRange(1, Model.ColumnPercents.Count - 1), actualSize.Width);
|
||||||
MagneticSnap snapY = new MagneticSnap(GridData.PrefixSum(Model.RowPercents).GetRange(1, Model.RowPercents.Count - 1), actualSize.Height);
|
MagneticSnap snapY = new MagneticSnap(GridData.PrefixSum(Model.RowPercents).GetRange(1, Model.RowPercents.Count - 1), actualSize.Height);
|
||||||
|
|
||||||
for (int zoneIndex = 0; zoneIndex < _data.Zones.Count(); zoneIndex++)
|
for (int zoneIndex = 0; zoneIndex < _data.Zones.Count; zoneIndex++)
|
||||||
{
|
{
|
||||||
// this is needed for the lambda
|
// this is needed for the lambda
|
||||||
int zoneIndexCopy = zoneIndex;
|
int zoneIndexCopy = zoneIndex;
|
||||||
@@ -227,8 +227,8 @@ namespace FancyZonesEditor
|
|||||||
SetupUI();
|
SetupUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
private double _dragX = 0;
|
private double _dragX;
|
||||||
private double _dragY = 0;
|
private double _dragY;
|
||||||
|
|
||||||
private void Resizer_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
|
private void Resizer_DragStarted(object sender, System.Windows.Controls.Primitives.DragStartedEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -379,7 +379,7 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
var selectedIndices = new List<int>();
|
var selectedIndices = new List<int>();
|
||||||
|
|
||||||
for (int zoneIndex = 0; zoneIndex < _data.Zones.Count(); zoneIndex++)
|
for (int zoneIndex = 0; zoneIndex < _data.Zones.Count; zoneIndex++)
|
||||||
{
|
{
|
||||||
var zoneData = _data.Zones[zoneIndex];
|
var zoneData = _data.Zones[zoneIndex];
|
||||||
|
|
||||||
@@ -418,7 +418,7 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
var selectedIndices = new List<int>();
|
var selectedIndices = new List<int>();
|
||||||
|
|
||||||
for (int zoneIndex = 0; zoneIndex < _data.Zones.Count(); zoneIndex++)
|
for (int zoneIndex = 0; zoneIndex < _data.Zones.Count; zoneIndex++)
|
||||||
{
|
{
|
||||||
if ((Preview.Children[zoneIndex] as GridZone).IsSelected)
|
if ((Preview.Children[zoneIndex] as GridZone).IsSelected)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace FancyZonesEditor
|
|||||||
public event MouseButtonEventHandler MergeComplete;
|
public event MouseButtonEventHandler MergeComplete;
|
||||||
|
|
||||||
private readonly Rectangle _splitter;
|
private readonly Rectangle _splitter;
|
||||||
private bool _switchOrientation = false;
|
private bool _switchOrientation;
|
||||||
private Point _lastPos = new Point(-1, -1);
|
private Point _lastPos = new Point(-1, -1);
|
||||||
private int _snappedPositionX;
|
private int _snappedPositionX;
|
||||||
private int _snappedPositionY;
|
private int _snappedPositionY;
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ namespace FancyZonesEditor
|
|||||||
private const int MinimalForDefaultWrapPanelsHeight = 900;
|
private const int MinimalForDefaultWrapPanelsHeight = 900;
|
||||||
|
|
||||||
private readonly MainWindowSettingsModel _settings = ((App)Application.Current).MainWindowSettings;
|
private readonly MainWindowSettingsModel _settings = ((App)Application.Current).MainWindowSettings;
|
||||||
private LayoutModel _backup = null;
|
private LayoutModel _backup;
|
||||||
|
|
||||||
private ContentDialog _openedDialog = null;
|
private ContentDialog _openedDialog;
|
||||||
|
|
||||||
public int WrapPanelItemSize { get; set; } = DefaultWrapPanelItemSize;
|
public int WrapPanelItemSize { get; set; } = DefaultWrapPanelItemSize;
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ namespace FancyZonesEditor.Models
|
|||||||
List<string> result = new List<string>();
|
List<string> result = new List<string>();
|
||||||
foreach (var pair in MainWindowSettingsModel.QuickKeys.SelectedKeys)
|
foreach (var pair in MainWindowSettingsModel.QuickKeys.SelectedKeys)
|
||||||
{
|
{
|
||||||
if (pair.Value == string.Empty || pair.Value == Uuid)
|
if (string.IsNullOrEmpty(pair.Value) || pair.Value == Uuid)
|
||||||
{
|
{
|
||||||
result.Add(pair.Key);
|
result.Add(pair.Key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ namespace FancyZonesEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LayoutModel _selectedModel = null;
|
private LayoutModel _selectedModel;
|
||||||
|
|
||||||
public LayoutModel AppliedModel
|
public LayoutModel AppliedModel
|
||||||
{
|
{
|
||||||
@@ -180,7 +180,7 @@ namespace FancyZonesEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LayoutModel _appliedModel = null;
|
private LayoutModel _appliedModel;
|
||||||
|
|
||||||
public static bool IsPredefinedLayout(LayoutModel model)
|
public static bool IsPredefinedLayout(LayoutModel model)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -707,7 +707,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
// Serialize quick layout switch keys
|
// Serialize quick layout switch keys
|
||||||
foreach (var pair in MainWindowSettingsModel.QuickKeys.SelectedKeys)
|
foreach (var pair in MainWindowSettingsModel.QuickKeys.SelectedKeys)
|
||||||
{
|
{
|
||||||
if (pair.Value != string.Empty)
|
if (!string.IsNullOrEmpty(pair.Value))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -739,10 +739,12 @@ namespace FancyZonesEditor.Utils
|
|||||||
private string ReadFile(string fileName)
|
private string ReadFile(string fileName)
|
||||||
{
|
{
|
||||||
Stream inputStream = _fileSystem.File.Open(fileName, FileMode.Open);
|
Stream inputStream = _fileSystem.File.Open(fileName, FileMode.Open);
|
||||||
StreamReader reader = new StreamReader(inputStream);
|
using (StreamReader reader = new StreamReader(inputStream))
|
||||||
string data = reader.ReadToEnd();
|
{
|
||||||
inputStream.Close();
|
string data = reader.ReadToEnd();
|
||||||
return data;
|
inputStream.Close();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SetDevices(List<DeviceWrapper> devices)
|
private bool SetDevices(List<DeviceWrapper> devices)
|
||||||
|
|||||||
Reference in New Issue
Block a user