Skip to content

Commit

Permalink
- Added Needle style to Analog Display.
Browse files Browse the repository at this point in the history
- Added Analog Display Bar/Needle color selection.
- Added Menu Icon Style selection to settings. You can change these settings in View Settings.
  • Loading branch information
WebSpiderTeam committed May 26, 2024
1 parent 027a42d commit 3173ec6
Show file tree
Hide file tree
Showing 10 changed files with 246 additions and 84 deletions.
2 changes: 1 addition & 1 deletion BluetoothDMM WPF/Bluetooth.Dmm/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2040,7 +2040,7 @@ public static ArrayList ParseHeartRateValue(byte[] data, bool LogData, int isBDM
// Testing other device data
var TestDevice = 0;
#if DEBUG// In debug mode do not custom-handle the exception, let Visual Studio handle it
TestDevice = 7;
TestDevice = 0;
#else
TestDevice = 0;
#endif
Expand Down
6 changes: 6 additions & 0 deletions BluetoothDMM WPF/BluetoothDMM/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@
<setting name="CheckUpdates" serializeAs="String">
<value>True</value>
</setting>
<setting name="ADisplayNewStyle" serializeAs="String">
<value>False</value>
</setting>
<setting name="ADisplayBarColor" serializeAs="String">
<value>#FFFFFF00</value>
</setting>
</BluetoothDMM.Properties.Settings>
</userSettings>
</configuration>
92 changes: 80 additions & 12 deletions BluetoothDMM WPF/BluetoothDMM/Classes/Arc.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
Expand All @@ -23,7 +24,7 @@ static CircularProgress()

StrokeThicknessProperty.OverrideMetadata(
typeof(CircularProgress),
new FrameworkPropertyMetadata(10.0));
new FrameworkPropertyMetadata(1.0));
}

public double StartAngle
Expand All @@ -43,6 +44,12 @@ public double Value
set { SetValue(ValueProperty, value); }
}

public int Type
{
get { return (int)GetValue(TypeProperty); }
set { SetValue(TypeProperty, value); }
}

#region 종료 각도 속성 - StartAngleProperty

/// <summary>
Expand Down Expand Up @@ -76,6 +83,16 @@ public double Value
FrameworkPropertyMetadataOptions.AffectsRender,
null, // Property changed callback
new CoerceValueCallback(CoerceValue)); // Coerce value callback
// DependencyProperty - Value (0 - 100)
private static FrameworkPropertyMetadata typeMetadata =
new FrameworkPropertyMetadata(
0, // Default value
FrameworkPropertyMetadataOptions.AffectsRender,
null, // Property changed callback
new CoerceValueCallback(TypeValue)); // Coerce value callback

public static readonly DependencyProperty TypeProperty =
DependencyProperty.Register("Type", typeof(int), typeof(CircularProgress), typeMetadata);

public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(double), typeof(CircularProgress), valueMetadata);
Expand All @@ -86,6 +103,13 @@ public double Value
public static readonly DependencyProperty EndAngleProperty =
DependencyProperty.Register("EndAngle", typeof(double), typeof(CircularProgress), EndAngleMetadata);

private static object TypeValue(DependencyObject depObj, object baseVal)
{
int val = (int)baseVal;
val = Math.Min(val, 1);
val = Math.Max(val, 0);
return val;
}
private static object CoerceValue(DependencyObject depObj, object baseVal)
{
double val = (double)baseVal;
Expand Down Expand Up @@ -113,37 +137,81 @@ protected override Geometry DefiningGeometry
{
get
{
int type = Type;
double multiplerTop = 1;
double multiplerBottom = 0.965;
double change = 1;
if (type == 1)
{
multiplerTop = 0.98;
multiplerBottom = 0.945;
}
double startAngle = StartAngle + 90;
double Differ = Math.Abs(EndAngle - StartAngle);
double endAngle = startAngle - ((Value / 100.0) * (Differ)+0.2);

double maxWidth = Math.Max(0.0, RenderSize.Width - StrokeThickness);
double maxHeight = Math.Max(0.0, RenderSize.Height - StrokeThickness);

double xStart = maxWidth / 2.0 * Math.Cos(startAngle * Math.PI / 180.0);
double yStart = maxHeight / 2.0 * Math.Sin(startAngle * Math.PI / 180.0);
double xTopStart = maxWidth * multiplerTop / 2.0 * Math.Cos(startAngle * Math.PI / 180.0);
double yTopStart = maxHeight * multiplerTop / 2.0 * Math.Sin(startAngle * Math.PI / 180.0);

double xTopEnd = maxWidth * multiplerTop / 2.0 * Math.Cos(endAngle * Math.PI / 180.0);
double yTopEnd = maxHeight * multiplerTop / 2.0 * Math.Sin(endAngle * Math.PI / 180.0);

double xBottomStart = maxWidth * multiplerBottom / 2.0 * Math.Cos(startAngle * Math.PI / 180.0);
double yBottomStart = maxHeight * multiplerBottom / 2.0 * Math.Sin(startAngle * Math.PI / 180.0);

double xBottomEnd = maxWidth * multiplerBottom / 2.0 * Math.Cos(endAngle * Math.PI / 180.0);
double yBottomEnd = maxHeight * multiplerBottom / 2.0 * Math.Sin(endAngle * Math.PI / 180.0);

double xEnd = maxWidth / 2.0 * Math.Cos(endAngle * Math.PI / 180.0);
double yEnd = maxHeight / 2.0 * Math.Sin(endAngle * Math.PI / 180.0);
double xPinEnd = maxWidth * multiplerBottom / 2.0 * Math.Cos((endAngle + 0.3) * Math.PI / 180.0);
double yPinEnd = maxHeight * multiplerBottom / 2.0 * Math.Sin((endAngle + 0.3) * Math.PI / 180.00);

StreamGeometry geom = new StreamGeometry();
using (StreamGeometryContext ctx = geom.Open())
{
ctx.BeginFigure(
new Point((RenderSize.Width / 2.0) + xStart,
(RenderSize.Height / 2.0) - yStart),
new Point((RenderSize.Width / 2.0) + xBottomStart,
(RenderSize.Height / 2.0) - yBottomStart),
true, // Filled
false); // Closed
ctx.ArcTo(
new Point((RenderSize.Width / 2.0) + xEnd,
(RenderSize.Height / 2.0) - yEnd),
new Size(maxWidth / 2.0, maxHeight / 2),
new Point((RenderSize.Width / 2.0) + xBottomEnd,
(RenderSize.Height / 2.0) - yBottomEnd),
new Size(maxWidth / (2.0/multiplerBottom), maxHeight / (2.0/multiplerBottom)),
0.0, // rotationAngle
(startAngle - endAngle) > 180, // greater than 180 deg?
SweepDirection.Clockwise,
true, // isStroked
false);
// ctx.LineTo(new Point((RenderSize.Width / 2.0), (RenderSize.Height / 2.0)), true, true);
true);

ctx.LineTo(new Point((RenderSize.Width / 2.0) + xTopEnd, (RenderSize.Height / 2.0) - yTopEnd), true, false);
if (Type == 0)
{
ctx.ArcTo(
new Point((RenderSize.Width / 2.0) + xTopStart,
(RenderSize.Height / 2.0) - yTopStart),
new Size(maxWidth / (2.0 / multiplerTop), maxHeight / (2.0 / multiplerTop)),
0.0, // rotationAngle
(startAngle - endAngle) > 180, // greater than 180 deg?
SweepDirection.Counterclockwise,
true, // isStroked
false);
ctx.LineTo(new Point((RenderSize.Width / 2.0) + xBottomStart, (RenderSize.Height / 2.0) - yBottomStart), true, false);
} else
{
ctx.LineTo(new Point((RenderSize.Width / 2.0) + xPinEnd, (RenderSize.Height / 2.0) - yPinEnd), true, false);
ctx.ArcTo(
new Point((RenderSize.Width / 2.0) + xBottomStart,
(RenderSize.Height / 2.0) - yBottomStart),
new Size(maxWidth / (2.0 / multiplerBottom), maxHeight / (2.0 / multiplerBottom)),
0.0, // rotationAngle
(startAngle - endAngle) > 180, // greater than 180 deg?
SweepDirection.Counterclockwise,
true, // isStroked
false);
}
}

return geom;
Expand Down
10 changes: 6 additions & 4 deletions BluetoothDMM WPF/BluetoothDMM/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -527,16 +527,18 @@
<MenuItem Header="Quit" Name="Quit" Style="{StaticResource MainMenuitem}" Click="Quit_Click"/>
</ContextMenu>
</Grid.Resources>
<Viewbox Width="620" HorizontalAlignment="Stretch" Margin="0,10,0,0" Stretch="Uniform" VerticalAlignment="Top" StretchDirection="Both">
<Viewbox Width="620" HorizontalAlignment="Stretch" Margin="0,0,0,0" Stretch="Uniform" VerticalAlignment="Top" StretchDirection="Both">
<Grid>
<StackPanel Height="55" Width="270" Margin="0,0,0,0">
<StackPanel Height="65" Width="270" Margin="0,0,0,0">
<local:CircularProgress
x:Name="Meter"
Height="500" Width="500" Margin="0,10,0,0"
Height="500" Width="500" Margin="0,12,0,0"
StartAngle="29.7"
EndAngle="-29.3"
Stroke="#FFFFFF00"
Stroke="{Binding Source={x:Static settings:Settings.Default}, Path=ADisplayBarColor, Mode=OneWay}"
Fill="{Binding Source={x:Static settings:Settings.Default}, Path=ADisplayBarColor, Mode=OneWay}"
Value="0.1"
Type="{Binding Source={x:Static settings:Settings.Default}, Path=ADisplayNewStyle, Mode=OneWay}"
HorizontalAlignment="Center"/>
<Path Width="270" Height="55" Margin="0,-973,0,0" Fill="#FF0E0000" Data="m 119.95707,-30.720772 3.25784,9.461455 m 0.87995,-10.845939 2.91094,8.958938 m 1.2504,-10.270992 2.94662,9.63797 m 1.23695,-10.877219 2.64788,9.234264 m 5.78097,-11.492762 2.48079,9.94991 m 1.76192,-10.968494 2.20787,9.563318 m 2.052,-10.507697 2.04163,9.605113 m 2.23404,-10.475007 1.86949,9.617671 m -75.369666,17.134182 4.712805,8.5021243 m -0.878283,-10.5840943 4.677955,8.7979516 m -0.807665,-10.8126826 4.470953,8.7747389 m -0.566125,-10.7216289 4.356781,8.932722 m 3.551844,-12.62056 4.064541,9.129103 m -0.0632,-10.868952 3.9996,9.422459 m 0.0316,-11.092207 3.76717,9.324081 m 0.29247,-10.923235 3.57025,9.300817 m 175.6137,-9.300878 -3.47386,9.049723 m 7.53354,-7.450561 -3.57946,8.859474 m 7.61058,-7.189743 -4.06318,9.572249 m 8.06455,-7.832381 -3.98718,8.955354 m 11.89582,-5.267503 -4.51883,9.2649736 m 8.42369,-7.3180786 -4.72361,9.2706064 m 8.59385,-7.2559094 -4.89645,9.2088867 m 8.73096,-7.1268917 -5.0851,9.1737609 m -68.41503,-35.9256059 -1.96374,10.102557 m 6.2394,-9.232677 -2.11097,9.931365 m 6.37082,-8.986988 -2.29914,9.958669 m 6.54184,-8.940063 -2.41973,9.705028 m 10.8486,-7.44654 -2.64018,9.207387 m 6.82377,-7.968149 -2.83021,9.257192 m 6.99152,-7.94514 -2.88952,8.893015 m 7.02732,-7.508517 -3.08764,8.967161 m -73.94126,-22.549411 -0.18449,10.569143 m 4.54624,-10.454937 -0.36544,10.464869 m 4.72455,-10.274552 -0.54858,10.467569 m 4.90372,-10.201178 -0.71238,10.187471 m 9.40538,-9.426937 -1.03644,9.861033 m 5.37166,-9.367098 -1.22037,9.939147 m 5.54631,-9.369617 -1.40716,10.012503 m 5.7225,-9.367582 -1.52212,9.610278 m -76.69516,-9.610276 1.51703,9.578121 m 2.7983,-10.223061 1.41121,10.041225 m 2.91476,-10.610732 1.24556,10.144254 m 3.08965,-10.638203 1.05581,10.045329 m 7.63717,-10.805862 0.71238,10.187485 m 3.64275,-10.453854 0.52568,10.03054 m 3.83345,-10.220858 0.35041,10.034445 m 4.01136,-10.148663 0.18085,10.361007 m 26.52075,-15.443445 -1.42215,16.255218 m 45.37072,-8.501493 -4.1111,15.342827 m 46.04562,-0.07533 -6.67101,14.306015 m -209.727043,-14.32697 6.830483,14.648015 m 35.10695,-29.907402 4.12505,15.394881 m 39.82505,-23.140082 1.40249,16.030516 m 66.2693,-18.360358 -3.7129,21.056905 m 47.33941,-8.22945 -6.76209,18.578668 m -171.40869,-18.996666 7.02985,19.314347 m 36.71542,-31.913147 3.72324,21.115539 m 41.6929,-25.186439 v 22.243909 m 135.00005,5.567961 c -5.16677,8.949108 -10.33354,17.898215 -15.50031,26.8473224 M 66.349166,-28.16797 81.384742,-2.1255919" Stretch="Fill" StrokeThickness="2" Opacity="0.7" >
<Path.Effect>
Expand Down
4 changes: 2 additions & 2 deletions BluetoothDMM WPF/BluetoothDMM/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.25.0.0")]
[assembly: AssemblyFileVersion("1.25.0.0")]
[assembly: AssemblyVersion("1.26.0.0")]
[assembly: AssemblyFileVersion("1.26.0.0")]
26 changes: 25 additions & 1 deletion BluetoothDMM WPF/BluetoothDMM/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions BluetoothDMM WPF/BluetoothDMM/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,11 @@
<Setting Name="CheckUpdates" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="ADisplayNewStyle" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ADisplayBarColor" Type="System.String" Scope="User">
<Value Profile="(Default)">#FFFFFF00</Value>
</Setting>
</Settings>
</SettingsFile>
Loading

0 comments on commit 3173ec6

Please sign in to comment.