code formatting
This commit is contained in:
1 parent
6a3711e6e0
commit
5afb569d11
43 files changed
+200
-287
No files matched your search
@@ -2333,7 +2333,6 @@
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
<Style x:Key="GroupBoxOriginalBaseStyle" BasedOn="{StaticResource GroupBoxBaseStyle}" TargetType="GroupBox">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
|
||||
<Setter Property="hc:BorderElement.CornerRadius" Value="0" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Top" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
@@ -9578,7 +9577,6 @@
|
||||
</Style>
|
||||
<Style x:Key="PropertyItemToolTipBaseStyle" BasedOn="{StaticResource {x:Type ToolTip}}" TargetType="ToolTip">
|
||||
<Setter Property="Padding" Value="10" />
|
||||
<Setter Property="hc:BorderElement.CornerRadius" Value="2" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToolTip">
|
||||
@@ -11342,7 +11340,7 @@
|
||||
<Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource CornerRadiusSplitConverter}, ConverterParameter='1,1,0,0'}" Grid.ColumnSpan="3" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" Name="PART_BorderTitle">
|
||||
<TextBlock x:Name="PART_TimeStr" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" Foreground="{DynamicResource TextIconBrush}" />
|
||||
</Border>
|
||||
<Canvas Grid.Row="1" Grid.ColumnSpan="3" Margin="0,16,0,0" VerticalAlignment="Top" Name="PART_Canvas" Width="178" Height="178">
|
||||
<Canvas Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Margin="0,16,0,0" VerticalAlignment="Top" Name="PART_Canvas" Width="178" Height="178">
|
||||
<Border Background="{DynamicResource SecondaryRegionBrush}" Width="178" Height="178" CornerRadius="89" />
|
||||
<hc:CirclePanel Diameter="130" x:Name="PART_PanelNum" KeepVertical="True" Margin="24,24,0,0" OffsetAngle="-60" />
|
||||
<Border Focusable="False" Name="PART_BorderClock" Background="{DynamicResource PrimaryBrush}" RenderTransformOrigin="0.5,1" Height="63" Width="2" Canvas.Left="88" Canvas.Top="26" />
|
||||
|
||||
@@ -517,7 +517,7 @@
|
||||
<value>TextDialog</value>
|
||||
</data>
|
||||
<data name="PleaseWait" xml:space="preserve">
|
||||
<value>Proszę czekać</value>
|
||||
<value>Proszę czekać...</value>
|
||||
</data>
|
||||
<data name="GrowlDemo" xml:space="preserve">
|
||||
<value>Growl demo</value>
|
||||
@@ -792,4 +792,7 @@
|
||||
<data name="Success" xml:space="preserve">
|
||||
<value>Success</value>
|
||||
</data>
|
||||
<data name="Empty" xml:space="preserve">
|
||||
<value>Empty</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -4,7 +4,6 @@
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
|
||||
xmlns:userControl="clr-namespace:HandyControlDemo.UserControl"
|
||||
DataContext="{Binding SplitButtonDemo,Source={StaticResource Locator}}">
|
||||
<hc:TransitioningContentControl>
|
||||
<StackPanel Margin="32" VerticalAlignment="Center">
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private static void OnShowRowNumberChanged(DependencyObject target, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(target is DataGrid dataGrid)) return;
|
||||
if (target is not DataGrid dataGrid) return;
|
||||
var show = (bool) e.NewValue;
|
||||
|
||||
if (show)
|
||||
@@ -277,7 +277,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private static void ItemContainerGenerator_ItemsChanged(object sender, ItemsChangedEventArgs e)
|
||||
{
|
||||
if (!(sender is ItemContainerGenerator generator)) return;
|
||||
if (sender is not ItemContainerGenerator generator) return;
|
||||
UpdateItems(generator, e.ItemCount);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,10 @@ namespace HandyControl.Controls
|
||||
{
|
||||
var topLine = (FrameworkElement) d;
|
||||
|
||||
if (e.NewValue is Popup popup)
|
||||
if (e.NewValue is Popup {TemplatedParent: MenuItem menuItem})
|
||||
{
|
||||
if (popup.TemplatedParent is MenuItem menuItem)
|
||||
{
|
||||
SetTopLine(menuItem, topLine);
|
||||
menuItem.Loaded += MenuItem_Loaded;
|
||||
}
|
||||
SetTopLine(menuItem, topLine);
|
||||
menuItem.Loaded += MenuItem_Loaded;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private static void OnInstanceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is FrameworkElement target)) return;
|
||||
if (d is not FrameworkElement target) return;
|
||||
var element = (AdornerElement) e.NewValue;
|
||||
element.OnInstanceChanged(target);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private static void OnDataChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is UIElement target)) return;
|
||||
if (d is not UIElement target) return;
|
||||
|
||||
target.PreviewMouseLeftButtonDown -= Target_PreviewMouseLeftButtonDown;
|
||||
target.PreviewMouseLeftButtonUp -= Target_PreviewMouseLeftButtonUp;
|
||||
|
||||
@@ -535,7 +535,7 @@ namespace HandyControl.Controls
|
||||
var cIndex = _colorSeparateList.IndexOf(Color.FromRgb(list[0], list[1], list[2]));
|
||||
int sub;
|
||||
var direc = 0;
|
||||
if (cIndex < 5 && cIndex > 0)
|
||||
if (cIndex is < 5 and > 0)
|
||||
{
|
||||
var nextColorList = _colorSeparateList[cIndex + 1].ToList();
|
||||
var prevColorList = _colorSeparateList[cIndex - 1].ToList();
|
||||
@@ -666,29 +666,18 @@ namespace HandyControl.Controls
|
||||
private void NumericUpDownRgb_OnValueChanged(object sender, FunctionEventArgs<double> e)
|
||||
{
|
||||
if (!_appliedTemplate || !IsNeedUpdateInfo) return;
|
||||
if (e.OriginalSource is NumericUpDown ctl && ctl.Tag is string tag)
|
||||
if (e.OriginalSource is NumericUpDown {Tag: string tag})
|
||||
{
|
||||
var color = SelectedBrush.Color;
|
||||
IsNeedUpdateInfo = false;
|
||||
|
||||
switch (tag)
|
||||
SelectedBrush = tag switch
|
||||
{
|
||||
case "R":
|
||||
{
|
||||
SelectedBrush = new SolidColorBrush(Color.FromArgb(color.A, (byte) e.Info, color.G, color.B));
|
||||
break;
|
||||
}
|
||||
case "G":
|
||||
{
|
||||
SelectedBrush = new SolidColorBrush(Color.FromArgb(color.A, color.R, (byte) e.Info, color.B));
|
||||
break;
|
||||
}
|
||||
case "B":
|
||||
{
|
||||
SelectedBrush = new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, (byte) e.Info));
|
||||
break;
|
||||
}
|
||||
}
|
||||
"R" => new SolidColorBrush(Color.FromArgb(color.A, (byte) e.Info, color.G, color.B)),
|
||||
"G" => new SolidColorBrush(Color.FromArgb(color.A, color.R, (byte) e.Info, color.B)),
|
||||
"B" => new SolidColorBrush(Color.FromArgb(color.A, color.R, color.G, (byte) e.Info)),
|
||||
_ => SelectedBrush
|
||||
};
|
||||
|
||||
IsNeedUpdateInfo = true;
|
||||
}
|
||||
@@ -704,10 +693,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private void ToggleButtonDropper_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_colorDropper == null)
|
||||
{
|
||||
_colorDropper = new ColorDropper(this);
|
||||
}
|
||||
_colorDropper ??= new ColorDropper(this);
|
||||
// ReSharper disable once PossibleInvalidOperationException
|
||||
_colorDropper.Update(_toggleButtonDropper.IsChecked.Value);
|
||||
}
|
||||
@@ -730,7 +716,6 @@ namespace HandyControl.Controls
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public bool CanDispose { get; } = true;
|
||||
|
||||
public bool CanDispose => true;
|
||||
}
|
||||
}
|
||||
@@ -208,7 +208,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private void Tags_OnClosed(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (e.OriginalSource is Tag tag && tag.Tag is CheckComboBoxItem checkComboBoxItem)
|
||||
if (e.OriginalSource is Tag {Tag: CheckComboBoxItem checkComboBoxItem})
|
||||
{
|
||||
checkComboBoxItem.SetCurrentValue(IsSelectedProperty, false);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,13 @@ namespace HandyControl.Controls
|
||||
public static readonly DependencyProperty IsDropDownOpenProperty = DependencyProperty.Register(
|
||||
"IsDropDownOpen", typeof(bool), typeof(DateTimePicker), new FrameworkPropertyMetadata(ValueBoxes.FalseBox, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDropDownOpenChanged, OnCoerceIsDropDownOpen));
|
||||
|
||||
private static object OnCoerceIsDropDownOpen(DependencyObject d, object baseValue) => d is DateTimePicker dp && !dp.IsEnabled ? false : baseValue;
|
||||
private static object OnCoerceIsDropDownOpen(DependencyObject d, object baseValue) =>
|
||||
d is DateTimePicker
|
||||
{
|
||||
IsEnabled: false
|
||||
}
|
||||
? false
|
||||
: baseValue;
|
||||
|
||||
private static void OnIsDropDownOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
@@ -172,7 +178,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private static void OnSelectedDateTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is DateTimePicker dp)) return;
|
||||
if (d is not DateTimePicker dp) return;
|
||||
|
||||
if (dp.SelectedDateTime.HasValue)
|
||||
{
|
||||
@@ -555,7 +561,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private void PopupPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is Popup popup && !popup.StaysOpen)
|
||||
if (sender is Popup {StaysOpen: false})
|
||||
{
|
||||
if (_dropDownButton?.InputHitTest(e.GetPosition(_dropDownButton)) != null)
|
||||
{
|
||||
|
||||
@@ -302,21 +302,18 @@ namespace HandyControl.Controls
|
||||
ActualPasswordBox.SetBinding(System.Windows.Controls.PasswordBox.SelectionOpacityProperty, new Binding(SelectionOpacityProperty.Name) { Source = this });
|
||||
ActualPasswordBox.SetBinding(System.Windows.Controls.PasswordBox.CaretBrushProperty, new Binding(CaretBrushProperty.Name) { Source = this });
|
||||
|
||||
if (_password != null)
|
||||
if (_password is {Length: > 0})
|
||||
{
|
||||
if (_password.Length > 0)
|
||||
var valuePtr = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
var valuePtr = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
valuePtr = Marshal.SecureStringToGlobalAllocUnicode(_password);
|
||||
ActualPasswordBox.Password = Marshal.PtrToStringUni(valuePtr) ?? throw new InvalidOperationException();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.ZeroFreeGlobalAllocUnicode(valuePtr);
|
||||
_password.Clear();
|
||||
}
|
||||
valuePtr = Marshal.SecureStringToGlobalAllocUnicode(_password);
|
||||
ActualPasswordBox.Password = Marshal.PtrToStringUni(valuePtr) ?? throw new InvalidOperationException();
|
||||
}
|
||||
finally
|
||||
{
|
||||
Marshal.ZeroFreeGlobalAllocUnicode(valuePtr);
|
||||
_password.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +142,13 @@ namespace HandyControl.Controls
|
||||
typeof(TimePicker),
|
||||
new FrameworkPropertyMetadata(ValueBoxes.FalseBox, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsDropDownOpenChanged, OnCoerceIsDropDownOpen));
|
||||
|
||||
private static object OnCoerceIsDropDownOpen(DependencyObject d, object baseValue) => d is TimePicker dp && !dp.IsEnabled ? false : baseValue;
|
||||
private static object OnCoerceIsDropDownOpen(DependencyObject d, object baseValue) =>
|
||||
d is TimePicker
|
||||
{
|
||||
IsEnabled: false
|
||||
}
|
||||
? false
|
||||
: baseValue;
|
||||
|
||||
private static void OnIsDropDownOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
@@ -183,7 +189,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private static void OnSelectedTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (!(d is TimePicker dp)) return;
|
||||
if (d is not TimePicker dp) return;
|
||||
|
||||
if (dp.SelectedTime.HasValue)
|
||||
{
|
||||
@@ -340,16 +346,14 @@ namespace HandyControl.Controls
|
||||
private static void OnClockChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var ctl = (TimePicker) d;
|
||||
var oldClock = e.OldValue as ClockBase;
|
||||
var newClock = e.NewValue as ClockBase;
|
||||
|
||||
if (oldClock != null)
|
||||
if (e.OldValue is ClockBase oldClock)
|
||||
{
|
||||
oldClock.SelectedTimeChanged -= ctl.Clock_SelectedTimeChanged;
|
||||
oldClock.Confirmed -= ctl.Clock_Confirmed;
|
||||
}
|
||||
|
||||
if (newClock != null)
|
||||
if (e.NewValue is ClockBase newClock)
|
||||
{
|
||||
newClock.ShowConfirmButton = true;
|
||||
newClock.SelectedTimeChanged += ctl.Clock_SelectedTimeChanged;
|
||||
@@ -589,7 +593,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private void PopupPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (sender is Popup popup && !popup.StaysOpen)
|
||||
if (sender is Popup {StaysOpen: false})
|
||||
{
|
||||
if (_dropDownButton?.InputHitTest(e.GetPosition(_dropDownButton)) != null)
|
||||
{
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
layer.Remove(_adornerContainer);
|
||||
}
|
||||
else if (_adornerContainer != null && _adornerContainer.Parent is AdornerLayer parent)
|
||||
else if (_adornerContainer is {Parent: AdornerLayer parent})
|
||||
{
|
||||
parent.Remove(_adornerContainer);
|
||||
}
|
||||
|
||||
@@ -192,21 +192,14 @@ namespace HandyControl.Controls
|
||||
szInfo = content ?? string.Empty
|
||||
};
|
||||
|
||||
switch (infoType)
|
||||
data.dwInfoFlags = infoType switch
|
||||
{
|
||||
case NotifyIconInfoType.Info:
|
||||
data.dwInfoFlags = InteropValues.NIIF_INFO;
|
||||
break;
|
||||
case NotifyIconInfoType.Warning:
|
||||
data.dwInfoFlags = InteropValues.NIIF_WARNING;
|
||||
break;
|
||||
case NotifyIconInfoType.Error:
|
||||
data.dwInfoFlags = InteropValues.NIIF_ERROR;
|
||||
break;
|
||||
case NotifyIconInfoType.None:
|
||||
data.dwInfoFlags = InteropValues.NIIF_NONE;
|
||||
break;
|
||||
}
|
||||
NotifyIconInfoType.Info => InteropValues.NIIF_INFO,
|
||||
NotifyIconInfoType.Warning => InteropValues.NIIF_WARNING,
|
||||
NotifyIconInfoType.Error => InteropValues.NIIF_ERROR,
|
||||
NotifyIconInfoType.None => InteropValues.NIIF_NONE,
|
||||
_ => data.dwInfoFlags
|
||||
};
|
||||
|
||||
InteropMethods.Shell_NotifyIcon(InteropValues.NIM_MODIFY, data);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private static object CoercePageIndex(DependencyObject d, object basevalue)
|
||||
{
|
||||
if (!(d is Pagination pagination)) return 1;
|
||||
if (d is not Pagination pagination) return 1;
|
||||
|
||||
var intValue = (int) basevalue;
|
||||
return intValue < 1
|
||||
@@ -392,7 +392,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private void ToggleButton_OnChecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!(e.OriginalSource is RadioButton button)) return;
|
||||
if (e.OriginalSource is not RadioButton button) return;
|
||||
if (button.IsChecked == false) return;
|
||||
PageIndex = int.Parse(button.Content.ToString());
|
||||
}
|
||||
|
||||
@@ -287,7 +287,7 @@ namespace HandyControl.Controls
|
||||
private void Element_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
var hitMode = GetIsInstance(Target) ? HitMode : GetHitMode(Target);
|
||||
if (hitMode != HitMode.Hover || hitMode == HitMode.None) return;
|
||||
if (hitMode != HitMode.Hover) return;
|
||||
|
||||
SwitchPoptip(true);
|
||||
}
|
||||
@@ -295,7 +295,7 @@ namespace HandyControl.Controls
|
||||
private void Element_MouseLeave(object sender, MouseEventArgs e)
|
||||
{
|
||||
var hitMode = GetIsInstance(Target) ? HitMode : GetHitMode(Target);
|
||||
if (hitMode != HitMode.Hover || hitMode == HitMode.None) return;
|
||||
if (hitMode != HitMode.Hover) return;
|
||||
|
||||
SwitchPoptip(false);
|
||||
}
|
||||
@@ -303,7 +303,7 @@ namespace HandyControl.Controls
|
||||
private void Element_GotFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var hitMode = GetIsInstance(Target) ? HitMode : GetHitMode(Target);
|
||||
if (hitMode != HitMode.Focus || hitMode == HitMode.None) return;
|
||||
if (hitMode != HitMode.Focus) return;
|
||||
|
||||
SwitchPoptip(true);
|
||||
}
|
||||
@@ -311,7 +311,7 @@ namespace HandyControl.Controls
|
||||
private void Element_LostFocus(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var hitMode = GetIsInstance(Target) ? HitMode : GetHitMode(Target);
|
||||
if (hitMode != HitMode.Focus || hitMode == HitMode.None) return;
|
||||
if (hitMode != HitMode.Focus) return;
|
||||
|
||||
SwitchPoptip(false);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace HandyControl.Controls
|
||||
private static bool OnSpanValidate(object value)
|
||||
{
|
||||
var v = (int) value;
|
||||
return v >= 1 && v <= 24;
|
||||
return v is >= 1 and <= 24;
|
||||
}
|
||||
|
||||
public int Span
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace HandyControl.Controls
|
||||
_ => new ReadOnlyTextPropertyEditor()
|
||||
}
|
||||
: type.IsSubclassOf(typeof(Enum))
|
||||
? (PropertyEditorBase) new EnumPropertyEditor()
|
||||
? new EnumPropertyEditor()
|
||||
: new ReadOnlyTextPropertyEditor();
|
||||
|
||||
public virtual PropertyEditorBase CreateEditor(Type type) => Activator.CreateInstance(type) as PropertyEditorBase ?? new ReadOnlyTextPropertyEditor();
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace HandyControl.Controls
|
||||
if (Role == SideMenuItemRole.Header && ItemsHost.Children.Count > 0)
|
||||
{
|
||||
var item = ItemsHost.Children.OfType<SideMenuItem>().FirstOrDefault();
|
||||
if (item != null && !item.IsSelected)
|
||||
if (item is {IsSelected: false})
|
||||
{
|
||||
item.OnSelected(new RoutedEventArgs(SelectedEvent, item));
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
layer.Remove(_adorner);
|
||||
}
|
||||
else if (_adorner != null && _adorner.Parent is AdornerLayer parent)
|
||||
else if (_adorner is {Parent: AdornerLayer parent})
|
||||
{
|
||||
parent.Remove(_adorner);
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace HandyControl.Controls
|
||||
|
||||
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
|
||||
{
|
||||
if (IsMoveToPointEnabled && _track.ThumbStart != null && !_track.ThumbStart.IsMouseOver && _track.ThumbEnd != null && !_track.ThumbEnd.IsMouseOver)
|
||||
if (IsMoveToPointEnabled && _track.ThumbStart is {IsMouseOver: false} && _track.ThumbEnd is {IsMouseOver: false})
|
||||
{
|
||||
// Here we need to determine whether it's closer to the starting point or the end point.
|
||||
var pt = e.MouseDevice.GetPosition(_track);
|
||||
@@ -301,7 +301,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
// If ticks collection is available, use it.
|
||||
// Note that ticks may be unsorted.
|
||||
if (Ticks != null && Ticks.Count > 0)
|
||||
if (Ticks is {Count: > 0})
|
||||
{
|
||||
foreach (var tick in Ticks)
|
||||
{
|
||||
@@ -341,7 +341,7 @@ namespace HandyControl.Controls
|
||||
var previous = Minimum;
|
||||
var next = Maximum;
|
||||
|
||||
if (Ticks != null && Ticks.Count > 0)
|
||||
if (Ticks is {Count: > 0})
|
||||
{
|
||||
foreach (var tick in Ticks)
|
||||
{
|
||||
@@ -429,7 +429,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
// Show AutoToolTip if needed.
|
||||
|
||||
if (!(e.OriginalSource is RangeThumb thumb)) return;
|
||||
if (e.OriginalSource is not RangeThumb thumb) return;
|
||||
_thumbCurrent = thumb;
|
||||
_originThumbPoint = Mouse.GetPosition(_thumbCurrent);
|
||||
_thumbCurrent.StartDrag();
|
||||
@@ -531,7 +531,7 @@ namespace HandyControl.Controls
|
||||
|
||||
protected virtual void OnThumbDragDelta(DragDeltaEventArgs e)
|
||||
{
|
||||
if (!(e.OriginalSource is Thumb thumb)) return;
|
||||
if (e.OriginalSource is not Thumb thumb) return;
|
||||
var isStart = thumb.Equals(_track.ThumbStart);
|
||||
if (!isStart)
|
||||
{
|
||||
@@ -579,7 +579,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
// Show AutoToolTip if needed.
|
||||
|
||||
if (!(e.OriginalSource is Thumb thumb) || AutoToolTipPlacement == AutoToolTipPlacement.None)
|
||||
if (e.OriginalSource is not Thumb thumb || AutoToolTipPlacement == AutoToolTipPlacement.None)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -397,10 +397,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (oldValue != newValue)
|
||||
{
|
||||
if (_visualChildren == null)
|
||||
{
|
||||
_visualChildren = new Visual[5];
|
||||
}
|
||||
_visualChildren ??= new Visual[5];
|
||||
|
||||
if (oldValue != null)
|
||||
{
|
||||
|
||||
@@ -236,7 +236,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
for (var i = 0; i < Items.Count; i++)
|
||||
{
|
||||
if (!(ItemContainerGenerator.ContainerFromIndex(i) is TabItem item)) return;
|
||||
if (ItemContainerGenerator.ContainerFromIndex(i) is not TabItem item) return;
|
||||
item.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
|
||||
item.TabPanel = HeaderPanel;
|
||||
}
|
||||
@@ -321,7 +321,7 @@ namespace HandyControl.Controls
|
||||
_buttonOverflow.Menu.Items.Clear();
|
||||
for (var i = 0; i < Items.Count; i++)
|
||||
{
|
||||
if (!(ItemContainerGenerator.ContainerFromIndex(i) is TabItem item)) continue;
|
||||
if (ItemContainerGenerator.ContainerFromIndex(i) is not TabItem item) continue;
|
||||
|
||||
var menuItem = new MenuItem
|
||||
{
|
||||
@@ -350,14 +350,10 @@ namespace HandyControl.Controls
|
||||
{
|
||||
list.Remove(actualItem);
|
||||
list.Insert(0, actualItem);
|
||||
if (IsAnimationEnabled)
|
||||
{
|
||||
HeaderPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, new Duration(TimeSpan.FromMilliseconds(200)));
|
||||
}
|
||||
else
|
||||
{
|
||||
HeaderPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey, new Duration(TimeSpan.FromMilliseconds(0)));
|
||||
}
|
||||
HeaderPanel.SetValue(TabPanel.FluidMoveDurationPropertyKey,
|
||||
IsAnimationEnabled
|
||||
? new Duration(TimeSpan.FromMilliseconds(200))
|
||||
: new Duration(TimeSpan.FromMilliseconds(0)));
|
||||
HeaderPanel.ForceUpdate = true;
|
||||
HeaderPanel.Measure(new Size(HeaderPanel.DesiredSize.Width, ActualHeight));
|
||||
HeaderPanel.ForceUpdate = false;
|
||||
@@ -396,7 +392,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
var argsClosing = new CancelRoutedEventArgs(TabItem.ClosingEvent, item);
|
||||
|
||||
if (!(ItemContainerGenerator.ContainerFromItem(item) is TabItem tabItem)) continue;
|
||||
if (ItemContainerGenerator.ContainerFromItem(item) is not TabItem tabItem) continue;
|
||||
|
||||
tabItem.RaiseEvent(argsClosing);
|
||||
if (argsClosing.Cancel) return;
|
||||
|
||||
@@ -173,11 +173,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (_isHandlerSuspended == null)
|
||||
{
|
||||
_isHandlerSuspended = new Dictionary<DependencyProperty, bool>(2);
|
||||
}
|
||||
|
||||
_isHandlerSuspended ??= new Dictionary<DependencyProperty, bool>(2);
|
||||
_isHandlerSuspended[property] = true;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
@@ -110,6 +111,7 @@ namespace HandyControl.Controls
|
||||
selector.ItemsSource = list;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "MergeIntoPattern")]
|
||||
private void Update()
|
||||
{
|
||||
if (_hourList.SelectedIndex >= 0 && _hourList.SelectedIndex < 24 &&
|
||||
|
||||
@@ -114,7 +114,7 @@ namespace HandyControl.Controls
|
||||
|
||||
private static void OnSelectedTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is TimeBar timeBar && timeBar._textBlockSelected != null)
|
||||
if (d is TimeBar {_textBlockSelected: { }} timeBar)
|
||||
{
|
||||
timeBar.OnSelectedTimeChanged((DateTime) e.NewValue);
|
||||
}
|
||||
@@ -403,25 +403,17 @@ namespace HandyControl.Controls
|
||||
/// <returns></returns>
|
||||
private DateTime TimeConvert(DateTime time)
|
||||
{
|
||||
switch (_speIndex)
|
||||
return _speIndex switch
|
||||
{
|
||||
case 0:
|
||||
return new DateTime(time.Year, time.Month, time.Day, time.Hour / 2 * 2, 0, 0);
|
||||
case 1:
|
||||
return new DateTime(time.Year, time.Month, time.Day, time.Hour, 0, 0);
|
||||
case 2:
|
||||
return new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute / 30 * 30, 0);
|
||||
case 3:
|
||||
return new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute / 10 * 10, 0);
|
||||
case 4:
|
||||
return new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute / 5 * 5, 0);
|
||||
case 5:
|
||||
return new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute, 0);
|
||||
case 6:
|
||||
return new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second / 30 * 30);
|
||||
default:
|
||||
return time;
|
||||
}
|
||||
0 => new DateTime(time.Year, time.Month, time.Day, time.Hour / 2 * 2, 0, 0),
|
||||
1 => new DateTime(time.Year, time.Month, time.Day, time.Hour, 0, 0),
|
||||
2 => new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute / 30 * 30, 0),
|
||||
3 => new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute / 10 * 10, 0),
|
||||
4 => new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute / 5 * 5, 0),
|
||||
5 => new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute, 0),
|
||||
6 => new DateTime(time.Year, time.Month, time.Day, time.Hour, time.Minute, time.Second / 30 * 30),
|
||||
_ => time
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -628,6 +628,7 @@ namespace HandyControl.Controls
|
||||
|| value == MessageBoxButton.YesNoCancel;
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "ConditionIsAlwaysTrueOrFalse")]
|
||||
private static bool IsValidMessageBoxImage(MessageBoxImage value)
|
||||
{
|
||||
return value == MessageBoxImage.Asterisk
|
||||
|
||||
@@ -21,19 +21,13 @@ namespace HandyControl.Expression.Drawing
|
||||
arcSegment.Size.Height, arcSegment.RotationAngle, arcSegment.IsLargeArc,
|
||||
arcSegment.SweepDirection == SweepDirection.Clockwise, arcSegment.Point.X, arcSegment.Point.Y,
|
||||
out var pointArray, out var num);
|
||||
switch (num)
|
||||
return num switch
|
||||
{
|
||||
case -1:
|
||||
return null;
|
||||
|
||||
case 0:
|
||||
return CreateLineSegment(arcSegment.Point, isStroked);
|
||||
|
||||
case 1:
|
||||
return CreateBezierSegment(pointArray[0], pointArray[1], pointArray[2], isStroked);
|
||||
}
|
||||
|
||||
return CreatePolyBezierSegment(pointArray, 0, num * 3, isStroked);
|
||||
-1 => null,
|
||||
0 => CreateLineSegment(arcSegment.Point, isStroked),
|
||||
1 => CreateBezierSegment(pointArray[0], pointArray[1], pointArray[2], isStroked),
|
||||
_ => CreatePolyBezierSegment(pointArray, 0, num * 3, isStroked)
|
||||
};
|
||||
}
|
||||
|
||||
public static ArcSegment CreateArcSegment(Point point, Size size, bool isLargeArc, bool clockwise,
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace HandyControl.Interactivity
|
||||
{
|
||||
if (parameter is DependencyObject dependencyObject)
|
||||
{
|
||||
if (Window.GetWindow(dependencyObject) is Window window)
|
||||
if (Window.GetWindow(dependencyObject) is { } window)
|
||||
{
|
||||
window.Close();
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ namespace HandyControl.Interactivity
|
||||
private static ResourceManager ResourceMan;
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static ResourceManager ResourceManager => ResourceMan ?? (ResourceMan = new ResourceManager(nameof(ExceptionStringTable),
|
||||
typeof(ExceptionStringTable).Assembly));
|
||||
internal static ResourceManager ResourceManager => ResourceMan ??= new ResourceManager(nameof(ExceptionStringTable),
|
||||
typeof(ExceptionStringTable).Assembly);
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static CultureInfo Culture { get; set; }
|
||||
|
||||
@@ -490,44 +490,26 @@ namespace HandyControl.Interactivity
|
||||
var layoutSlot = LayoutInformation.GetLayoutSlot(element);
|
||||
var x = 0.0;
|
||||
var y = 0.0;
|
||||
switch (element.HorizontalAlignment)
|
||||
x = element.HorizontalAlignment switch
|
||||
{
|
||||
case HorizontalAlignment.Left:
|
||||
x = layoutSlot.Left + margin.Left;
|
||||
break;
|
||||
|
||||
case HorizontalAlignment.Center:
|
||||
x = (layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 - actualWidth / 2.0;
|
||||
break;
|
||||
|
||||
case HorizontalAlignment.Right:
|
||||
x = layoutSlot.Right - margin.Right - actualWidth;
|
||||
break;
|
||||
|
||||
case HorizontalAlignment.Stretch:
|
||||
x = Math.Max(layoutSlot.Left + margin.Left,
|
||||
(layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 - actualWidth / 2.0);
|
||||
break;
|
||||
}
|
||||
switch (element.VerticalAlignment)
|
||||
HorizontalAlignment.Left => layoutSlot.Left + margin.Left,
|
||||
HorizontalAlignment.Center => (layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 -
|
||||
actualWidth / 2.0,
|
||||
HorizontalAlignment.Right => layoutSlot.Right - margin.Right - actualWidth,
|
||||
HorizontalAlignment.Stretch => Math.Max(layoutSlot.Left + margin.Left,
|
||||
(layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 - actualWidth / 2.0),
|
||||
_ => x
|
||||
};
|
||||
y = element.VerticalAlignment switch
|
||||
{
|
||||
case VerticalAlignment.Top:
|
||||
y = layoutSlot.Top + margin.Top;
|
||||
break;
|
||||
|
||||
case VerticalAlignment.Center:
|
||||
y = (layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 - actualHeight / 2.0;
|
||||
break;
|
||||
|
||||
case VerticalAlignment.Bottom:
|
||||
y = layoutSlot.Bottom - margin.Bottom - actualHeight;
|
||||
break;
|
||||
|
||||
case VerticalAlignment.Stretch:
|
||||
y = Math.Max(layoutSlot.Top + margin.Top,
|
||||
(layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 - actualHeight / 2.0);
|
||||
break;
|
||||
}
|
||||
VerticalAlignment.Top => layoutSlot.Top + margin.Top,
|
||||
VerticalAlignment.Center => (layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 -
|
||||
actualHeight / 2.0,
|
||||
VerticalAlignment.Bottom => layoutSlot.Bottom - margin.Bottom - actualHeight,
|
||||
VerticalAlignment.Stretch => Math.Max(layoutSlot.Top + margin.Top,
|
||||
(layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 - actualHeight / 2.0),
|
||||
_ => y
|
||||
};
|
||||
return new Rect(x, y, actualWidth, actualHeight);
|
||||
}
|
||||
|
||||
|
||||
@@ -234,4 +234,7 @@
|
||||
<data name="All" xml:space="preserve">
|
||||
<value>Wszystkie</value>
|
||||
</data>
|
||||
<data name="NoData" xml:space="preserve">
|
||||
<value>No Data</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -96,7 +96,6 @@
|
||||
</ControlTemplate>
|
||||
|
||||
<Style x:Key="GroupBoxOriginalBaseStyle" BasedOn="{StaticResource GroupBoxBaseStyle}" TargetType="GroupBox">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
|
||||
<Setter Property="hc:BorderElement.CornerRadius" Value="0"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Top"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
|
||||
<Style x:Key="PropertyItemToolTipBaseStyle" BasedOn="{StaticResource {x:Type ToolTip}}" TargetType="ToolTip">
|
||||
<Setter Property="Padding" Value="10"/>
|
||||
<Setter Property="hc:BorderElement.CornerRadius" Value="2"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToolTip">
|
||||
|
||||
@@ -90,7 +90,7 @@
|
||||
<Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource CornerRadiusSplitConverter}, ConverterParameter='1,1,0,0'}" Grid.ColumnSpan="3" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" Name="PART_BorderTitle">
|
||||
<TextBlock x:Name="PART_TimeStr" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" Foreground="{DynamicResource TextIconBrush}"/>
|
||||
</Border>
|
||||
<Canvas Grid.Row="1" Grid.ColumnSpan="3" Margin="0,16,0,0" VerticalAlignment="Top" Name="PART_Canvas" Width="178" Height="178">
|
||||
<Canvas Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Margin="0,16,0,0" VerticalAlignment="Top" Name="PART_Canvas" Width="178" Height="178">
|
||||
<Border Background="{DynamicResource SecondaryRegionBrush}" Width="178" Height="178" CornerRadius="89"/>
|
||||
<hc:CirclePanel Diameter="130" x:Name="PART_PanelNum" KeepVertical="True" Margin="24,24,0,0" OffsetAngle="-60"/>
|
||||
<Border Focusable="False" Name="PART_BorderClock" Background="{DynamicResource PrimaryBrush}" RenderTransformOrigin="0.5,1" Height="63" Width="2" Canvas.Left="88" Canvas.Top="26"/>
|
||||
|
||||
@@ -2333,7 +2333,6 @@
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
<Style x:Key="GroupBoxOriginalBaseStyle" BasedOn="{StaticResource GroupBoxBaseStyle}" TargetType="GroupBox">
|
||||
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}" />
|
||||
<Setter Property="hc:BorderElement.CornerRadius" Value="0" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Top" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
@@ -9696,7 +9695,6 @@
|
||||
</Style>
|
||||
<Style x:Key="PropertyItemToolTipBaseStyle" BasedOn="{StaticResource {x:Type ToolTip}}" TargetType="ToolTip">
|
||||
<Setter Property="Padding" Value="10" />
|
||||
<Setter Property="hc:BorderElement.CornerRadius" Value="2" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToolTip">
|
||||
@@ -11475,7 +11473,7 @@
|
||||
<Border CornerRadius="{Binding Path=(hc:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource CornerRadiusSplitConverter}, ConverterParameter='1,1,0,0'}" Grid.ColumnSpan="3" Background="{Binding Path=(hc:TitleElement.Background),RelativeSource={RelativeSource TemplatedParent}}" Name="PART_BorderTitle">
|
||||
<TextBlock x:Name="PART_TimeStr" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="20" Foreground="{DynamicResource TextIconBrush}" />
|
||||
</Border>
|
||||
<Canvas Grid.Row="1" Grid.ColumnSpan="3" Margin="0,16,0,0" VerticalAlignment="Top" Name="PART_Canvas" Width="178" Height="178">
|
||||
<Canvas Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Margin="0,16,0,0" VerticalAlignment="Top" Name="PART_Canvas" Width="178" Height="178">
|
||||
<Border Background="{DynamicResource SecondaryRegionBrush}" Width="178" Height="178" CornerRadius="89" />
|
||||
<hc:CirclePanel Diameter="130" x:Name="PART_PanelNum" KeepVertical="True" Margin="24,24,0,0" OffsetAngle="-60" />
|
||||
<Border Focusable="False" Name="PART_BorderClock" Background="{DynamicResource PrimaryBrush}" RenderTransformOrigin="0.5,1" Height="63" Width="2" Canvas.Left="88" Canvas.Top="26" />
|
||||
|
||||
@@ -79,38 +79,26 @@ namespace HandyControl.Tools
|
||||
var layoutSlot = LayoutInformation.GetLayoutSlot(element);
|
||||
var x = 0.0;
|
||||
var y = 0.0;
|
||||
switch (element.HorizontalAlignment)
|
||||
x = element.HorizontalAlignment switch
|
||||
{
|
||||
case HorizontalAlignment.Left:
|
||||
x = layoutSlot.Left + margin.Left;
|
||||
break;
|
||||
case HorizontalAlignment.Center:
|
||||
x = (layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 - width / 2.0;
|
||||
break;
|
||||
case HorizontalAlignment.Right:
|
||||
x = layoutSlot.Right - margin.Right - width;
|
||||
break;
|
||||
case HorizontalAlignment.Stretch:
|
||||
x = Math.Max(layoutSlot.Left + margin.Left,
|
||||
(layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 - width / 2.0);
|
||||
break;
|
||||
}
|
||||
switch (element.VerticalAlignment)
|
||||
HorizontalAlignment.Left => layoutSlot.Left + margin.Left,
|
||||
HorizontalAlignment.Center => (layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 -
|
||||
width / 2.0,
|
||||
HorizontalAlignment.Right => layoutSlot.Right - margin.Right - width,
|
||||
HorizontalAlignment.Stretch => Math.Max(layoutSlot.Left + margin.Left,
|
||||
(layoutSlot.Left + margin.Left + layoutSlot.Right - margin.Right) / 2.0 - width / 2.0),
|
||||
_ => x
|
||||
};
|
||||
y = element.VerticalAlignment switch
|
||||
{
|
||||
case VerticalAlignment.Top:
|
||||
y = layoutSlot.Top + margin.Top;
|
||||
break;
|
||||
case VerticalAlignment.Center:
|
||||
y = (layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 - height / 2.0;
|
||||
break;
|
||||
case VerticalAlignment.Bottom:
|
||||
y = layoutSlot.Bottom - margin.Bottom - height;
|
||||
break;
|
||||
case VerticalAlignment.Stretch:
|
||||
y = Math.Max(layoutSlot.Top + margin.Top,
|
||||
(layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 - height / 2.0);
|
||||
break;
|
||||
}
|
||||
VerticalAlignment.Top => layoutSlot.Top + margin.Top,
|
||||
VerticalAlignment.Center => (layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 -
|
||||
height / 2.0,
|
||||
VerticalAlignment.Bottom => layoutSlot.Bottom - margin.Bottom - height,
|
||||
VerticalAlignment.Stretch => Math.Max(layoutSlot.Top + margin.Top,
|
||||
(layoutSlot.Top + margin.Top + layoutSlot.Bottom - margin.Bottom) / 2.0 - height / 2.0),
|
||||
_ => y
|
||||
};
|
||||
return new Rect(x, y, width, height);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
using System.Windows;
|
||||
@@ -9,6 +10,8 @@ using HandyControl.Tools.Interop;
|
||||
|
||||
namespace HandyControl.Tools
|
||||
{
|
||||
[SuppressMessage("ReSharper", "ArrangeRedundantParentheses")]
|
||||
[SuppressMessage("ReSharper", "IntVariableOverflowInUncheckedContext")]
|
||||
internal static class IconHelper
|
||||
{
|
||||
private static Size SmallIconSize;
|
||||
|
||||
@@ -12,10 +12,7 @@ namespace HandyControl.Tools
|
||||
[SecurityCritical]
|
||||
internal static void DemandUIWindowPermission()
|
||||
{
|
||||
if (_allWindowsUIPermission == null)
|
||||
{
|
||||
_allWindowsUIPermission = new UIPermission(UIPermissionWindow.AllWindows);
|
||||
}
|
||||
_allWindowsUIPermission ??= new UIPermission(UIPermissionWindow.AllWindows);
|
||||
_allWindowsUIPermission.Demand();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace HandyControl.Tools.Interop
|
||||
internal static BitmapHandle CreateDIBSection(HandleRef hdc, ref InteropValues.BITMAPINFO bitmapInfo, int iUsage,
|
||||
ref IntPtr ppvBits, SafeFileMappingHandle hSection, int dwOffset)
|
||||
{
|
||||
if (hSection == null) hSection = new SafeFileMappingHandle(IntPtr.Zero);
|
||||
hSection ??= new SafeFileMappingHandle(IntPtr.Zero);
|
||||
|
||||
var hBitmap = PrivateCreateDIBSection(hdc, ref bitmapInfo, iUsage, ref ppvBits, hSection, dwOffset);
|
||||
return hBitmap;
|
||||
@@ -547,7 +547,7 @@ namespace HandyControl.Tools.Interop
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct StartupOutput
|
||||
private readonly struct StartupOutput
|
||||
{
|
||||
private readonly IntPtr hook;
|
||||
|
||||
@@ -613,31 +613,30 @@ namespace HandyControl.Tools.Interop
|
||||
|
||||
internal static Exception StatusException(int status)
|
||||
{
|
||||
switch (status)
|
||||
return status switch
|
||||
{
|
||||
case GenericError: return new ExternalException("GdiplusGenericError");
|
||||
case InvalidParameter: return new ArgumentException("GdiplusInvalidParameter");
|
||||
case OutOfMemory: return new OutOfMemoryException("GdiplusOutOfMemory");
|
||||
case ObjectBusy: return new InvalidOperationException("GdiplusObjectBusy");
|
||||
case InsufficientBuffer: return new OutOfMemoryException("GdiplusInsufficientBuffer");
|
||||
case NotImplemented: return new NotImplementedException("GdiplusNotImplemented");
|
||||
case Win32Error: return new ExternalException("GdiplusGenericError");
|
||||
case WrongState: return new InvalidOperationException("GdiplusWrongState");
|
||||
case Aborted: return new ExternalException("GdiplusAborted");
|
||||
case FileNotFound: return new FileNotFoundException("GdiplusFileNotFound");
|
||||
case ValueOverflow: return new OverflowException("GdiplusOverflow");
|
||||
case AccessDenied: return new ExternalException("GdiplusAccessDenied");
|
||||
case UnknownImageFormat: return new ArgumentException("GdiplusUnknownImageFormat");
|
||||
case PropertyNotFound: return new ArgumentException("GdiplusPropertyNotFoundError");
|
||||
case PropertyNotSupported: return new ArgumentException("GdiplusPropertyNotSupportedError");
|
||||
case FontFamilyNotFound: return new ArgumentException("GdiplusFontFamilyNotFound");
|
||||
case FontStyleNotFound: return new ArgumentException("GdiplusFontStyleNotFound");
|
||||
case NotTrueTypeFont: return new ArgumentException("GdiplusNotTrueTypeFont_NoName");
|
||||
case UnsupportedGdiplusVersion: return new ExternalException("GdiplusUnsupportedGdiplusVersion");
|
||||
case GdiplusNotInitialized: return new ExternalException("GdiplusNotInitialized");
|
||||
}
|
||||
|
||||
return new ExternalException("GdiplusUnknown");
|
||||
GenericError => new ExternalException("GdiplusGenericError"),
|
||||
InvalidParameter => new ArgumentException("GdiplusInvalidParameter"),
|
||||
OutOfMemory => new OutOfMemoryException("GdiplusOutOfMemory"),
|
||||
ObjectBusy => new InvalidOperationException("GdiplusObjectBusy"),
|
||||
InsufficientBuffer => new OutOfMemoryException("GdiplusInsufficientBuffer"),
|
||||
NotImplemented => new NotImplementedException("GdiplusNotImplemented"),
|
||||
Win32Error => new ExternalException("GdiplusGenericError"),
|
||||
WrongState => new InvalidOperationException("GdiplusWrongState"),
|
||||
Aborted => new ExternalException("GdiplusAborted"),
|
||||
FileNotFound => new FileNotFoundException("GdiplusFileNotFound"),
|
||||
ValueOverflow => new OverflowException("GdiplusOverflow"),
|
||||
AccessDenied => new ExternalException("GdiplusAccessDenied"),
|
||||
UnknownImageFormat => new ArgumentException("GdiplusUnknownImageFormat"),
|
||||
PropertyNotFound => new ArgumentException("GdiplusPropertyNotFoundError"),
|
||||
PropertyNotSupported => new ArgumentException("GdiplusPropertyNotSupportedError"),
|
||||
FontFamilyNotFound => new ArgumentException("GdiplusFontFamilyNotFound"),
|
||||
FontStyleNotFound => new ArgumentException("GdiplusFontStyleNotFound"),
|
||||
NotTrueTypeFont => new ArgumentException("GdiplusNotTrueTypeFont_NoName"),
|
||||
UnsupportedGdiplusVersion => new ExternalException("GdiplusUnsupportedGdiplusVersion"),
|
||||
GdiplusNotInitialized => new ExternalException("GdiplusNotInitialized"),
|
||||
_ => new ExternalException("GdiplusUnknown")
|
||||
};
|
||||
}
|
||||
|
||||
[DllImport(InteropValues.ExternDll.GdiPlus, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
|
||||
|
||||
@@ -53,15 +53,15 @@ namespace HandyControl.Tools
|
||||
/// <returns>方法返回布尔值</returns>
|
||||
public static bool IsIp(this string ip, IpType ipType)
|
||||
{
|
||||
switch (ipType)
|
||||
return ipType switch
|
||||
{
|
||||
case IpType.A: return Regex.IsMatch(ip, RegexPatterns.IpAPattern);
|
||||
case IpType.B: return Regex.IsMatch(ip, RegexPatterns.IpBPattern);
|
||||
case IpType.C: return Regex.IsMatch(ip, RegexPatterns.IpCPattern);
|
||||
case IpType.D: return Regex.IsMatch(ip, RegexPatterns.IpDPattern);
|
||||
case IpType.E: return Regex.IsMatch(ip, RegexPatterns.IpEPattern);
|
||||
default: return false;
|
||||
}
|
||||
IpType.A => Regex.IsMatch(ip, RegexPatterns.IpAPattern),
|
||||
IpType.B => Regex.IsMatch(ip, RegexPatterns.IpBPattern),
|
||||
IpType.C => Regex.IsMatch(ip, RegexPatterns.IpCPattern),
|
||||
IpType.D => Regex.IsMatch(ip, RegexPatterns.IpDPattern),
|
||||
IpType.E => Regex.IsMatch(ip, RegexPatterns.IpEPattern),
|
||||
_ => false
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -400,27 +400,15 @@ namespace Microsoft.Windows.Shell
|
||||
TBPF tbpFlags = TBPF.NOPROGRESS;
|
||||
if (attached)
|
||||
{
|
||||
switch (progressState)
|
||||
tbpFlags = progressState switch
|
||||
{
|
||||
case TaskbarItemProgressState.None:
|
||||
tbpFlags = TBPF.NOPROGRESS;
|
||||
break;
|
||||
case TaskbarItemProgressState.Indeterminate:
|
||||
tbpFlags = TBPF.INDETERMINATE;
|
||||
break;
|
||||
case TaskbarItemProgressState.Normal:
|
||||
tbpFlags = TBPF.NORMAL;
|
||||
break;
|
||||
case TaskbarItemProgressState.Error:
|
||||
tbpFlags = TBPF.ERROR;
|
||||
break;
|
||||
case TaskbarItemProgressState.Paused:
|
||||
tbpFlags = TBPF.PAUSED;
|
||||
break;
|
||||
default:
|
||||
tbpFlags = TBPF.NOPROGRESS;
|
||||
break;
|
||||
}
|
||||
TaskbarItemProgressState.None => TBPF.NOPROGRESS,
|
||||
TaskbarItemProgressState.Indeterminate => TBPF.INDETERMINATE,
|
||||
TaskbarItemProgressState.Normal => TBPF.NORMAL,
|
||||
TaskbarItemProgressState.Error => TBPF.ERROR,
|
||||
TaskbarItemProgressState.Paused => TBPF.PAUSED,
|
||||
_ => TBPF.NOPROGRESS
|
||||
};
|
||||
}
|
||||
HRESULT result = this._taskbarList.SetProgressState(this._hwndSource.Handle, tbpFlags);
|
||||
if (result.Succeeded)
|
||||
|
||||
@@ -433,15 +433,12 @@ namespace Microsoft.Windows.Shell
|
||||
private WindowState _GetHwndState()
|
||||
{
|
||||
WINDOWPLACEMENT windowPlacement = NativeMethods.GetWindowPlacement(this._hwnd);
|
||||
switch (windowPlacement.showCmd)
|
||||
return windowPlacement.showCmd switch
|
||||
{
|
||||
case SW.SHOWMINIMIZED:
|
||||
return WindowState.Minimized;
|
||||
case SW.SHOWMAXIMIZED:
|
||||
return WindowState.Maximized;
|
||||
default:
|
||||
return WindowState.Normal;
|
||||
}
|
||||
SW.SHOWMINIMIZED => WindowState.Minimized,
|
||||
SW.SHOWMAXIMIZED => WindowState.Maximized,
|
||||
_ => WindowState.Normal
|
||||
};
|
||||
}
|
||||
|
||||
private Rect _GetWindowRect()
|
||||
|
||||
Reference in new issue
Block a user