code formatting
This commit is contained in:
1 parent
6a3711e6e0
commit
5afb569d11
43 files changed
+200
-287
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user