Commit da151244 authored by Rabbit's avatar Rabbit
Browse files

20241214

parent 843030ad
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CountDownList.Class
{
    class JSON
    {
    }
}
+60 −0
Original line number Diff line number Diff line
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Windows;
using System.Windows.Controls;

namespace CountDownList
{
    public static class ScrollViewerBehavior
    {
        public static readonly DependencyProperty VerticalOffsetProperty = DependencyProperty.RegisterAttached("VerticalOffset", typeof(double), typeof(ScrollViewerBehavior), new UIPropertyMetadata(0.0, OnVerticalOffsetChanged));
        public static void SetVerticalOffset(FrameworkElement target, double value) => target.SetValue(VerticalOffsetProperty, value);
        public static double GetVerticalOffset(FrameworkElement target) => (double)target.GetValue(VerticalOffsetProperty);
        private static void OnVerticalOffsetChanged(DependencyObject target, DependencyPropertyChangedEventArgs e) => (target as ScrollViewer)?.ScrollToVerticalOffset((double)e.NewValue);
    }

    //继承ScrollViewer 通过截获MouseWheel事件控制滚动
    public class MyScrollViewer : ScrollViewer
    {
        //记录上一次的滚动位置
        private double LastLocation = 0;
        //重写鼠标滚动事件
        protected override void OnMouseWheel(MouseWheelEventArgs e)
        {
            double WheelChange = e.Delta;
            //可以更改一次滚动的距离倍数 (WheelChange可能为正负数!)
            double newOffset = LastLocation - (WheelChange * 0.5);
            //Animation并不会改变真正的VerticalOffset(只是它的依赖属性) 所以将VOffset设置到上一次的滚动位置 (相当于衔接上一个动画)
            ScrollToVerticalOffset(LastLocation);
            //碰到底部和顶部时的处理
            if (newOffset < 0)
                newOffset = 0;
            if (newOffset > ScrollableHeight)
                newOffset = ScrollableHeight;

            AnimateScroll(newOffset);
            LastLocation = newOffset;
            //告诉ScrollViewer我们已经完成了滚动
            e.Handled = true;
        }
        private void AnimateScroll(double ToValue)
        {
            //为了避免重复,先结束掉上一个动画
            BeginAnimation(ScrollViewerBehavior.VerticalOffsetProperty, null);
            DoubleAnimation Animation = new DoubleAnimation();
            Animation.EasingFunction = new CubicEase() { EasingMode = EasingMode.EaseOut };
            Animation.From = VerticalOffset;
            Animation.To = ToValue;
            //动画速度
            Animation.Duration = TimeSpan.FromMilliseconds(800);
            //考虑到性能,可以降低动画帧数
            //Timeline.SetDesiredFrameRate(Animation, 40);
            BeginAnimation(ScrollViewerBehavior.VerticalOffsetProperty, Animation);
        }
    }
}
+21 −0
Original line number Diff line number Diff line
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using OpenCvSharp;

namespace CountDownList.Class
{
    public class Visual
    {
        /// <summary>
        /// 高斯模糊
        /// </summary>
        public class GaussianBlur
        {

        }
    }
}
+30 −0
Original line number Diff line number Diff line
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CountDownList.Class
{
    public class cdlTimeSpan
    {
        /// <summary>
        /// 自动转换TimeSpan到String,根据时间跨度选择合适的单位
        /// </summary>
        /// <param name="timeSpan"></param>
        /// <returns>例如:5月02天,3年6月,2分钟28秒</returns>
        public string AutoToStringZh(TimeSpan timeSpan)
        {
            string returns = string.Empty;
            if (timeSpan.TotalDays >= 366)
            {
                returns = $"{Math.Floor(timeSpan.TotalDays / 365.25)}{(timeSpan.TotalDays % 365d) / 30 :F0}月";
            }
            else if(timeSpan.TotalDays < 366 && timeSpan.TotalDays >= 180)
            {
                returns = $"{Math.Floor(timeSpan.TotalDays / 30)}{Math.Floor(timeSpan.TotalDays - (timeSpan.TotalDays % 30))}天";
            }
            return returns;
        } 
    }
}
+37 −23
Original line number Diff line number Diff line
<UserControl x:Class="CountDownList.Controls.ListLabel"
<UserControl x:Name="userControl" x:Class="CountDownList.Controls.ListLabel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:CountDownList.Controls"
             mc:Ignorable="d" d:DesignHeight="85" d:DesignWidth="405">
    <UserControl.Resources>
        <ContextMenu x:Key="ContextMenu">
            <MenuItem Name="Paste" Header="编辑" >
                <MenuItem.Icon>
                    <Image RenderOptions.BitmapScalingMode="Fant" Source="/UI/Icon/3-Edit.png"></Image>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Name="Copy" Header="隐藏" >
                <MenuItem.Icon>
                    <Image RenderOptions.BitmapScalingMode="Fant" Source="/UI/Icon/2-Hid.png"></Image>
                </MenuItem.Icon>
            </MenuItem>
            <MenuItem Name="Delete" Header="删除" >
                <MenuItem.Icon>
                    <Image RenderOptions.BitmapScalingMode="Fant" Source="/UI/Icon/1-Del.png"></Image>
                </MenuItem.Icon>
            </MenuItem>
        </ContextMenu>
    </UserControl.Resources>
             mc:Ignorable="d" Height="85" Width="384">
    <Grid>
        <Border Margin="4,4,4,4" BorderBrush="#FFF7F7F7" CornerRadius="8,8,8,8" BorderThickness="2,2,2,2">
        <Border Margin="4,4,4,4" BorderBrush="#FFF7F7F7" CornerRadius="8,8,8,8" BorderThickness="2,2,2,2" Cursor="Hand" MouseLeftButtonUp="Border_MouseLeftButtonUp">
            <Border.Background>
                <ImageBrush ImageSource="/UI/test.png" Stretch="UniformToFill"/>
            </Border.Background>
            <Grid>
                <!--更多-->
                <Button Height="24" Width="24" Background="Transparent" BorderBrush="{x:Null}" Padding="0,0,0,0" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0" Click="Button_Click">
                <Button Height="10" Width="20" Background="Transparent" BorderBrush="{x:Null}" Padding="-16,-16,-16,-16" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,4,4,0" Click="Button_Click">
                    <Image RenderOptions.BitmapScalingMode="Fant" Source="/UI/Icon/0-more.png" Height="20" Width="20"/>
                </Button>

                <Grid>
                    <TextBlock x:Name="TitleText" Foreground="#FFF7F7F7" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="8,8,0,0">
                        12331你好
                    </TextBlock>

                    <TextBlock x:Name="ProgressText" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="#FFF7F7F7" Margin="8,0,0,12">
                        100%
                    </TextBlock>

                    <TextBlock x:Name="TimeText" HorizontalAlignment="Right" VerticalAlignment="Bottom" Foreground="#FFF7F7F7" Margin="0,0,8,12">
                        1天1516小时3分钟
                    </TextBlock>
                </Grid>

                <Grid x:Name="ProgressBar">
                    <Border Height="6" CornerRadius="0,0,8,8" Background="#7FF7F7F7" VerticalAlignment="Bottom"/>
                    <Border Background="#FF80C2FF" CornerRadius="0,0,8,8" Height="6" VerticalAlignment="Bottom">
                        <Border.Clip>
                            <RectangleGeometry x:Name="ProgressRectangleGeometry" RadiusX="0" RadiusY="0" Rect="0,0,32,6">
                                
                            </RectangleGeometry>
                        </Border.Clip>
                    </Border>

                </Grid>
            </Grid>
        </Border>

        <Border x:Name="d" BorderBrush="#FFF7F7F7" BorderThickness="2,2,2,2" CornerRadius="8,8,8,8" Margin="4,4,4,4">
            
        </Border>
    </Grid>
</UserControl>
Loading