diff options
| author | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2023-04-23 12:00:02 +0300 |
|---|---|---|
| committer | Victoria Plitt <Victoria.Plitt@twine-s.com> | 2023-04-23 12:00:02 +0300 |
| commit | f86efbca4aac00a1a4e6d290feca1a0236c2d828 (patch) | |
| tree | e83fce8f7bf2da088a12bc6fa3b18ff32ac2377d /Software/Visual_Studio/Tango.Touch | |
| parent | 82f5e5a9c43641b473e54d1c0534f05bb8190f11 (diff) | |
| download | Tango-f86efbca4aac00a1a4e6d290feca1a0236c2d828.tar.gz Tango-f86efbca4aac00a1a4e6d290feca1a0236c2d828.zip | |
ArcProgress Control.
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch')
4 files changed, 133 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.cs new file mode 100644 index 000000000..510fd500d --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; + +namespace Tango.Touch.Controls +{ + public class TouchArcProgress : ProgressBar + { + private SharedUI.Shapes.Arc _arc; + private SharedUI.Shapes.Arc _arc_base; + + public double RingThickness + { + get { return (double)GetValue(RingThicknessProperty); } + set { SetValue(RingThicknessProperty, value); } + } + public static readonly DependencyProperty RingThicknessProperty = + DependencyProperty.Register("RingThickness", typeof(double), typeof(TouchArcProgress), new PropertyMetadata(3.0)); + + + + public int MinArcAngle + { + get { return (int)GetValue(MinArcAngleProperty); } + set { SetValue(MinArcAngleProperty, value); } + } + + // Using a DependencyProperty as the backing store for MinArcAngle. This enables animation, styling, binding, etc... + public static readonly DependencyProperty MinArcAngleProperty = + DependencyProperty.Register("MinArcAngle", typeof(int), typeof(TouchArcProgress), new PropertyMetadata(40)); + + + + public int MaxArcAngle + { + get { return (int)GetValue(MaxArcAngleProperty); } + set { SetValue(MaxArcAngleProperty, value); } + } + + // Using a DependencyProperty as the backing store for MaxArcAngle. This enables animation, styling, binding, etc... + public static readonly DependencyProperty MaxArcAngleProperty = + DependencyProperty.Register("MaxArcAngle", typeof(int), typeof(TouchArcProgress), new PropertyMetadata(320)); + + + + static TouchArcProgress() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchArcProgress), new FrameworkPropertyMetadata(typeof(TouchArcProgress))); + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + _arc = GetTemplateChild("PART_ArcValue") as SharedUI.Shapes.Arc; + _arc_base = GetTemplateChild("PART_ArcBase") as SharedUI.Shapes.Arc; + SetArcBase(); + SetArc(); + } + + protected override void OnValueChanged(double oldValue, double newValue) + { + base.OnValueChanged(oldValue, newValue); + SetArc(); + } + + protected override void OnMinimumChanged(double oldMinimum, double newMinimum) + { + base.OnMinimumChanged(oldMinimum, newMinimum); + SetArcBase(); + SetArc(); + } + + protected override void OnMaximumChanged(double oldMaximum, double newMaximum) + { + base.OnMaximumChanged(oldMaximum, newMaximum); + SetArcBase(); + SetArc(); + } + + private void SetArcBase() + { + if (_arc_base != null) + { + _arc_base.StartAngle = ((MaxArcAngle - MinArcAngle) * (Minimum / (Maximum - Minimum))) + MinArcAngle; + _arc_base.EndAngle = ((MaxArcAngle - MinArcAngle) * (Maximum / (Maximum - Minimum))) + MinArcAngle; + } + } + + private void SetArc() + { + if (_arc != null) + { + _arc.StartAngle = ((MaxArcAngle - MinArcAngle) * (Minimum / (Maximum - Minimum))) + MinArcAngle; + _arc.EndAngle = ((MaxArcAngle - MinArcAngle) * (Value / (Maximum - Minimum))) + MinArcAngle; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.xaml new file mode 100644 index 000000000..518b3632c --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchArcProgress.xaml @@ -0,0 +1,24 @@ +<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" + xmlns:local="clr-namespace:Tango.Touch.Controls"> + <ResourceDictionary.MergedDictionaries> + <ResourceDictionary Source="../Resources/Colors.xaml" /> + </ResourceDictionary.MergedDictionaries> + + <Style TargetType="{x:Type local:TouchArcProgress}"> + <Setter Property="Background" Value="{StaticResource TangoDividerBrush}"></Setter> + <Setter Property="Foreground" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type local:TouchArcProgress}"> + <Grid> + <shapes:Arc x:Name="PART_ArcBase" Stroke="{TemplateBinding Background}" StrokeThickness="{TemplateBinding RingThickness}" OriginRotationDegrees="90" Direction="Clockwise"/> + <shapes:Arc x:Name="PART_ArcValue" Stroke="{TemplateBinding Foreground}" StrokeThickness="{TemplateBinding RingThickness}" OriginRotationDegrees="90" Direction="Clockwise"/> + </Grid> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> + +</ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index 2e2370584..1096ec112 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -67,6 +67,7 @@ <Compile Include="Controls\FocusSelectionMode.cs" /> <Compile Include="Controls\IValueControl.cs" /> <Compile Include="Controls\MessageBoxVM.cs" /> + <Compile Include="Controls\TouchArcProgress.cs" /> <Compile Include="Controls\TouchAutoComplete.cs" /> <Compile Include="Controls\TouchCalendar.cs" /> <Compile Include="Controls\TouchCheckBox.cs" /> @@ -132,6 +133,10 @@ <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> </Page> + <Page Include="Controls\TouchArcProgress.xaml"> + <SubType>Designer</SubType> + <Generator>MSBuild:Compile</Generator> + </Page> <Page Include="Controls\TouchAutoComplete.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> @@ -497,7 +502,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml index a623203cf..8b49ccc6b 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -39,6 +39,7 @@ <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchSlider.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchStaticListBox.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchRingProgress.xaml" /> + <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchArcProgress.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchNativeListBox.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchGifAnimation.xaml" /> <ResourceDictionary Source="pack://application:,,,/Tango.Touch;component/Controls/TouchFlatListBox.xaml" /> |
