Skip to content

Commit 8908209

Browse files
committed
Extract local function in mousecomboviewmodel
1 parent 7385ac9 commit 8908209

1 file changed

Lines changed: 13 additions & 23 deletions

File tree

YMouseButtonControl.Core/ViewModels/LayerViewModel/MouseComboViewModel.cs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,41 +80,20 @@ IShowSimulatedKeystrokesDialogService showSimulatedKeystrokesDialogService
8080
switch (next.Direction)
8181
{
8282
case WheelScrollDirection.VerticalUp when mouseButton == MouseButton.Mwu:
83-
BackgroundColor = themeService.CurHighlight;
84-
if (!_wheelTimer.Enabled)
85-
{
86-
_wheelTimer.Start();
87-
}
88-
break;
8983
case WheelScrollDirection.VerticalDown when mouseButton == MouseButton.Mwd:
90-
BackgroundColor = themeService.CurHighlight;
91-
if (!_wheelTimer.Enabled)
92-
{
93-
_wheelTimer.Start();
94-
}
95-
break;
9684
case WheelScrollDirection.HorizontalRight
9785
when mouseButton == MouseButton.Mwr:
98-
BackgroundColor = themeService.CurHighlight;
99-
if (!_wheelTimer.Enabled)
100-
{
101-
_wheelTimer.Start();
102-
}
103-
break;
10486
case WheelScrollDirection.HorizontalLeft
10587
when mouseButton == MouseButton.Mwl:
106-
BackgroundColor = themeService.CurHighlight;
107-
if (!_wheelTimer.Enabled)
108-
{
109-
_wheelTimer.Start();
110-
}
88+
MouseWheelDoHighlight();
11189
break;
11290
}
11391
});
11492
break;
11593
default:
11694
throw new ArgumentOutOfRangeException(nameof(mouseButton), mouseButton, null);
11795
}
96+
11897
_profilesService = profilesService;
11998
SourceCache<BaseButtonMappingVm, int> sourceButtonMappings = new(x => x.Index);
12099
var myOp = sourceButtonMappings.Connect().AutoRefresh().Bind(out _btnMappings).Subscribe();
@@ -166,13 +145,24 @@ await ShowSimulatedKeystrokesDialogService.ShowSimulatedKeystrokesDialog(
166145
},
167146
canClickUserClickedSettingsBtn
168147
);
148+
return;
149+
150+
void MouseWheelDoHighlight()
151+
{
152+
BackgroundColor = themeService.CurHighlight;
153+
if (!_wheelTimer.Enabled)
154+
{
155+
_wheelTimer.Start();
156+
}
157+
}
169158
}
170159

171160
public IBrush BackgroundColor
172161
{
173162
get => _backgroundColor;
174163
set => this.RaiseAndSetIfChanged(ref _backgroundColor, value);
175164
}
165+
176166
public IShowSimulatedKeystrokesDialogService ShowSimulatedKeystrokesDialogService { get; }
177167

178168
public BaseButtonMappingVm? SelectedBtnMap

0 commit comments

Comments
 (0)