Skip to content

Commit 3204dea

Browse files
committed
整理代码
1 parent 8c78745 commit 3204dea

10 files changed

+48
-51
lines changed

Firefly/Behaviors/AutoRowNumberBehavior.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ namespace Firefly.Behaviors;
99

1010
public static class AutoRowNumberBehavior
1111
{
12-
public static readonly DependencyProperty EnableAutoRowNumbersProperty =
12+
public static readonly DependencyProperty IsEnabledProperty =
1313
DependencyProperty.RegisterAttached(
14-
"EnableAutoRowNumbers",
14+
"IsEnabled",
1515
typeof(bool),
1616
typeof(AutoRowNumberBehavior),
17-
new PropertyMetadata(false, OnEnableAutoRowNumbersChanged));
17+
new PropertyMetadata(false, OnIsEnabledChanged));
1818

19-
public static bool GetEnableAutoRowNumbers(DependencyObject obj)
19+
public static bool GetIsEnabled(DependencyObject obj)
2020
{
21-
return (bool)obj.GetValue(EnableAutoRowNumbersProperty);
21+
return (bool)obj.GetValue(IsEnabledProperty);
2222
}
2323

24-
public static void SetEnableAutoRowNumbers(DependencyObject obj, bool value)
24+
public static void SetIsEnabled(DependencyObject obj, bool value)
2525
{
26-
obj.SetValue(EnableAutoRowNumbersProperty, value);
26+
obj.SetValue(IsEnabledProperty, value);
2727
}
2828

2929
private static void ItemsControl_Loaded(object sender, RoutedEventArgs e)
@@ -52,7 +52,7 @@ void UnloadedHandler(object s, RoutedEventArgs args)
5252
RefreshRowNumbers(itemsControl);
5353
}
5454

55-
private static void OnEnableAutoRowNumbersChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
55+
private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
5656
{
5757
if (d is not ItemsControl itemsControl)
5858
{

Firefly/Behaviors/AutoScrollBehavior.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ public static bool GetAllowPause(DependencyObject obj)
2727
return (bool)obj.GetValue(AllowPauseProperty);
2828
}
2929

30-
public static bool GetIsEnabled(DependencyObject element)
30+
public static bool GetIsEnabled(DependencyObject obj)
3131
{
32-
return (bool)element.GetValue(IsEnabledProperty);
32+
return (bool)obj.GetValue(IsEnabledProperty);
3333
}
3434

3535
public static void SetAllowPause(DependencyObject obj, bool value)
3636
{
3737
obj.SetValue(AllowPauseProperty, value);
3838
}
3939

40-
public static void SetIsEnabled(DependencyObject element, bool value)
40+
public static void SetIsEnabled(DependencyObject obj, bool value)
4141
{
42-
element.SetValue(IsEnabledProperty, value);
42+
obj.SetValue(IsEnabledProperty, value);
4343
}
4444

4545
private static void ItemsControl_Loaded(object sender, RoutedEventArgs e)

Firefly/Behaviors/DataGridScrollFindableToCenterBehavior.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ namespace Firefly.Behaviors;
1515

1616
public class DataGridScrollFindableToCenterBehavior : Behavior<DataGrid>, IScrollFindableToCenter
1717
{
18-
// Using a DependencyProperty as the backing store for Client. This enables animation, styling, binding, etc...
1918
public static readonly DependencyProperty ClientProperty =
2019
DependencyProperty.Register(
2120
"Client",
2221
typeof(ISupportScrollFindableToCenterBehavior),
2322
typeof(DataGridScrollFindableToCenterBehavior),
2423
new PropertyMetadata(null));
2524

26-
// Using a DependencyProperty as the backing store for FindableScopes. This enables animation, styling, binding, etc...
2725
public static readonly DependencyProperty FindableScopesProperty =
2826
DependencyProperty.Register(
2927
"FindableScopes",

Firefly/Behaviors/IgnoreMouseWheelBehavior.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace Firefly.Behaviors;
1313
/// </summary>
1414
public sealed class IgnoreMouseWheelBehavior : Behavior<UIElement>
1515
{
16-
// Using a DependencyProperty as the backing store for IsEnabled. This enables animation, styling, binding, etc...
1716
public static readonly DependencyProperty IsEnabledProperty =
1817
DependencyProperty.RegisterAttached(
1918
"IsEnabled",
@@ -47,15 +46,15 @@ protected override void OnDetaching()
4746

4847
private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
4948
{
50-
if (d is UIElement uie)
49+
if (d is UIElement uiElement)
5150
{
5251
if ((bool)e.NewValue)
5352
{
54-
uie.PreviewMouseWheel += OnPreviewMouseWheel;
53+
uiElement.PreviewMouseWheel += OnPreviewMouseWheel;
5554
}
5655
else
5756
{
58-
uie.PreviewMouseWheel -= OnPreviewMouseWheel;
57+
uiElement.PreviewMouseWheel -= OnPreviewMouseWheel;
5958
}
6059
}
6160
}
@@ -69,11 +68,11 @@ private static void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
6968

7069
e.Handled = true;
7170

72-
var e2 = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) {
71+
var args = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) {
7372
RoutedEvent = UIElement.MouseWheelEvent
7473
};
7574

76-
((UIElement)sender).RaiseEvent(e2);
75+
((UIElement)sender).RaiseEvent(args);
7776
}
7877

7978
private void AssociatedObject_PreviewMouseWheel(object sender, MouseWheelEventArgs e)
@@ -85,10 +84,10 @@ private void AssociatedObject_PreviewMouseWheel(object sender, MouseWheelEventAr
8584

8685
e.Handled = true;
8786

88-
var e2 = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) {
87+
var args = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta) {
8988
RoutedEvent = UIElement.MouseWheelEvent
9089
};
9190

92-
AssociatedObject.RaiseEvent(e2);
91+
AssociatedObject.RaiseEvent(args);
9392
}
9493
}

Firefly/Behaviors/InputElementContextMenuBehavior.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ public static class InputElementContextMenuBehavior
1212
typeof(InputElementContextMenuBehavior),
1313
new PropertyMetadata(false, OnUseCustomStyleChanged));
1414

15-
public static bool GetUseCustomStyle(DependencyObject element)
15+
public static bool GetUseCustomStyle(DependencyObject obj)
1616
{
17-
return (bool)element.GetValue(UseCustomStyleProperty);
17+
return (bool)obj.GetValue(UseCustomStyleProperty);
1818
}
1919

20-
public static void SetUseCustomStyle(DependencyObject element, bool value)
20+
public static void SetUseCustomStyle(DependencyObject obj, bool value)
2121
{
22-
element.SetValue(UseCustomStyleProperty, value);
22+
obj.SetValue(UseCustomStyleProperty, value);
2323
}
2424

2525
private static void OnUseCustomStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

Firefly/Behaviors/ScrollViewerHelper.cs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,27 @@ public static class ScrollViewerHelper
2626
typeof(ScrollViewerHelper),
2727
new PropertyMetadata(1.0));
2828

29-
public static bool GetShiftWheelScrollsHorizontally(UIElement element)
29+
public static bool GetShiftWheelScrollsHorizontally(DependencyObject obj)
3030
{
31-
return (bool)element.GetValue(ShiftWheelScrollsHorizontallyProperty);
31+
return (bool)obj.GetValue(ShiftWheelScrollsHorizontallyProperty);
3232
}
3333

34-
public static double GetShiftWheelScrollSpeed(UIElement element)
34+
public static double GetShiftWheelScrollSpeed(DependencyObject obj)
3535
{
36-
return (double)element.GetValue(ShiftWheelScrollSpeedProperty);
36+
return (double)obj.GetValue(ShiftWheelScrollSpeedProperty);
3737
}
3838

39-
public static void SetShiftWheelScrollsHorizontally(UIElement element, bool value)
39+
public static void SetShiftWheelScrollsHorizontally(DependencyObject obj, bool value)
4040
{
41-
element.SetValue(ShiftWheelScrollsHorizontallyProperty, value);
41+
obj.SetValue(ShiftWheelScrollsHorizontallyProperty, value);
4242
}
4343

44-
// 默认滚动速率为 1.0
45-
public static void SetShiftWheelScrollSpeed(UIElement element, double value)
44+
public static void SetShiftWheelScrollSpeed(DependencyObject obj, double value)
4645
{
47-
element.SetValue(ShiftWheelScrollSpeedProperty, value);
46+
obj.SetValue(ShiftWheelScrollSpeedProperty, value);
4847
}
4948

50-
private static void OnPreviewMouseWheel(object sender, MouseWheelEventArgs args)
49+
private static void OnPreviewMouseWheel(object sender, MouseWheelEventArgs e)
5150
{
5251
if (Keyboard.Modifiers != ModifierKeys.Shift)
5352
{
@@ -67,27 +66,27 @@ private static void OnPreviewMouseWheel(object sender, MouseWheelEventArgs args)
6766
}
6867

6968
double scrollSpeed = GetShiftWheelScrollSpeed(d);
70-
double offset = scrollSpeed * (args.Delta > 0 ? -1 : 1);
69+
double offset = scrollSpeed * (e.Delta > 0 ? -1 : 1);
7170

7271
scrollViewer.ScrollToHorizontalOffset(scrollViewer.HorizontalOffset + (offset * 48));
7372

74-
args.Handled = true;
73+
e.Handled = true;
7574
}
7675

7776
private static void UseHorizontalScrollingChangedCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
7877
{
79-
if (d is not UIElement element)
78+
if (d is not UIElement uiElement)
8079
{
8180
throw new Exception("Attached property must be used with UIElement.");
8281
}
8382

8483
if ((bool)e.NewValue)
8584
{
86-
element.PreviewMouseWheel += OnPreviewMouseWheel;
85+
uiElement.PreviewMouseWheel += OnPreviewMouseWheel;
8786
}
8887
else
8988
{
90-
element.PreviewMouseWheel -= OnPreviewMouseWheel;
89+
uiElement.PreviewMouseWheel -= OnPreviewMouseWheel;
9190
}
9291
}
9392
}

Firefly/Behaviors/SplitButtonToggleDropDownBehavior.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Windows.Controls;
2+
using System.Windows.Input;
23
using System.Windows.Media;
34
using System.Windows.Shapes;
45

@@ -27,7 +28,7 @@ protected override void OnDetaching()
2728
base.OnDetaching();
2829
}
2930

30-
private void AssociatedObject_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
31+
private void AssociatedObject_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
3132
{
3233
var result = VisualTreeHelper.HitTest(AssociatedObject, e.GetPosition(AssociatedObject));
3334

Firefly/Behaviors/TripleClickToSelectAllBehavior.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ public class TripleClickToSelectAllBehavior
1616
typeof(TripleClickToSelectAllBehavior),
1717
new PropertyMetadata(false, OnPropertyChanged));
1818

19-
public static bool GetIsEnabled(DependencyObject element)
19+
public static bool GetIsEnabled(DependencyObject obj)
2020
{
21-
return (bool)element.GetValue(IsEnabledProperty);
21+
return (bool)obj.GetValue(IsEnabledProperty);
2222
}
2323

24-
public static void SetIsEnabled(DependencyObject element, bool value)
24+
public static void SetIsEnabled(DependencyObject obj, bool value)
2525
{
26-
element.SetValue(IsEnabledProperty, value);
26+
obj.SetValue(IsEnabledProperty, value);
2727
}
2828

2929
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
3030
{
31-
if (d is TextBox tb)
31+
if (d is TextBox textBox)
3232
{
3333
if ((bool)e.NewValue)
3434
{
35-
tb.PreviewMouseLeftButtonDown += OnTextBoxMouseDown;
35+
textBox.PreviewMouseLeftButtonDown += OnTextBoxMouseDown;
3636
}
3737
else
3838
{
39-
tb.PreviewMouseLeftButtonDown -= OnTextBoxMouseDown;
39+
textBox.PreviewMouseLeftButtonDown -= OnTextBoxMouseDown;
4040
}
4141
}
4242
}

Firefly/Views/CccfDbMergeWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@
176176
MinHeight="88"
177177
MaxHeight="310"
178178
Padding="4"
179-
b:AutoRowNumberBehavior.EnableAutoRowNumbers="True"
179+
b:AutoRowNumberBehavior.IsEnabled="True"
180180
d:ItemsSource="{d:SampleData ItemCount=5}"
181181
dd:DragDrop.CanDragWithMouseRightButton="False"
182182
dd:DragDrop.IsDragSource="True"

Firefly/Views/FireTableColumnMappingWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236
Margin="8,0,0,0"
237237
Header="跳过规则">
238238
<DataGrid x:Name="dgSkipRowRules"
239-
b:AutoRowNumberBehavior.EnableAutoRowNumbers="True"
239+
b:AutoRowNumberBehavior.IsEnabled="True"
240240
b:AutoScrollBehavior.IsEnabled="True"
241241
d:ItemsSource="{d:SampleData ItemCount=5}"
242242
dd:DragDrop.CanDragWithMouseRightButton="False"

0 commit comments

Comments
 (0)