Commit 54afa2c4 authored by Rabbit's avatar Rabbit
Browse files

优化滚动框体验,修复一些问题

parent ea1b49dd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ using System.Windows;
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
[assembly: AssemblyVersion("1.1.2.*")]
[assembly: AssemblyVersion("1.1.7.*")]

/// <summary>
/// 使用此类前需要把[assembly: ComVisible(false)]改为true
+5 −4
Original line number Diff line number Diff line
@@ -19,8 +19,9 @@ namespace CountDownList
    }

    //继承ScrollViewer 通过截获MouseWheel事件控制滚动
    public class MyScrollViewer : ScrollViewer
    public class MyScrollViewer : HandyControl.Controls.ScrollViewer
    {
        
        //记录上一次的滚动位置
        private double LastLocation = 0;
        //重写鼠标滚动事件
@@ -28,7 +29,7 @@ namespace CountDownList
        {
            double WheelChange = e.Delta;
            //可以更改一次滚动的距离倍数 (WheelChange可能为正负数!)
            double newOffset = LastLocation - (WheelChange * 0.5);
            double newOffset = LastLocation - (WheelChange);
            //Animation并不会改变真正的VerticalOffset(只是它的依赖属性) 所以将VOffset设置到上一次的滚动位置 (相当于衔接上一个动画)
            ScrollToVerticalOffset(LastLocation);
            //碰到底部和顶部时的处理
@@ -47,11 +48,11 @@ namespace CountDownList
            //为了避免重复,先结束掉上一个动画
            BeginAnimation(ScrollViewerBehavior.VerticalOffsetProperty, null);
            DoubleAnimation Animation = new DoubleAnimation();
            Animation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
            Animation.EasingFunction = new QuadraticEase() { EasingMode = EasingMode.EaseOut };
            Animation.From = VerticalOffset;
            Animation.To = ToValue;
            //动画速度
            Animation.Duration = TimeSpan.FromMilliseconds(800);
            Animation.Duration = TimeSpan.FromMilliseconds(200);
            //考虑到性能,可以降低动画帧数
            //Timeline.SetDesiredFrameRate(Animation, 40);
            BeginAnimation(ScrollViewerBehavior.VerticalOffsetProperty, Animation);
+41 −3
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ using System.Xml;
using System.Xml.Linq;
using CountDownList.UI.WindowFrame;
using HandyControl.Tools.Extension;
using System.IO;

#pragma warning disable
namespace CountDownList.Class
@@ -83,8 +84,12 @@ namespace CountDownList.Class
        /// <returns>包含多个ListLabels的列表</returns>
        public List<Controls.ListLabel> GetListLabels()
        {
            string output = "";

            List<Controls.ListLabel> result = new();

            List<PathErr> pathErr = new();

            XmlNode rootNode = xmlDoc.SelectSingleNode("shRabbit").SelectSingleNode("CountDownList");

            int labelsCount = 0;
@@ -172,11 +177,30 @@ namespace CountDownList.Class
                    if (isImageBackground)
                    {
                        ImageBrush ib = new();

                        try
                        {
                            if (File.Exists($@"{AppDomain.CurrentDomain.BaseDirectory}{backgroundRaw}"))
                            {
                                ib.ImageSource = new BitmapImage(new Uri(backgroundRaw, UriKind.Relative));
                                ib.Stretch = Stretch.UniformToFill;
                                brush = ib;
                            }
                            else
                            {
                                ib.ImageSource = new BitmapImage(new Uri("UI\\Misc\\PathErr.png", UriKind.RelativeOrAbsolute));
                                ib.Stretch = Stretch.UniformToFill;
                                brush = ib;

                                pathErr.Add(new(title, backgroundRaw));
                            }
                        }
                        catch
                        {

                        }
                    }
                    else
                    {
                        byte[] color = new byte[4];
                        string[] colorRaw = new string[4];
@@ -209,6 +233,14 @@ namespace CountDownList.Class
                    }
                }
            }
            if (pathErr.Count != 0)
            {
                foreach (PathErr item in pathErr)
                {
                    output += $"找不到名为 {item.Title} 标签的图片路径 {item.Path}。\n";
                }
                HandyControl.Controls.MessageBox.Show(output, "检测到的问题", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            return result;
        }
    }
@@ -278,4 +310,10 @@ namespace CountDownList.Class
        /// </summary>
        public required Brush Readonly { get; set; }
    }

    public class PathErr(string title, string path)
    {
        public string Title = title;
        public string Path = path;
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -42,6 +42,8 @@
    <None Remove="UI\Logos\HandyControl.png" />
    <None Remove="UI\Logos\NAudio.png" />
    <None Remove="UI\Misc\00.bmp" />
    <None Remove="UI\Misc\PathErr.bmp.png" />
    <None Remove="UI\Misc\PathErr.png" />
    <None Remove="UI\shRabbitLight%404x.png" />
    <None Remove="UI\test.png" />
  </ItemGroup>
@@ -125,6 +127,9 @@
    <Resource Include="UI\Logos\NAudio.png">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Resource>
    <Content Include="UI\Misc\PathErr.png">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Resource Include="UI\[email protected]" />
  </ItemGroup>

+1 −1
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@
                </TransformGroup>
            </Border.RenderTransform>
            <Grid Margin="0,4,0,4">
                <local:MyScrollViewer x:Name="sv" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard" VerticalScrollBarVisibility="Hidden" Focusable="False">
                <local:MyScrollViewer x:Name="sv" VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Standard" Focusable="False" Style="{DynamicResource ScrollViewerBaseStyle}" VerticalScrollBarVisibility="Auto">
                    <local:MyScrollViewer.OpacityMask>
                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                            <GradientStop Color="Transparent"/>
Loading