Skip to content

Commit

Permalink
Fix issue (#128
Browse files Browse the repository at this point in the history
Fix issue (#128
  • Loading branch information
yanjinhuagood committed Dec 17, 2024
1 parent 263f86c commit be272b9
Show file tree
Hide file tree
Showing 13 changed files with 246 additions and 194 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<UserControl
x:Class="WPFDevelopers.Samples.ExampleViews.CircleProgressBarExample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:WPFDevelopers.Samples.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPFDevelopers.Samples.ExampleViews"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:wd="https://github.com/WPFDevelopersOrg/WPFDevelopers"
d:DesignHeight="450"
d:DesignWidth="800"
mc:Ignorable="d">
<controls:CodeViewer>
<UniformGrid>
<wd:CircleProgressBar
Width="80"
Height="80"
Background="#21BA9D"
BorderBrush="LightGray"
BrushStrokeThickness="2"
StrokeThickness="5"
Value="{Binding ElementName=CircleSlider, Path=Value}" />

<wd:CircleProgressBar
Background="#E14D5F"
BorderBrush="#42ABAC"
BrushStrokeThickness="4"
IsRound="True"
StrokeThickness="7"
Value="{Binding ElementName=CircleSlider, Path=Value}" />
<wd:CircleProgressBar
Width="50"
Height="50"
Background="#1FA7FC"
BorderBrush="#D6D6D6"
BrushStrokeThickness="10"
Foreground="Black"
IsRound="True"
StrokeThickness="10"
Value="{Binding ElementName=CircleSlider, Path=Value}" />
<wd:CircleProgressBar
Width="100"
Height="100"
BrushStrokeThickness="10"
IsRound="True"
Value="{Binding ElementName=CircleSlider, Path=Value}" />
<wd:CircleProgressBar Value="{Binding ElementName=CircleSlider, Path=Value}" />
<Slider
x:Name="CircleSlider"
VerticalAlignment="Center"
IsSnapToTickEnabled="True"
Maximum="100"
Minimum="0"
Value="10" />
</UniformGrid>
<controls:CodeViewer.SourceCodes>
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/CircleProgressBarExample.xaml" CodeType="Xaml" />
<controls:SourceCodeModel CodeSource="/WPFDevelopers.SamplesCode;component/ExampleViews/CircleProgressBarExample.xaml.cs" CodeType="CSharp" />
</controls:CodeViewer.SourceCodes>
</controls:CodeViewer>
</UserControl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Windows.Controls;

namespace WPFDevelopers.Samples.ExampleViews
{
/// <summary>
/// CircleProgressBarExample.xaml 的交互逻辑
/// </summary>
public partial class CircleProgressBarExample : UserControl
{
public CircleProgressBarExample()
{
InitializeComponent();
}
}
}

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion src/WPFDevelopers.Samples.Shared/Helpers/MenuEnum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public enum MenuEnum
VerifyCode,
CircleMenu,
ChatEmoji,
ProgressBar,
CircleProgressBar,
Dashboard,
PieControl,
Password,
Expand Down
4 changes: 2 additions & 2 deletions src/WPFDevelopers.Samples.Shared/ViewModels/MainVM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ void MenuItemSelection(string _menuName)
case MenuEnum.ChatEmoji:
ControlPanel = new ChatEmojiExample();
break;
case MenuEnum.ProgressBar:
ControlPanel = new CircularProgressBarExample();
case MenuEnum.CircleProgressBar:
ControlPanel = new CircleProgressBarExample();
break;
case MenuEnum.Dashboard:
ControlPanel = new DashboardExample();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@
<SubType>Code</SubType>
<DependentUpon>CircleMenuExample.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)ExampleViews\CircularProgressBarExample.xaml.cs">
<Compile Include="$(MSBuildThisFileDirectory)ExampleViews\CircleProgressBarExample.xaml.cs">
<SubType>Code</SubType>
<DependentUpon>CircularProgressBarExample.xaml</DependentUpon>
<DependentUpon>CircleProgressBarExample.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)ExampleViews\ColorPickerExample.xaml.cs">
<DependentUpon>ColorPickerExample.xaml</DependentUpon>
Expand Down Expand Up @@ -616,7 +616,7 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="$(MSBuildThisFileDirectory)ExampleViews\CircularProgressBarExample.xaml">
<Page Include="$(MSBuildThisFileDirectory)ExampleViews\CircleProgressBarExample.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,8 @@
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\CircularMenuExample.xaml">
<Link>ExampleViews\CircularMenuExample.xaml</Link>
</Resource>
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\CircularProgressBarExample.xaml">
<Link>ExampleViews\CircularProgressBarExample.xaml</Link>
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\CircleProgressBarExample.xaml">
<Link>ExampleViews\CircleProgressBarExample.xaml</Link>
</Resource>
<Resource Include="..\WPFDevelopers.Samples.Shared\ExampleViews\CountdownTimerExample.xaml">
<Link>ExampleViews\CountdownTimerExample.xaml</Link>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,73 +11,63 @@ namespace WPFDevelopers.Controls
[TemplatePart(Name = PathFigureTemplateName, Type = typeof(PathFigure))]
[TemplatePart(Name = PathFigureAngleTemplateName, Type = typeof(PathFigure))]
[TemplatePart(Name = TextBlockTemplateName, Type = typeof(TextBlock))]
public class CircularProgressBar : ProgressBar
public class CircleProgressBar : ProgressBar
{
private const string ArcSegmentTemplateName = "PART_ArcSegment";
private const string ArcSegmentAngleTemplateName = "PART_ArcSegmentAngle";
private const string PathFigureTemplateName = "PART_PathFigure";
private const string PathFigureAngleTemplateName = "PART_PathFigureAngle";
private const string TextBlockTemplateName = "PART_TextBlock";
private readonly Size _size = new Size(50,50);
private ArcSegment _arcSegment, _arcSegmentAngle;
private PathFigure _pathFigure, _pathFigureAngle;
private TextBlock _textBlock;

public static readonly DependencyProperty IsRoundProperty =
DependencyProperty.Register("IsRound", typeof(bool), typeof(CircleProgressBar),
new PropertyMetadata(false));

public static readonly DependencyProperty SizeProperty =
DependencyProperty.Register("Size", typeof(Size), typeof(CircularProgressBar),
new PropertyMetadata(new Size(50,50)));
public static readonly DependencyProperty AngleProperty =
DependencyProperty.Register("Angle", typeof(double), typeof(CircularProgressBar),
DependencyProperty.Register("Angle", typeof(double), typeof(CircleProgressBar),
new PropertyMetadata(0.0));

public static readonly DependencyProperty StrokeThicknessProperty =
DependencyProperty.Register("StrokeThickness", typeof(double), typeof(CircularProgressBar),
new PropertyMetadata(10.0));
DependencyProperty.Register("StrokeThickness", typeof(double), typeof(CircleProgressBar),
new PropertyMetadata(5.0));

public static readonly DependencyProperty BrushStrokeThicknessProperty =
DependencyProperty.Register("BrushStrokeThickness", typeof(double), typeof(CircularProgressBar),
new PropertyMetadata(1.0));
DependencyProperty.Register("BrushStrokeThickness", typeof(double), typeof(CircleProgressBar),
new PropertyMetadata(5.0));

public CircularProgressBar()
public CircleProgressBar()
{
ValueChanged += CircularProgressBar_ValueChanged;
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();

if (Size.Width != Size.Height)
{
var max = Math.Max(Size.Width, Size.Height);
Size = new Size(max, max);
}

_pathFigure = GetTemplateChild(PathFigureTemplateName) as PathFigure;
_pathFigureAngle = GetTemplateChild(PathFigureAngleTemplateName) as PathFigure;
_pathFigure.StartPoint = new Point(Size.Width, 0);
_pathFigureAngle.StartPoint = new Point(Size.Width, 0);
_pathFigure.StartPoint = new Point(_size.Width, 0);
_pathFigureAngle.StartPoint = new Point(_size.Width, 0);
_arcSegment = GetTemplateChild(ArcSegmentTemplateName) as ArcSegment;
_arcSegment.Size = Size;
_arcSegment.Point = new Point(Size.Width - 0.000872664626, 7.61543361704753E-09);
_arcSegment.Size = _size;
_arcSegment.Point = new Point(_size.Width - 0.000872664626, 7.61543361704753E-09);
_arcSegmentAngle = GetTemplateChild(ArcSegmentAngleTemplateName) as ArcSegment;
_arcSegmentAngle.Size = Size;
_arcSegmentAngle.Size = _size;
_textBlock = GetTemplateChild(TextBlockTemplateName) as TextBlock;
if (Size.Width < 15)
{
FontSize = 8;
}
}
public Size Size

public bool IsRound
{
get => (Size)GetValue(SizeProperty);
set => SetValue(SizeProperty, value);
get => (bool)GetValue(IsRoundProperty);
set => SetValue(IsRoundProperty, value);
}

public double Angle
{
get => (double)GetValue(AngleProperty);
set => SetValue(AngleProperty, value);
private set => SetValue(AngleProperty, value);
}

public double StrokeThickness
Expand All @@ -94,7 +84,7 @@ public double BrushStrokeThickness

private void CircularProgressBar_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
var bar = sender as CircularProgressBar;
var bar = sender as CircleProgressBar;
var currentAngle = bar.Angle;
var targetAngle = e.NewValue / bar.Maximum * 359.999;
var anim = new DoubleAnimation(currentAngle, targetAngle, TimeSpan.FromMilliseconds(500));
Expand Down
6 changes: 6 additions & 0 deletions src/WPFDevelopers.Shared/Themes/Basic/Colors.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
x:Key="WD.NormalSolidColorBrush"
po:Freeze="True"
Color="{StaticResource WD.NormalColor}" />
<Color x:Key="WD.NormalSuccess" po:Freeze="True">#FF13CE67</Color>
<SolidColorBrush
x:Key="WD.SuccessNormalBrush"
po:Freeze="True"
Color="{StaticResource WD.NormalSuccess}" />

<!-- Success颜色 -->

<Color x:Key="WD.SuccessBorderBrushColor" po:Freeze="True">#99FA68</Color>
Expand Down
Loading

0 comments on commit be272b9

Please sign in to comment.