Skip to content

Commit c2fbd4b

Browse files
committed
Use linq methods in ThemePreviewer
1 parent 1de9db9 commit c2fbd4b

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

src/Skia/ThemePreviewer.cs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,11 @@ protected override void OnMouseClick(MouseEventArgs e)
154154
}
155155

156156
// Check if carousel indicator was clicked
157-
if (renderer.CarouselIndicatorRects != null)
157+
var clickedIndex = Array.FindIndex(renderer.CarouselIndicatorRects ?? [], r => r.Contains(e.Location));
158+
if (clickedIndex != -1)
158159
{
159-
for (int i = 0; i < renderer.CarouselIndicatorRects.Length; i++)
160-
{
161-
if (renderer.CarouselIndicatorRects[i].Contains(e.Location))
162-
{
163-
ViewModel.SelectedIndex = i;
164-
return;
165-
}
166-
}
160+
ViewModel.SelectedIndex = clickedIndex;
161+
return;
167162
}
168163
}
169164

@@ -199,19 +194,7 @@ protected override void OnMouseMove(MouseEventArgs e)
199194
}
200195

201196
// Check carousel indicators for hand cursor
202-
bool isOverCarouselIndicator = false;
203-
if (renderer.CarouselIndicatorRects != null)
204-
{
205-
foreach (var rect in renderer.CarouselIndicatorRects)
206-
{
207-
if (rect.Contains(e.Location))
208-
{
209-
isOverCarouselIndicator = true;
210-
break;
211-
}
212-
}
213-
}
214-
197+
bool isOverCarouselIndicator = renderer.CarouselIndicatorRects?.Any(r => r.Contains(e.Location)) ?? false;
215198
bool isOverClickable = hoveredItem != HoveredItem.None || isOverCarouselIndicator;
216199
Cursor = isOverClickable ? Cursors.Hand : Cursors.Default;
217200

0 commit comments

Comments
 (0)