Loading CountDownList/Class/JSON.cs→CountDownList/Class/Comon.cs +2 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,8 @@ using System.Threading.Tasks; namespace CountDownList.Class { class JSON public static class Comon { public const string ListPath = @"Data\CountDownList.json"; } } CountDownList/Class/XML.cs 0 → 100644 +72 −0 Original line number Diff line number Diff line using System; using System.Collections.Generic; using System.Linq; using System.Reflection.Metadata; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Xml; using System.Xml.Linq; #pragma warning disable namespace CountDownList.Class { public class CountCownListXml { public required XDocument xmlDoc; public required XElement root; public required XElement main; public CountCownListXml() { xmlDoc = XDocument.Load($"{AppDomain.CurrentDomain.BaseDirectory}{Comon.ListPath}"); try { if (xmlDoc.Root != null && root != null) { root = xmlDoc.Root; main = root.Element("CountDownList"); } else { throw (new("找不到Xml配置文件节点")); } } catch { throw (new("找不到Xml配置文件节点")); } } //public List<UIElement> GetAllListToControls() //{ // List<UIElement> e = new(); // foreach (XElement item in main.Elements()) // { // Controls.ListLabel ll = new // ( // item.Element("Title").Value, // DateTime.FromBinary(Convert.ToInt64(item.Element("StartTimeT").Value)), // DateTime.FromBinary(Convert.ToInt64(item.Element("EndTimeT").Value)), // item.Element("Format").Value, // Convert.ToBoolean(item.Element("IsCount").Value) // ); // e.Add(ll); // } // return e; //} } /// <summary> /// JSON(反)序列化内容 /// </summary> public class CountDownListXmlTemplete { public required string Title { get; set; } public required long StartTimeT { get; set; } public required long EndTimeT { get; set; } public required bool IsCount { get; set; } public required string format { get; set; } } } CountDownList/Controls/ListLabel.xaml +143 −9 Original line number Diff line number Diff line Loading @@ -5,33 +5,167 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:CountDownList.Controls" mc:Ignorable="d" Height="85" Width="384"> <UserControl.Resources> <Storyboard x:Key="Storyboard1"> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="userControl" Storyboard.TargetProperty="(FrameworkElement.Height)"> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="216"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TitleTextFull" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="18"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <ThicknessAnimationUsingKeyFrames Storyboard.TargetName="ProgressTextFull" Storyboard.TargetProperty="(FrameworkElement.Margin)"> <EasingThicknessKeyFrame KeyTime="00:00:00.5000000" Value="0,0,0,32"> <EasingThicknessKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingThicknessKeyFrame.EasingFunction> </EasingThicknessKeyFrame> </ThicknessAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TimeTextFull" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="22"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="grid1" Storyboard.TargetProperty="(UIElement.Opacity)"> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> </Storyboard> <Storyboard x:Key="Storyboard2"> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="userControl" Storyboard.TargetProperty="(FrameworkElement.Height)"> <SplineDoubleKeyFrame KeyTime="00:00:00" Value="216"/> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="85"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TitleTextFull" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="18"/> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="12"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <ThicknessAnimationUsingKeyFrames Storyboard.TargetName="ProgressTextFull" Storyboard.TargetProperty="(FrameworkElement.Margin)"> <EasingThicknessKeyFrame KeyTime="00:00:00.5000000" Value="0,0,0,12"> <EasingThicknessKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingThicknessKeyFrame.EasingFunction> </EasingThicknessKeyFrame> </ThicknessAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TimeTextFull" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="22"/> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="12"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/> <DiscreteObjectKeyFrame KeyTime="00:00:00.2000000" Value="{x:Static Visibility.Visible}"/> <DiscreteObjectKeyFrame KeyTime="00:00:00.5000000" Value="{x:Static Visibility.Collapsed}"/> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="grid1" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="grid1" Storyboard.TargetProperty="(UIElement.Opacity)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TitleText" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="12"/> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="12"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ProgressText" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="14"/> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="12"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> </Storyboard> <SolidColorBrush x:Key="Light" Color="#FFF7F7F7"></SolidColorBrush> <SolidColorBrush x:Key="Dark" Color="#FF202020"></SolidColorBrush> <SolidColorBrush x:Key="Binding" Color="Yellow"></SolidColorBrush> </UserControl.Resources> <Grid> <Border Margin="4,4,4,4" BorderBrush="#FFF7F7F7" CornerRadius="8,8,8,8" BorderThickness="2,2,2,2" Cursor="Hand" MouseLeftButtonUp="Border_MouseLeftButtonUp"> <Border x:Name="bg" 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="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"> <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" Visibility="Collapsed"> <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"> <Grid x:Name="grid" Visibility="Collapsed"> <TextBlock x:Name="TitleTextFull" Foreground="{DynamicResource Binding}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,13,0,0" d:IsHidden="True"> 12331你好 </TextBlock> <TextBlock x:Name="ProgressTextFull" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="{DynamicResource Binding}" Margin="0,0,0,12"> 100% </TextBlock> <TextBlock x:Name="TimeTextFull" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource Binding}" Margin="0,0,0,12"> 1天1516小时3分钟 </TextBlock> </Grid> <Grid x:Name="grid1"> <TextBlock x:Name="TitleText" Foreground="{DynamicResource Binding}" 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"> <TextBlock x:Name="ProgressText" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="{DynamicResource Binding}" Margin="8,0,0,12"> 100% </TextBlock> <TextBlock x:Name="TimeText" HorizontalAlignment="Right" VerticalAlignment="Bottom" Foreground="#FFF7F7F7" Margin="0,0,8,12"> <TextBlock x:Name="TimeText" HorizontalAlignment="Right" VerticalAlignment="Bottom" Foreground="{DynamicResource Binding}" 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 Height="6" CornerRadius="0,0,8,8" Background="#7FC7C7C7" 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"> Loading CountDownList/Controls/ListLabel.xaml.cs +70 −8 Original line number Diff line number Diff line using System; using NAudio.Wave; using System; using System.Collections.Generic; using System.Linq; using System.Text; Loading Loading @@ -28,6 +29,9 @@ namespace CountDownList.Controls public DateTime EndTime { get; set; } public bool IsHidden { get; set; } public bool IsCountMode { get; set; } public Brush LabelBackground { get; set; } public bool DarkText { get; set; } public string? TimeFormat; Loading @@ -39,7 +43,7 @@ namespace CountDownList.Controls /// <param name="endTime">结束时间</param> /// <param name="format">时间转换格式</param> /// <param name="isCountMode">是否为正计时模式,为true将忽略结束时间</param> public ListLabel(string title,DateTime startTime, DateTime endTime, string format, bool isCountMode = false) public ListLabel(string title,DateTime startTime, DateTime endTime, string format, bool darkText, Brush background,bool isCountMode = false) { InitializeComponent(); Title = title; Loading @@ -47,10 +51,14 @@ namespace CountDownList.Controls EndTime = endTime; IsCountMode = isCountMode; TimeFormat = format; LabelBackground = background; DarkText = darkText; SyncTitle(); SyncTime(); SyncProgress(); SyncTextColor(); SyncBackground(); } private void Button_Click(object sender, RoutedEventArgs e) Loading @@ -58,17 +66,34 @@ namespace CountDownList.Controls ((ContextMenu)FindResource("ContextMenu")).IsOpen = true; } void OpenAnimation() { } bool Open = false; private void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (Open) { Open = false; ((Storyboard)FindResource("Storyboard2")).Begin(); } else { Open = true; ((Storyboard)FindResource("Storyboard1")).Begin(); } } public void SyncTitle() => TitleText.Text = Title; public void SyncTitle() { TitleText.Text = Title; if (EndTime <= DateTime.Now) { TitleTextFull.Text = $"距离{Title}已经过去"; } else { TitleTextFull.Text = $"距离{Title}还剩"; } } public void SyncTime() { Loading @@ -76,11 +101,13 @@ namespace CountDownList.Controls { //正计时 TimeText.Text = (StartTime - DateTime.Now).ToString(TimeFormat); TimeTextFull.Text = (StartTime - DateTime.Now).ToString(TimeFormat); } else { //倒计时 TimeText.Text = (EndTime - DateTime.Now).ToString(TimeFormat); TimeTextFull.Text = (EndTime - DateTime.Now).ToString(TimeFormat); } } Loading @@ -91,6 +118,7 @@ namespace CountDownList.Controls ProgressBar.Visibility = Visibility.Collapsed; ProgressText.Text = $"已经过去"; ProgressTextFull.Visibility = Visibility.Collapsed; } else { Loading @@ -98,15 +126,49 @@ namespace CountDownList.Controls { Progress = ((EndTime - DateTime.Now).TotalMilliseconds / (EndTime - StartTime).TotalMilliseconds) * 100; ProgressText.Text = $"{100 - Progress:F2}%"; ProgressTextFull.Text = $"{100 - Progress:F2}%"; ProgressRectangleGeometry.Rect = new(0, 0, (d.ActualWidth / 100) * (100 - Progress), 6); } else { Progress = 0; ProgressText.Text = $"已完成"; ProgressTextFull.Text = $"100%"; ProgressRectangleGeometry.Rect = new(0, 0, d.ActualWidth, 6); } } } SolidColorBrush Dark = new(Color.FromArgb(255, 32, 32, 32)); SolidColorBrush Light = new(Color.FromArgb(255, 247, 247, 247)); public void SyncTextColor() { if (DarkText) { TitleText.Foreground = Dark; ProgressText.Foreground = Dark; TimeText.Foreground = Dark; TitleTextFull.Foreground = Dark; ProgressTextFull.Foreground = Dark; TimeTextFull.Foreground = Dark; } else { TitleText.Foreground = Light; ProgressText.Foreground = Light; TimeText.Foreground = Light; TitleTextFull.Foreground = Light; ProgressTextFull.Foreground = Light; TimeTextFull.Foreground = Light; } } public void SyncBackground() { bg.Background = LabelBackground; } } } CountDownList/CountDownList.csproj +21 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,10 @@ </PropertyGroup> <ItemGroup> <None Remove="Data\Image\1.jpg" /> <None Remove="Data\Image\2.jpg" /> <None Remove="Data\Image\3.png" /> <None Remove="Data\Image\4.jpg" /> <None Remove="UI\Icon\0-more.png" /> <None Remove="UI\Icon\1-Del.png" /> <None Remove="UI\Icon\2-Hid.png" /> Loading @@ -20,6 +24,18 @@ </ItemGroup> <ItemGroup> <Content Include="Data\Image\1.jpg"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="Data\Image\2.jpg"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="Data\Image\3.png"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="Data\Image\4.jpg"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="UI\Icon\0-more.png"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> Loading Loading @@ -48,7 +64,12 @@ <ItemGroup> <PackageReference Include="HandyControl" Version="3.5.1" /> <PackageReference Include="NAudio" Version="2.2.1" /> <PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" /> </ItemGroup> <ItemGroup> <Folder Include="Data\Sounds\UI\" /> </ItemGroup> </Project> Loading
CountDownList/Class/JSON.cs→CountDownList/Class/Comon.cs +2 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,8 @@ using System.Threading.Tasks; namespace CountDownList.Class { class JSON public static class Comon { public const string ListPath = @"Data\CountDownList.json"; } }
CountDownList/Class/XML.cs 0 → 100644 +72 −0 Original line number Diff line number Diff line using System; using System.Collections.Generic; using System.Linq; using System.Reflection.Metadata; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Xml; using System.Xml.Linq; #pragma warning disable namespace CountDownList.Class { public class CountCownListXml { public required XDocument xmlDoc; public required XElement root; public required XElement main; public CountCownListXml() { xmlDoc = XDocument.Load($"{AppDomain.CurrentDomain.BaseDirectory}{Comon.ListPath}"); try { if (xmlDoc.Root != null && root != null) { root = xmlDoc.Root; main = root.Element("CountDownList"); } else { throw (new("找不到Xml配置文件节点")); } } catch { throw (new("找不到Xml配置文件节点")); } } //public List<UIElement> GetAllListToControls() //{ // List<UIElement> e = new(); // foreach (XElement item in main.Elements()) // { // Controls.ListLabel ll = new // ( // item.Element("Title").Value, // DateTime.FromBinary(Convert.ToInt64(item.Element("StartTimeT").Value)), // DateTime.FromBinary(Convert.ToInt64(item.Element("EndTimeT").Value)), // item.Element("Format").Value, // Convert.ToBoolean(item.Element("IsCount").Value) // ); // e.Add(ll); // } // return e; //} } /// <summary> /// JSON(反)序列化内容 /// </summary> public class CountDownListXmlTemplete { public required string Title { get; set; } public required long StartTimeT { get; set; } public required long EndTimeT { get; set; } public required bool IsCount { get; set; } public required string format { get; set; } } }
CountDownList/Controls/ListLabel.xaml +143 −9 Original line number Diff line number Diff line Loading @@ -5,33 +5,167 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:CountDownList.Controls" mc:Ignorable="d" Height="85" Width="384"> <UserControl.Resources> <Storyboard x:Key="Storyboard1"> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="userControl" Storyboard.TargetProperty="(FrameworkElement.Height)"> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="216"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TitleTextFull" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="18"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <ThicknessAnimationUsingKeyFrames Storyboard.TargetName="ProgressTextFull" Storyboard.TargetProperty="(FrameworkElement.Margin)"> <EasingThicknessKeyFrame KeyTime="00:00:00.5000000" Value="0,0,0,32"> <EasingThicknessKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingThicknessKeyFrame.EasingFunction> </EasingThicknessKeyFrame> </ThicknessAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TimeTextFull" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="22"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="grid1" Storyboard.TargetProperty="(UIElement.Opacity)"> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> </Storyboard> <Storyboard x:Key="Storyboard2"> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="userControl" Storyboard.TargetProperty="(FrameworkElement.Height)"> <SplineDoubleKeyFrame KeyTime="00:00:00" Value="216"/> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="85"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TitleTextFull" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="18"/> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="12"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <ThicknessAnimationUsingKeyFrames Storyboard.TargetName="ProgressTextFull" Storyboard.TargetProperty="(FrameworkElement.Margin)"> <EasingThicknessKeyFrame KeyTime="00:00:00.5000000" Value="0,0,0,12"> <EasingThicknessKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingThicknessKeyFrame.EasingFunction> </EasingThicknessKeyFrame> </ThicknessAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TimeTextFull" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="22"/> <EasingDoubleKeyFrame KeyTime="00:00:00.5000000" Value="12"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/> <DiscreteObjectKeyFrame KeyTime="00:00:00.2000000" Value="{x:Static Visibility.Visible}"/> <DiscreteObjectKeyFrame KeyTime="00:00:00.5000000" Value="{x:Static Visibility.Collapsed}"/> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="grid" Storyboard.TargetProperty="(UIElement.Opacity)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="1"/> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetName="grid1" Storyboard.TargetProperty="(UIElement.Visibility)"> <DiscreteObjectKeyFrame KeyTime="00:00:00" Value="{x:Static Visibility.Visible}"/> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="grid1" Storyboard.TargetProperty="(UIElement.Opacity)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="0"/> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="TitleText" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="12"/> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="12"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ProgressText" Storyboard.TargetProperty="(TextBlock.FontSize)"> <EasingDoubleKeyFrame KeyTime="00:00:00" Value="14"/> <EasingDoubleKeyFrame KeyTime="00:00:00.2000000" Value="12"> <EasingDoubleKeyFrame.EasingFunction> <CubicEase EasingMode="EaseOut"/> </EasingDoubleKeyFrame.EasingFunction> </EasingDoubleKeyFrame> </DoubleAnimationUsingKeyFrames> </Storyboard> <SolidColorBrush x:Key="Light" Color="#FFF7F7F7"></SolidColorBrush> <SolidColorBrush x:Key="Dark" Color="#FF202020"></SolidColorBrush> <SolidColorBrush x:Key="Binding" Color="Yellow"></SolidColorBrush> </UserControl.Resources> <Grid> <Border Margin="4,4,4,4" BorderBrush="#FFF7F7F7" CornerRadius="8,8,8,8" BorderThickness="2,2,2,2" Cursor="Hand" MouseLeftButtonUp="Border_MouseLeftButtonUp"> <Border x:Name="bg" 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="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"> <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" Visibility="Collapsed"> <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"> <Grid x:Name="grid" Visibility="Collapsed"> <TextBlock x:Name="TitleTextFull" Foreground="{DynamicResource Binding}" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,13,0,0" d:IsHidden="True"> 12331你好 </TextBlock> <TextBlock x:Name="ProgressTextFull" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="{DynamicResource Binding}" Margin="0,0,0,12"> 100% </TextBlock> <TextBlock x:Name="TimeTextFull" HorizontalAlignment="Center" VerticalAlignment="Center" Foreground="{DynamicResource Binding}" Margin="0,0,0,12"> 1天1516小时3分钟 </TextBlock> </Grid> <Grid x:Name="grid1"> <TextBlock x:Name="TitleText" Foreground="{DynamicResource Binding}" 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"> <TextBlock x:Name="ProgressText" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="{DynamicResource Binding}" Margin="8,0,0,12"> 100% </TextBlock> <TextBlock x:Name="TimeText" HorizontalAlignment="Right" VerticalAlignment="Bottom" Foreground="#FFF7F7F7" Margin="0,0,8,12"> <TextBlock x:Name="TimeText" HorizontalAlignment="Right" VerticalAlignment="Bottom" Foreground="{DynamicResource Binding}" 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 Height="6" CornerRadius="0,0,8,8" Background="#7FC7C7C7" 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"> Loading
CountDownList/Controls/ListLabel.xaml.cs +70 −8 Original line number Diff line number Diff line using System; using NAudio.Wave; using System; using System.Collections.Generic; using System.Linq; using System.Text; Loading Loading @@ -28,6 +29,9 @@ namespace CountDownList.Controls public DateTime EndTime { get; set; } public bool IsHidden { get; set; } public bool IsCountMode { get; set; } public Brush LabelBackground { get; set; } public bool DarkText { get; set; } public string? TimeFormat; Loading @@ -39,7 +43,7 @@ namespace CountDownList.Controls /// <param name="endTime">结束时间</param> /// <param name="format">时间转换格式</param> /// <param name="isCountMode">是否为正计时模式,为true将忽略结束时间</param> public ListLabel(string title,DateTime startTime, DateTime endTime, string format, bool isCountMode = false) public ListLabel(string title,DateTime startTime, DateTime endTime, string format, bool darkText, Brush background,bool isCountMode = false) { InitializeComponent(); Title = title; Loading @@ -47,10 +51,14 @@ namespace CountDownList.Controls EndTime = endTime; IsCountMode = isCountMode; TimeFormat = format; LabelBackground = background; DarkText = darkText; SyncTitle(); SyncTime(); SyncProgress(); SyncTextColor(); SyncBackground(); } private void Button_Click(object sender, RoutedEventArgs e) Loading @@ -58,17 +66,34 @@ namespace CountDownList.Controls ((ContextMenu)FindResource("ContextMenu")).IsOpen = true; } void OpenAnimation() { } bool Open = false; private void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (Open) { Open = false; ((Storyboard)FindResource("Storyboard2")).Begin(); } else { Open = true; ((Storyboard)FindResource("Storyboard1")).Begin(); } } public void SyncTitle() => TitleText.Text = Title; public void SyncTitle() { TitleText.Text = Title; if (EndTime <= DateTime.Now) { TitleTextFull.Text = $"距离{Title}已经过去"; } else { TitleTextFull.Text = $"距离{Title}还剩"; } } public void SyncTime() { Loading @@ -76,11 +101,13 @@ namespace CountDownList.Controls { //正计时 TimeText.Text = (StartTime - DateTime.Now).ToString(TimeFormat); TimeTextFull.Text = (StartTime - DateTime.Now).ToString(TimeFormat); } else { //倒计时 TimeText.Text = (EndTime - DateTime.Now).ToString(TimeFormat); TimeTextFull.Text = (EndTime - DateTime.Now).ToString(TimeFormat); } } Loading @@ -91,6 +118,7 @@ namespace CountDownList.Controls ProgressBar.Visibility = Visibility.Collapsed; ProgressText.Text = $"已经过去"; ProgressTextFull.Visibility = Visibility.Collapsed; } else { Loading @@ -98,15 +126,49 @@ namespace CountDownList.Controls { Progress = ((EndTime - DateTime.Now).TotalMilliseconds / (EndTime - StartTime).TotalMilliseconds) * 100; ProgressText.Text = $"{100 - Progress:F2}%"; ProgressTextFull.Text = $"{100 - Progress:F2}%"; ProgressRectangleGeometry.Rect = new(0, 0, (d.ActualWidth / 100) * (100 - Progress), 6); } else { Progress = 0; ProgressText.Text = $"已完成"; ProgressTextFull.Text = $"100%"; ProgressRectangleGeometry.Rect = new(0, 0, d.ActualWidth, 6); } } } SolidColorBrush Dark = new(Color.FromArgb(255, 32, 32, 32)); SolidColorBrush Light = new(Color.FromArgb(255, 247, 247, 247)); public void SyncTextColor() { if (DarkText) { TitleText.Foreground = Dark; ProgressText.Foreground = Dark; TimeText.Foreground = Dark; TitleTextFull.Foreground = Dark; ProgressTextFull.Foreground = Dark; TimeTextFull.Foreground = Dark; } else { TitleText.Foreground = Light; ProgressText.Foreground = Light; TimeText.Foreground = Light; TitleTextFull.Foreground = Light; ProgressTextFull.Foreground = Light; TimeTextFull.Foreground = Light; } } public void SyncBackground() { bg.Background = LabelBackground; } } }
CountDownList/CountDownList.csproj +21 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,10 @@ </PropertyGroup> <ItemGroup> <None Remove="Data\Image\1.jpg" /> <None Remove="Data\Image\2.jpg" /> <None Remove="Data\Image\3.png" /> <None Remove="Data\Image\4.jpg" /> <None Remove="UI\Icon\0-more.png" /> <None Remove="UI\Icon\1-Del.png" /> <None Remove="UI\Icon\2-Hid.png" /> Loading @@ -20,6 +24,18 @@ </ItemGroup> <ItemGroup> <Content Include="Data\Image\1.jpg"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="Data\Image\2.jpg"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="Data\Image\3.png"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="Data\Image\4.jpg"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> <Content Include="UI\Icon\0-more.png"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </Content> Loading Loading @@ -48,7 +64,12 @@ <ItemGroup> <PackageReference Include="HandyControl" Version="3.5.1" /> <PackageReference Include="NAudio" Version="2.2.1" /> <PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" /> </ItemGroup> <ItemGroup> <Folder Include="Data\Sounds\UI\" /> </ItemGroup> </Project>