using System;
using ;
using ;
using ;
using System.Net.Mail;
using ;
using ;
using System.Windows;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using ;
using static ;
namespace DiaControlLibiray
{
/// <summary>
/// 的交互逻辑
/// </summary>
public partial class CircleProgress : UserControl
{
public int cycleWidth
{
get { return (int)GetValue(cycleWidthProperty); }
set { SetValue(cycleWidthProperty, value); }
}
// Using a DependencyProperty as the backing store for cycleWidth. This enables animation, styling, binding, etc...
public static readonly DependencyProperty cycleWidthProperty =
("cycleWidth", typeof(int), typeof(CircleProgress), new PropertyMetadata(300, new PropertyChangedCallback(OnPropertyChanged)));
public . Color cycleColor
{
get { return ()GetValue(cycleColorProperty); }
set { SetValue(cycleColorProperty, value); }
}
// Using a DependencyProperty as the backing store for cycleColor. This enables animation, styling, binding, etc...
public static readonly DependencyProperty cycleColorProperty =
("cycleColor", typeof(), typeof(CircleProgress), new PropertyMetadata( ,new PropertyChangedCallback(OnPropertyChanged)));
public int cycleHeight
{
get { return (int)GetValue(cycleHeightProperty); }
set { SetValue(cycleHeightProperty, value); }
}
// Using a DependencyProperty as the backing store for cycleHeight. This enables animation, styling, binding, etc...
public static readonly DependencyProperty cycleHeightProperty =
("cycleHeight", typeof(int), typeof(CircleProgress), new PropertyMetadata(300, new PropertyChangedCallback(OnPropertyChanged)));
public int Percent
{
get { return (int)GetValue(PercentProperty); }
set { SetValue(PercentProperty, value); }
}
// Using a DependencyProperty as the backing store for Percent. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PercentProperty =
("Percent", typeof(int), typeof(CircleProgress), new PropertyMetadata(60, new PropertyChangedCallback(OnPropertyChanged)));
public CircleProgress()
{
InitializeComponent();
// = new SolidColorBrush((,,));
// = new SolidColorBrush();
Update();
}
public static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
(d as CircleProgress).Update();
}
public void Update()
{
double Angle = Percent * 3.6 * / 180;
= Percent + "%";
string data = "M{0} {1} A{2} {2} 0 0 1 {3} {4} ";
if (Percent > 50) data = "M{0} {1} A{2} {2} 0 1 1 {3} {4} ";
if (Percent >= 100)
{
data = "M{0} {1} A{2} {2} 0 1 1 {3} {4} Z";
Angle = 270;
}
double endpointX = (cycleWidth / 2 + (Angle) * cycleWidth / 2, 2);
double endpointY = 0;
//if(Percent<90)
endpointY = (cycleHeight / 2 - (Angle) * cycleHeight / 2, 2);
//if(Percent>90&&Percent<180)
// endpointY= (cycleHeight / 2+(Angle) *(cycleHeight/2),2);
data = (data, cycleWidth / 2, 0, cycleWidth / 2, endpointX, endpointY);
= (data);
http:// /attachment/201201/0_1325414042qvFL.gif & pos_id = c8oIyUjE
}
}
}
<Path Stroke="#419f8b"
x:Name="cycleProgressPath"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="310"
Height="310"
StrokeThickness="10"
Data="">
</Path>
<TextBlock x:Name="txtPercent" Text="60%" FontSize="33" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>