From a52a1f83f67f63386ea3a4fd5ff88acd9388558d Mon Sep 17 00:00:00 2001
From: NaBian <836904362@qq.com>
Date: Mon, 15 Nov 2021 23:07:42 +0800
Subject: [PATCH] chore: remove JumpTo method of ImageSelector
---
.../Controls/CoverFlowDemoCtl.xaml.cs | 3 ++-
.../Controls/Cover/CoverFlow/CoverFlow.cs | 22 +++++--------------
2 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml.cs b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml.cs
index c9cbf0bc..b482538a 100644
--- a/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml.cs
+++ b/src/Shared/HandyControlDemo_Shared/UserControl/Controls/CoverFlowDemoCtl.xaml.cs
@@ -21,7 +21,8 @@ namespace HandyControlDemo.UserControl
new Uri(@"pack://application:,,,/Resources/Img/Album/9.jpg"),
new Uri(@"pack://application:,,,/Resources/Img/Album/10.jpg")
});
- CoverFlowMain.JumpTo(2);
+
+ CoverFlowMain.PageIndex = 2;
}
}
}
diff --git a/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs b/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs
index 1a1088af..aaa71b03 100644
--- a/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs
+++ b/src/Shared/HandyControl_Shared/Controls/Cover/CoverFlow/CoverFlow.cs
@@ -103,18 +103,13 @@ namespace HandyControl.Controls
///
private int _lastShowIndex;
- ///
- /// 跳转编号
- ///
- private int _jumpToIndex = -1;
-
///
/// 页码
///
public int PageIndex
{
get => (int) GetValue(PageIndexProperty);
- internal set => SetValue(PageIndexProperty, value);
+ set => SetValue(PageIndexProperty, value);
}
///
@@ -147,11 +142,6 @@ namespace HandyControl.Controls
_visualParent = GetTemplateChild(ElementVisualParent) as ModelVisual3D;
UpdateShowRange();
- if (_jumpToIndex > 0)
- {
- PageIndex = _jumpToIndex;
- _jumpToIndex = -1;
- }
_point3DAnimation = new Point3DAnimation(new Point3D(CoverFlowItem.Interval * PageIndex, _camera.Position.Y, _camera.Position.Z), new Duration(TimeSpan.FromMilliseconds(200)));
_camera.BeginAnimation(ProjectionCamera.PositionProperty, _point3DAnimation);
@@ -181,11 +171,6 @@ namespace HandyControl.Controls
///
public void Add(Uri uri) => _contentDic.Add(_contentDic.Count, uri);
- ///
- /// 跳转
- ///
- public void JumpTo(int index) => _jumpToIndex = index;
-
protected override void OnMouseWheel(MouseWheelEventArgs e)
{
base.OnMouseWheel(e);
@@ -237,6 +222,11 @@ namespace HandyControl.Controls
///
private void UpdateIndex(int newIndex)
{
+ if (!IsLoaded)
+ {
+ return;
+ }
+
UpdateShowRange();
_itemShowDic.Do(item =>
{