dd
This commit is contained in:
parent
a0769ae579
commit
b761976f8c
@ -2,7 +2,7 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Wpf_AiSportsMicrospace.MyUserControl"
|
||||
Title="Home" Height="400" Width="800" Loaded="Window_Loaded">
|
||||
Title="Home" Height="600" Width="800" Loaded="Window_Loaded">
|
||||
<Grid>
|
||||
<local:CoverFlowControl x:Name="coverFlow" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Grid>
|
||||
|
||||
24
Wpf_AiSportsMicrospace/MyUserControl/CoverFlowItem.cs
Normal file
24
Wpf_AiSportsMicrospace/MyUserControl/CoverFlowItem.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Wpf_AiSportsMicrospace.MyUserControl
|
||||
{
|
||||
public class CoverFlowItem : DependencyObject
|
||||
{
|
||||
public Uri ImageUri { get; set; }
|
||||
|
||||
public double Progress
|
||||
{
|
||||
get => (double)GetValue(ProgressProperty);
|
||||
set => SetValue(ProgressProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ProgressProperty =
|
||||
DependencyProperty.Register(nameof(Progress), typeof(double), typeof(CoverFlowItem), new PropertyMetadata(0.0));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Wpf_AiSportsMicrospace.MyUserControl
|
||||
{
|
||||
public class ProgressToRectangleGeometryConverter : IValueConverter
|
||||
{
|
||||
// parameter: "width,height"
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
double progress = (double)value;
|
||||
string[] sizes = parameter.ToString().Split(',');
|
||||
double width = double.Parse(sizes[0]);
|
||||
double height = double.Parse(sizes[1]);
|
||||
|
||||
var geo = new StreamGeometry();
|
||||
using (var ctx = geo.Open())
|
||||
{
|
||||
ctx.BeginFigure(new Point(0, 0), false, false);
|
||||
|
||||
double total = 2 * (width + height);
|
||||
double len = progress * total;
|
||||
|
||||
// 上边
|
||||
if (len <= width)
|
||||
{
|
||||
ctx.LineTo(new Point(len, 0), true, true);
|
||||
return geo;
|
||||
}
|
||||
ctx.LineTo(new Point(width, 0), true, true);
|
||||
len -= width;
|
||||
|
||||
// 右边
|
||||
if (len <= height)
|
||||
{
|
||||
ctx.LineTo(new Point(width, len), true, true);
|
||||
return geo;
|
||||
}
|
||||
ctx.LineTo(new Point(width, height), true, true);
|
||||
len -= height;
|
||||
|
||||
// 下边
|
||||
if (len <= width)
|
||||
{
|
||||
ctx.LineTo(new Point(width - len, height), true, true);
|
||||
return geo;
|
||||
}
|
||||
ctx.LineTo(new Point(0, height), true, true);
|
||||
len -= width;
|
||||
|
||||
// 左边
|
||||
if (len <= height)
|
||||
{
|
||||
ctx.LineTo(new Point(0, height - len), true, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
ctx.LineTo(new Point(0, 0), true, true);
|
||||
}
|
||||
}
|
||||
geo.Freeze();
|
||||
return geo;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
=> throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user