mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
Fix analyzer warning (#16442)
This commit is contained in:
committed by
GitHub
parent
230c199ee5
commit
6a722e2961
@@ -31,6 +31,8 @@ using System.Diagnostics.CodeAnalysis;
|
|||||||
[assembly: SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "We need to have the names of these keys in lowercase to be able to compare with the keys becoming form the template json. ContainsKey does not allow StringComparer specification to IgnoreCase", Scope = "member", Target = "Microsoft.Templates.Core.ITemplateInfoExtensions.#GetQueryableProperties(Microsoft.TemplateEngine.Abstractions.ITemplateInfo)")]
|
[assembly: SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "We need to have the names of these keys in lowercase to be able to compare with the keys becoming form the template json. ContainsKey does not allow StringComparer specification to IgnoreCase", Scope = "member", Target = "Microsoft.Templates.Core.ITemplateInfoExtensions.#GetQueryableProperties(Microsoft.TemplateEngine.Abstractions.ITemplateInfo)")]
|
||||||
[assembly: SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "We need to have the names of these keys in lowercase to be able to compare with the keys becoming form the template json. ContainsKey does not allow StringComparer specification to IgnoreCase", Scope = "member", Target = "Microsoft.Templates.Core.Composition.CompositionQuery.#Match(System.Collections.Generic.IEnumerable`1<Microsoft.Templates.Core.Composition.QueryNode>,Microsoft.Templates.Core.Composition.QueryablePropertyDictionary)")]
|
[assembly: SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", Justification = "We need to have the names of these keys in lowercase to be able to compare with the keys becoming form the template json. ContainsKey does not allow StringComparer specification to IgnoreCase", Scope = "member", Target = "Microsoft.Templates.Core.Composition.CompositionQuery.#Match(System.Collections.Generic.IEnumerable`1<Microsoft.Templates.Core.Composition.QueryNode>,Microsoft.Templates.Core.Composition.QueryablePropertyDictionary)")]
|
||||||
[assembly: SuppressMessage("Usage", "VSTHRD103:Call async methods when in an async method", Justification = "Resource DictionaryWriter does not implement flush async", Scope = "member", Target = "~M:Microsoft.Templates.Core.PostActions.Catalog.Merge.MergeResourceDictionaryPostAction.ExecuteInternalAsync~System.Threading.Tasks.Task")]
|
[assembly: SuppressMessage("Usage", "VSTHRD103:Call async methods when in an async method", Justification = "Resource DictionaryWriter does not implement flush async", Scope = "member", Target = "~M:Microsoft.Templates.Core.PostActions.Catalog.Merge.MergeResourceDictionaryPostAction.ExecuteInternalAsync~System.Threading.Tasks.Task")]
|
||||||
|
[assembly: SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Used in a lot of places for meaningful method names")]
|
||||||
|
[assembly: SuppressMessage("Performance", "CA1822:Mark members as static", Justification = "Static methods may improve performance but decrease maintainability")]
|
||||||
|
|
||||||
// Threading suppressions
|
// Threading suppressions
|
||||||
[assembly: SuppressMessage("Microsoft.VisualStudio.Threading.Analyzers", "VSTHRD100:Avoid async void methods", Justification = "Event handlers needs async void", Scope = "member", Target = "~M:Microsoft.Templates.UI.Controls.Notification.OnClose")]
|
[assembly: SuppressMessage("Microsoft.VisualStudio.Threading.Analyzers", "VSTHRD100:Avoid async void methods", Justification = "Event handlers needs async void", Scope = "member", Target = "~M:Microsoft.Templates.UI.Controls.Notification.OnClose")]
|
||||||
|
|||||||
@@ -33,10 +33,7 @@ namespace FancyZonesEditor
|
|||||||
{
|
{
|
||||||
if (AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged))
|
if (AutomationPeer.ListenerExists(AutomationEvents.PropertyChanged))
|
||||||
{
|
{
|
||||||
ClickAutomationEventButtonAutomationPeer peer =
|
if (UIElementAutomationPeer.FromElement(this) is ClickAutomationEventButtonAutomationPeer peer)
|
||||||
UIElementAutomationPeer.FromElement(this) as ClickAutomationEventButtonAutomationPeer;
|
|
||||||
|
|
||||||
if (peer != null)
|
|
||||||
{
|
{
|
||||||
peer.RaisePropertyChangedEvent(
|
peer.RaisePropertyChangedEvent(
|
||||||
ValuePatternIdentifiers.ValueProperty,
|
ValuePatternIdentifiers.ValueProperty,
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ namespace FancyZonesEditor.Converters
|
|||||||
{
|
{
|
||||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||||
{
|
{
|
||||||
if (value is bool)
|
if (value is bool valueBool)
|
||||||
{
|
{
|
||||||
return (bool)value == true ? 1 : 0;
|
return valueBool == true ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -21,9 +21,9 @@ namespace FancyZonesEditor.Converters
|
|||||||
|
|
||||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||||
{
|
{
|
||||||
if (value is int)
|
if (value is int valueInt)
|
||||||
{
|
{
|
||||||
return (int)value == 1;
|
return valueInt == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||||
|
<EnableNETAnalyzers>true</EnableNETAnalyzers>
|
||||||
|
<AnalysisMode>Recommended</AnalysisMode>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
|
|||||||
@@ -355,17 +355,17 @@ namespace FancyZonesEditor
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Action<Zone> extend = (zone) =>
|
void Extend(Zone zone)
|
||||||
{
|
{
|
||||||
left = Math.Min(left, zone.Left);
|
left = Math.Min(left, zone.Left);
|
||||||
right = Math.Max(right, zone.Right);
|
right = Math.Max(right, zone.Right);
|
||||||
top = Math.Min(top, zone.Top);
|
top = Math.Min(top, zone.Top);
|
||||||
bottom = Math.Max(bottom, zone.Bottom);
|
bottom = Math.Max(bottom, zone.Bottom);
|
||||||
};
|
}
|
||||||
|
|
||||||
foreach (Index index in indices)
|
foreach (Index index in indices)
|
||||||
{
|
{
|
||||||
extend(_zones[index]);
|
Extend(_zones[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool possiblyBroken = true;
|
bool possiblyBroken = true;
|
||||||
@@ -386,7 +386,7 @@ namespace FancyZonesEditor
|
|||||||
if (newArea != 0 && newArea != area)
|
if (newArea != 0 && newArea != area)
|
||||||
{
|
{
|
||||||
// bad intersection found, extend
|
// bad intersection found, extend
|
||||||
extend(zone);
|
Extend(zone);
|
||||||
possiblyBroken = true;
|
possiblyBroken = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -494,17 +494,17 @@ namespace FancyZonesEditor
|
|||||||
{
|
{
|
||||||
var resizer = _resizers[resizerIndex];
|
var resizer = _resizers[resizerIndex];
|
||||||
|
|
||||||
Func<int, int> getSize = (zoneIndex) =>
|
int GetSize(int zoneIndex)
|
||||||
{
|
{
|
||||||
Zone zone = _zones[zoneIndex];
|
Zone zone = _zones[zoneIndex];
|
||||||
return resizer.Orientation == Orientation.Vertical ? zone.Right - zone.Left : zone.Bottom - zone.Top;
|
return resizer.Orientation == Orientation.Vertical ? zone.Right - zone.Left : zone.Bottom - zone.Top;
|
||||||
};
|
}
|
||||||
|
|
||||||
int minZoneSize = resizer.Orientation == Orientation.Vertical ? MinZoneWidth : MinZoneHeight;
|
int minZoneSize = resizer.Orientation == Orientation.Vertical ? MinZoneWidth : MinZoneHeight;
|
||||||
|
|
||||||
foreach (int zoneIndex in resizer.PositiveSideIndices)
|
foreach (int zoneIndex in resizer.PositiveSideIndices)
|
||||||
{
|
{
|
||||||
if (getSize(zoneIndex) - delta < minZoneSize)
|
if (GetSize(zoneIndex) - delta < minZoneSize)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -512,7 +512,7 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
foreach (int zoneIndex in resizer.NegativeSideIndices)
|
foreach (int zoneIndex in resizer.NegativeSideIndices)
|
||||||
{
|
{
|
||||||
if (getSize(zoneIndex) + delta < minZoneSize)
|
if (GetSize(zoneIndex) + delta < minZoneSize)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,12 +146,10 @@ namespace FancyZonesEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
Orientation orient = Orientation.Horizontal;
|
Orientation orient = Orientation.Horizontal;
|
||||||
int offset = 0;
|
|
||||||
|
|
||||||
int zoneIndex = Preview.Children.IndexOf(gridZone);
|
Debug.Assert(Preview.Children.Count > Preview.Children.IndexOf(gridZone), "Zone index out of range");
|
||||||
var zone = _data.Zones[zoneIndex];
|
|
||||||
Debug.Assert(Preview.Children.Count > zoneIndex, "Zone index out of range");
|
|
||||||
|
|
||||||
|
int offset;
|
||||||
if (((App)Application.Current).MainWindowSettings.IsShiftKeyPressed)
|
if (((App)Application.Current).MainWindowSettings.IsShiftKeyPressed)
|
||||||
{
|
{
|
||||||
orient = Orientation.Vertical;
|
orient = Orientation.Vertical;
|
||||||
@@ -174,8 +172,7 @@ namespace FancyZonesEditor
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var resizer = Keyboard.FocusedElement as GridResizer;
|
if (Keyboard.FocusedElement is GridResizer resizer)
|
||||||
if (resizer != null)
|
|
||||||
{
|
{
|
||||||
HandleResizerKeyDown(resizer, e);
|
HandleResizerKeyDown(resizer, e);
|
||||||
return;
|
return;
|
||||||
@@ -185,15 +182,13 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
private void GridEditor_KeyUp(object sender, KeyEventArgs e)
|
private void GridEditor_KeyUp(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
var resizer = Keyboard.FocusedElement as GridResizer;
|
if (Keyboard.FocusedElement is GridResizer resizer)
|
||||||
if (resizer != null)
|
|
||||||
{
|
{
|
||||||
HandleResizerKeyUp(resizer, e);
|
HandleResizerKeyUp(resizer, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var gridZone = Keyboard.FocusedElement as GridZone;
|
if (Keyboard.FocusedElement is GridZone gridZone)
|
||||||
if (gridZone != null)
|
|
||||||
{
|
{
|
||||||
HandleGridZoneKeyUp(gridZone, e);
|
HandleGridZoneKeyUp(gridZone, e);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ namespace FancyZonesEditor
|
|||||||
private const string GridZoneBackgroundBrushID = "GridZoneBackgroundBrush";
|
private const string GridZoneBackgroundBrushID = "GridZoneBackgroundBrush";
|
||||||
private const string SecondaryForegroundBrushID = "SecondaryForegroundBrush";
|
private const string SecondaryForegroundBrushID = "SecondaryForegroundBrush";
|
||||||
private const string AccentColorBrushID = "SystemControlBackgroundAccentBrush";
|
private const string AccentColorBrushID = "SystemControlBackgroundAccentBrush";
|
||||||
private const string CanvasCanvasZoneBorderBrushID = "CanvasCanvasZoneBorderBrush";
|
|
||||||
|
|
||||||
public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(ObjectDependencyID, typeof(bool), typeof(GridZone), new PropertyMetadata(false, OnSelectionChanged));
|
public static readonly DependencyProperty IsSelectedProperty = DependencyProperty.Register(ObjectDependencyID, typeof(bool), typeof(GridZone), new PropertyMetadata(false, OnSelectionChanged));
|
||||||
|
|
||||||
public event SplitEventHandler Split;
|
public event SplitEventHandler Split;
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ namespace FancyZonesEditor
|
|||||||
private const string PropertyZoneCountID = "ZoneCount";
|
private const string PropertyZoneCountID = "ZoneCount";
|
||||||
private const string PropertyShowSpacingID = "ShowSpacing";
|
private const string PropertyShowSpacingID = "ShowSpacing";
|
||||||
private const string PropertySpacingID = "Spacing";
|
private const string PropertySpacingID = "Spacing";
|
||||||
private const string PropertyZoneBackgroundID = "ZoneBackground";
|
|
||||||
private const string PropertyZoneBorderID = "ZoneBorder";
|
|
||||||
private const string ObjectDependencyID = "IsActualSize";
|
private const string ObjectDependencyID = "IsActualSize";
|
||||||
|
|
||||||
public static readonly DependencyProperty IsActualSizeProperty = DependencyProperty.Register(ObjectDependencyID, typeof(bool), typeof(LayoutPreview), new PropertyMetadata(false));
|
public static readonly DependencyProperty IsActualSizeProperty = DependencyProperty.Register(ObjectDependencyID, typeof(bool), typeof(LayoutPreview), new PropertyMetadata(false));
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Automation;
|
using System.Windows.Automation;
|
||||||
using System.Windows.Automation.Peers;
|
using System.Windows.Automation.Peers;
|
||||||
@@ -76,8 +77,7 @@ namespace FancyZonesEditor
|
|||||||
{
|
{
|
||||||
if (e.Key == Key.Enter && _openedDialog != null && _openedDialog.IsVisible)
|
if (e.Key == Key.Enter && _openedDialog != null && _openedDialog.IsVisible)
|
||||||
{
|
{
|
||||||
var source = e.OriginalSource as RadioButton;
|
if (e.OriginalSource is RadioButton source && source.IsChecked != true)
|
||||||
if (source != null && source.IsChecked != true)
|
|
||||||
{
|
{
|
||||||
source.IsChecked = true;
|
source.IsChecked = true;
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
@@ -105,7 +105,7 @@ namespace FancyZonesEditor
|
|||||||
private void DecrementZones_Click(object sender, RoutedEventArgs e)
|
private void DecrementZones_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var mainEditor = App.Overlay;
|
var mainEditor = App.Overlay;
|
||||||
if (!(mainEditor.CurrentDataContext is LayoutModel model))
|
if (mainEditor.CurrentDataContext is not LayoutModel model)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -119,7 +119,7 @@ namespace FancyZonesEditor
|
|||||||
private void IncrementZones_Click(object sender, RoutedEventArgs e)
|
private void IncrementZones_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
var mainEditor = App.Overlay;
|
var mainEditor = App.Overlay;
|
||||||
if (!(mainEditor.CurrentDataContext is LayoutModel model))
|
if (mainEditor.CurrentDataContext is not LayoutModel model)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -177,9 +177,9 @@ namespace FancyZonesEditor
|
|||||||
foreach (LayoutModel customModel in MainWindowSettingsModel.CustomModels)
|
foreach (LayoutModel customModel in MainWindowSettingsModel.CustomModels)
|
||||||
{
|
{
|
||||||
string name = customModel.Name;
|
string name = customModel.Name;
|
||||||
if (name.StartsWith(defaultNamePrefix))
|
if (name.StartsWith(defaultNamePrefix, StringComparison.CurrentCulture))
|
||||||
{
|
{
|
||||||
if (int.TryParse(name.Substring(defaultNamePrefix.Length), out int i))
|
if (int.TryParse(name.AsSpan(defaultNamePrefix.Length), out int i))
|
||||||
{
|
{
|
||||||
if (maxCustomIndex < i)
|
if (maxCustomIndex < i)
|
||||||
{
|
{
|
||||||
@@ -202,7 +202,7 @@ namespace FancyZonesEditor
|
|||||||
EditLayoutDialog.Hide();
|
EditLayoutDialog.Hide();
|
||||||
|
|
||||||
var mainEditor = App.Overlay;
|
var mainEditor = App.Overlay;
|
||||||
if (!(mainEditor.CurrentDataContext is LayoutModel model))
|
if (mainEditor.CurrentDataContext is not LayoutModel model)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -226,7 +226,7 @@ namespace FancyZonesEditor
|
|||||||
foreach (LayoutModel customModel in MainWindowSettingsModel.CustomModels)
|
foreach (LayoutModel customModel in MainWindowSettingsModel.CustomModels)
|
||||||
{
|
{
|
||||||
string customModelName = customModel.Name;
|
string customModelName = customModel.Name;
|
||||||
if (customModelName.StartsWith(name))
|
if (customModelName.StartsWith(name, StringComparison.CurrentCulture))
|
||||||
{
|
{
|
||||||
int openBraceIndex = customModelName.LastIndexOf('(');
|
int openBraceIndex = customModelName.LastIndexOf('(');
|
||||||
int closeBraceIndex = customModelName.LastIndexOf(')');
|
int closeBraceIndex = customModelName.LastIndexOf(')');
|
||||||
@@ -320,7 +320,7 @@ namespace FancyZonesEditor
|
|||||||
}
|
}
|
||||||
|
|
||||||
Keyboard.ClearFocus();
|
Keyboard.ClearFocus();
|
||||||
EditLayoutDialogTitle.Text = string.Format(Properties.Resources.Edit_Template, ((LayoutModel)dataContext).Name);
|
EditLayoutDialogTitle.Text = string.Format(CultureInfo.CurrentCulture, Properties.Resources.Edit_Template, ((LayoutModel)dataContext).Name);
|
||||||
await EditLayoutDialog.ShowAsync();
|
await EditLayoutDialog.ShowAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,7 +331,7 @@ namespace FancyZonesEditor
|
|||||||
Select((LayoutModel)dataContext);
|
Select((LayoutModel)dataContext);
|
||||||
EditLayoutDialog.Hide();
|
EditLayoutDialog.Hide();
|
||||||
var mainEditor = App.Overlay;
|
var mainEditor = App.Overlay;
|
||||||
if (!(mainEditor.CurrentDataContext is LayoutModel model))
|
if (mainEditor.CurrentDataContext is not LayoutModel model)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -415,7 +415,7 @@ namespace FancyZonesEditor
|
|||||||
Logger.LogTrace();
|
Logger.LogTrace();
|
||||||
|
|
||||||
var mainEditor = App.Overlay;
|
var mainEditor = App.Overlay;
|
||||||
if (!(mainEditor.CurrentDataContext is LayoutModel model))
|
if (mainEditor.CurrentDataContext is not LayoutModel model)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -527,8 +527,7 @@ namespace FancyZonesEditor
|
|||||||
|
|
||||||
private void TextBox_GotKeyboardFocus(object sender, RoutedEventArgs e)
|
private void TextBox_GotKeyboardFocus(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
TextBox tb = sender as TextBox;
|
if (sender is TextBox tb)
|
||||||
if (tb != null)
|
|
||||||
{
|
{
|
||||||
tb.SelectionStart = tb.Text.Length;
|
tb.SelectionStart = tb.Text.Length;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Globalization;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace FancyZonesEditor.Models
|
namespace FancyZonesEditor.Models
|
||||||
@@ -74,7 +75,9 @@ namespace FancyZonesEditor.Models
|
|||||||
|
|
||||||
public LayoutType Type { get; set; }
|
public LayoutType Type { get; set; }
|
||||||
|
|
||||||
|
#pragma warning disable CA1720 // Identifier contains type name (Not worth the effort to change this now.)
|
||||||
public Guid Guid
|
public Guid Guid
|
||||||
|
#pragma warning restore CA1720 // Identifier contains type name
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -181,16 +184,22 @@ namespace FancyZonesEditor.Models
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _quickKey == -1 ? Properties.Resources.Quick_Key_None : _quickKey.ToString();
|
return _quickKey == -1 ? Properties.Resources.Quick_Key_None : _quickKey.ToString(CultureInfo.CurrentCulture);
|
||||||
}
|
}
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
var intValue = -1;
|
||||||
string none = Properties.Resources.Quick_Key_None;
|
string none = Properties.Resources.Quick_Key_None;
|
||||||
var intValue = value == none ? -1 : int.Parse(value);
|
|
||||||
|
if (value != none && int.TryParse(value, out var parsedInt))
|
||||||
|
{
|
||||||
|
intValue = parsedInt;
|
||||||
|
}
|
||||||
|
|
||||||
if (intValue != _quickKey)
|
if (intValue != _quickKey)
|
||||||
{
|
{
|
||||||
string prev = _quickKey == -1 ? none : _quickKey.ToString();
|
string prev = _quickKey == -1 ? none : _quickKey.ToString(CultureInfo.CurrentCulture);
|
||||||
_quickKey = intValue;
|
_quickKey = intValue;
|
||||||
|
|
||||||
if (intValue != -1)
|
if (intValue != -1)
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ namespace FancyZonesEditor
|
|||||||
internal static class NativeMethods
|
internal static class NativeMethods
|
||||||
{
|
{
|
||||||
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Ansi)]
|
[DllImport("kernel32", SetLastError = true, CharSet = CharSet.Ansi)]
|
||||||
public static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPStr)] string lpFileName);
|
public static extern IntPtr LoadLibrary([MarshalAs(UnmanagedType.LPWStr)] string lpFileName);
|
||||||
|
|
||||||
[DllImport("kernel32", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true)]
|
[DllImport("kernel32", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
|
||||||
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
|
public static extern IntPtr GetProcAddress(IntPtr hModule, string procName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,5 +24,7 @@ namespace FancyZonesEditor
|
|||||||
public int Offset { get; }
|
public int Offset { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#pragma warning disable CA1711 // Identifiers should not have incorrect suffix (Causes warning in another class if fixed)
|
||||||
public delegate void SplitEventHandler(object sender, SplitEventArgs args);
|
public delegate void SplitEventHandler(object sender, SplitEventArgs args);
|
||||||
|
#pragma warning restore CA1711 // Identifiers should not have incorrect suffix
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,9 +35,6 @@ namespace FancyZonesEditor.Utils
|
|||||||
private const string CustomLayoutsFile = "\\Microsoft\\PowerToys\\FancyZones\\custom-layouts.json";
|
private const string CustomLayoutsFile = "\\Microsoft\\PowerToys\\FancyZones\\custom-layouts.json";
|
||||||
private const string ParamsFile = "\\Microsoft\\PowerToys\\FancyZones\\editor-parameters.json";
|
private const string ParamsFile = "\\Microsoft\\PowerToys\\FancyZones\\editor-parameters.json";
|
||||||
|
|
||||||
// Non-localizable string: Multi-monitor id
|
|
||||||
private const string MultiMonitorId = "FancyZones#MultiMonitorDevice";
|
|
||||||
|
|
||||||
// Non-localizable string: default virtual desktop id
|
// Non-localizable string: default virtual desktop id
|
||||||
private const string DefaultVirtualDesktopGuid = "{00000000-0000-0000-0000-000000000000}";
|
private const string DefaultVirtualDesktopGuid = "{00000000-0000-0000-0000-000000000000}";
|
||||||
|
|
||||||
@@ -317,7 +314,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
if (!App.Overlay.SpanZonesAcrossMonitors)
|
if (!App.Overlay.SpanZonesAcrossMonitors)
|
||||||
{
|
{
|
||||||
// Test launch with custom monitors configuration
|
// Test launch with custom monitors configuration
|
||||||
bool isCustomMonitorConfigurationMode = targetMonitorName.StartsWith("Monitor#");
|
bool isCustomMonitorConfigurationMode = targetMonitorName.StartsWith("Monitor#", StringComparison.Ordinal);
|
||||||
if (isCustomMonitorConfigurationMode)
|
if (isCustomMonitorConfigurationMode)
|
||||||
{
|
{
|
||||||
App.Overlay.Monitors.Clear();
|
App.Overlay.Monitors.Clear();
|
||||||
@@ -735,7 +732,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
{
|
{
|
||||||
LayoutHotkeyWrapper wrapper = new LayoutHotkeyWrapper
|
LayoutHotkeyWrapper wrapper = new LayoutHotkeyWrapper
|
||||||
{
|
{
|
||||||
Key = int.Parse(pair.Key),
|
Key = int.Parse(pair.Key, CultureInfo.CurrentCulture),
|
||||||
LayoutId = pair.Value,
|
LayoutId = pair.Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -906,7 +903,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Stream inputStream = _fileSystem.File.Open(fileName, FileMode.Open);
|
using (Stream inputStream = _fileSystem.File.Open(fileName, FileMode.Open))
|
||||||
using (StreamReader reader = new StreamReader(inputStream))
|
using (StreamReader reader = new StreamReader(inputStream))
|
||||||
{
|
{
|
||||||
string data = reader.ReadToEnd();
|
string data = reader.ReadToEnd();
|
||||||
@@ -948,11 +945,11 @@ namespace FancyZonesEditor.Utils
|
|||||||
bool unused = true;
|
bool unused = true;
|
||||||
foreach (Monitor monitor in monitors)
|
foreach (Monitor monitor in monitors)
|
||||||
{
|
{
|
||||||
string deviceIdSaved = monitor.Device.Id.Substring(0, monitor.Device.Id.LastIndexOf("_"));
|
string deviceIdSaved = monitor.Device.Id.Substring(0, monitor.Device.Id.LastIndexOf("_", StringComparison.Ordinal));
|
||||||
string deviceIdReadFromSettings = layout.DeviceId.Substring(0, layout.DeviceId.LastIndexOf("_"));
|
string deviceIdReadFromSettings = layout.DeviceId.Substring(0, layout.DeviceId.LastIndexOf("_", StringComparison.Ordinal));
|
||||||
|
|
||||||
string virtualDesktopIdSaved = monitor.Device.Id.Substring(monitor.Device.Id.LastIndexOf("_") + 1);
|
string virtualDesktopIdSaved = monitor.Device.Id.Substring(monitor.Device.Id.LastIndexOf("_", StringComparison.Ordinal) + 1);
|
||||||
string virtualDesktopIdReadFromSettings = layout.DeviceId.Substring(layout.DeviceId.LastIndexOf("_") + 1);
|
string virtualDesktopIdReadFromSettings = layout.DeviceId.Substring(layout.DeviceId.LastIndexOf("_", StringComparison.Ordinal) + 1);
|
||||||
|
|
||||||
if (deviceIdSaved == deviceIdReadFromSettings && (virtualDesktopIdSaved == virtualDesktopIdReadFromSettings || virtualDesktopIdReadFromSettings == DefaultVirtualDesktopGuid))
|
if (deviceIdSaved == deviceIdReadFromSettings && (virtualDesktopIdSaved == virtualDesktopIdReadFromSettings || virtualDesktopIdReadFromSettings == DefaultVirtualDesktopGuid))
|
||||||
{
|
{
|
||||||
@@ -1070,7 +1067,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
MainWindowSettingsModel.LayoutHotkeys.CleanUp();
|
MainWindowSettingsModel.LayoutHotkeys.CleanUp();
|
||||||
foreach (var wrapper in layoutHotkeys.LayoutHotkeys)
|
foreach (var wrapper in layoutHotkeys.LayoutHotkeys)
|
||||||
{
|
{
|
||||||
MainWindowSettingsModel.LayoutHotkeys.SelectKey(wrapper.Key.ToString(), wrapper.LayoutId);
|
MainWindowSettingsModel.LayoutHotkeys.SelectKey(wrapper.Key.ToString(CultureInfo.CurrentCulture), wrapper.LayoutId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace FancyZonesEditor.Utils
|
|||||||
public static void SetWindowStyleToolWindow(Window hwnd)
|
public static void SetWindowStyleToolWindow(Window hwnd)
|
||||||
{
|
{
|
||||||
var helper = new WindowInteropHelper(hwnd).Handle;
|
var helper = new WindowInteropHelper(hwnd).Handle;
|
||||||
SetWindowLong(helper, GWL_EX_STYLE, (GetWindowLong(helper, GWL_EX_STYLE) | WS_EX_TOOLWINDOW) & ~WS_EX_APPWINDOW);
|
_ = SetWindowLong(helper, GWL_EX_STYLE, (GetWindowLong(helper, GWL_EX_STYLE) | WS_EX_TOOLWINDOW) & ~WS_EX_APPWINDOW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace FancyZonesEditor.ViewModels
|
|||||||
|
|
||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
|
||||||
public delegate void MonitorChangedEventHandler(MonitorChangedEventArgs args);
|
public delegate void MonitorChangedEvent(MonitorChangedEventArgs args);
|
||||||
|
|
||||||
public ObservableCollection<MonitorInfoModel> MonitorInfoForViewModel { get; set; }
|
public ObservableCollection<MonitorInfoModel> MonitorInfoForViewModel { get; set; }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user