Skip to content

Commit 84a120e

Browse files
committed
code optimized
1 parent 313294b commit 84a120e

File tree

1 file changed

+74
-32
lines changed

1 file changed

+74
-32
lines changed

VitalSync/VitalSync/MainWindow.xaml

Lines changed: 74 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,48 @@
1414
<local:ECGMonitorViewModel/>
1515
</Grid.DataContext>
1616

17+
<Grid.Resources>
18+
<Style TargetType="Border" x:Key="borderStyle">
19+
<Setter Property="BorderThickness" Value="2"/>
20+
<Setter Property="BorderBrush" Value="#e3e2df"/>
21+
<Setter Property="Background" Value="#0a1f53"/>
22+
<Setter Property="Padding" Value="20"/>
23+
<Setter Property="CornerRadius" Value="10"/>
24+
</Style>
25+
26+
<Style TargetType="TextBlock" x:Key="bindingTextStyle">
27+
<Setter Property="FontSize" Value="28"/>
28+
<Setter Property="FontWeight" Value="Bold"/>
29+
<Setter Property="Foreground" Value="#2ac145"/>
30+
<Setter Property="TextAlignment" Value="Right"/>
31+
</Style>
32+
33+
<Style TargetType="TextBlock" x:Key="staticTextStyle">
34+
<Setter Property="FontSize" Value="16"/>
35+
<Setter Property="FontWeight" Value="Bold"/>
36+
<Setter Property="Foreground" Value="#e3e2df"/>
37+
<Setter Property="TextAlignment" Value="Right"/>
38+
</Style>
39+
40+
<Style TargetType="TextBlock" x:Key="timeIndicatorTextStyle">
41+
<Setter Property="FontSize" Value="16"/>
42+
<Setter Property="VerticalAlignment" Value="Bottom"/>
43+
<Setter Property="Foreground" Value="#FFFFFF"/>
44+
<Setter Property="HorizontalAlignment" Value="Left"/>
45+
</Style>
46+
47+
<Style TargetType="Path" x:Key="iconStyle">
48+
<Setter Property="Stretch" Value="Uniform"/>
49+
<Setter Property="Fill" Value="#FFFFFFFF"/>
50+
<Setter Property="Width" Value="60"/>
51+
<Setter Property="Height" Value="60"/>
52+
<Setter Property="RenderTransformOrigin" Value="0.5,0.5"/>
53+
<Setter Property="HorizontalAlignment" Value="Left"/>
54+
<Setter Property="VerticalAlignment" Value="Top"/>
55+
56+
</Style>
57+
</Grid.Resources>
58+
1759
<Grid.RowDefinitions>
1860
<!-- Define rows for different sections -->
1961
<RowDefinition Height="2.2*" />
@@ -31,43 +73,43 @@
3173
</Grid.ColumnDefinitions>
3274

3375
<!-- ECG Monitor Title -->
34-
<Border Grid.Row="0" Grid.Column="0" Background="#0a1f53" BorderBrush="#e3e2df" BorderThickness="2" CornerRadius="10" Padding="20" Margin="0,0,10,10">
76+
<Border Grid.Row="0" Grid.Column="0" Margin="0,0,10,10" Style="{StaticResource borderStyle}">
3577
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Center">
3678
<Image Source="/Images/electrocardiogram.png" Width="80" Height="80" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="20,0" />
3779
<TextBlock Text="Electrocardiogram Monitor" FontSize="35" FontWeight="Bold" Foreground="#e3e2df" VerticalAlignment="Center"/>
3880
</StackPanel>
3981
</Border>
4082

4183
<!-- Blood Pressure Metric -->
42-
<Border BorderBrush="#e3e2df" BorderThickness="2" Background="#0a1f53" Grid.Row="0" Grid.Column="1" CornerRadius="10" Padding="20" Margin="0,0,10,10">
84+
<Border Grid.Row="0" Grid.Column="1" Margin="0,0,10,10" Style="{StaticResource borderStyle}">
4385
<Grid>
4486
<!-- Define columns for icon and text -->
4587
<Grid.ColumnDefinitions>
4688
<ColumnDefinition Width="3.5*"/>
4789
<ColumnDefinition Width="6.5*"/>
4890
</Grid.ColumnDefinitions>
49-
<Path x:Name="bloodPressure" Stretch="Uniform" Fill="#FFFFFFFF" Width="60" Height="60" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top"/>
50-
<TextBlock Text="35 min" FontSize="16" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="White"/>
91+
<Path x:Name="bloodPressure" Style="{StaticResource iconStyle}"/>
92+
<TextBlock Text="35 min" Style="{StaticResource timeIndicatorTextStyle}"/>
5193
<StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Vertical">
52-
<TextBlock Text="{Binding BloodPressure}" FontSize="28" FontWeight="Bold" Foreground="#2ac145" TextAlignment="Right"/>
53-
<TextBlock Text="Blood Pressure" FontSize="16" FontWeight="Bold" Foreground="#e3e2df" TextAlignment="Right"/>
94+
<TextBlock Text="{Binding BloodPressure}" Style="{StaticResource bindingTextStyle}"/>
95+
<TextBlock Text="Blood Pressure" Style="{StaticResource staticTextStyle}"/>
5496
</StackPanel>
5597
</Grid>
5698
</Border>
5799

58100
<!-- Body Temperature Metric -->
59-
<Border BorderBrush="#e3e2df" BorderThickness="2" Background="#0a1f53" Grid.Row="0" Grid.Column="2" CornerRadius="10" Padding="20" Margin="0,0,0,10">
101+
<Border Grid.Row="0" Grid.Column="2" Margin="0,0,0,10" Style="{StaticResource borderStyle}">
60102
<Grid>
61103
<!-- Define columns for icon and text -->
62104
<Grid.ColumnDefinitions>
63105
<ColumnDefinition Width="5*"/>
64106
<ColumnDefinition Width="5*"/>
65107
</Grid.ColumnDefinitions>
66-
<Path x:Name="bodyTemperature" Stretch="Uniform" Fill="#FFFFFFFF" Width="60" Height="60" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top"/>
67-
<TextBlock Text="120 min" FontSize="16" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="White"/>
108+
<Path x:Name="bodyTemperature" Style="{StaticResource iconStyle}"/>
109+
<TextBlock Text="120 min" Style="{StaticResource timeIndicatorTextStyle}"/>
68110
<StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Vertical">
69-
<TextBlock Text="{Binding BodyTemperature}" FontSize="28" FontWeight="Bold" Foreground="#2ac145" TextAlignment="Right"/>
70-
<TextBlock Text="Body Temperature" FontSize="16" FontWeight="Bold" Foreground="#e3e2df" TextAlignment="Right"/>
111+
<TextBlock Text="{Binding BodyTemperature}" Style="{StaticResource bindingTextStyle}"/>
112+
<TextBlock Text="Body Temperature" Style="{StaticResource staticTextStyle}"/>
71113
</StackPanel>
72114
</Grid>
73115
</Border>
@@ -77,22 +119,22 @@
77119
<!-- Metric Panels -->
78120
<UniformGrid Grid.Row="1" Columns="4" HorizontalAlignment="Stretch">
79121
<!-- Heart Rate Panel -->
80-
<Border BorderBrush="#e3e2df" BorderThickness="2" Background="#0a1f53" CornerRadius="10" Padding="20" Margin="0,0,10,10">
122+
<Border Margin="0,0,10,10" Style="{StaticResource borderStyle}">
81123
<Grid>
82124
<!-- Define columns for icon and text -->
83125
<Grid.ColumnDefinitions>
84126
<ColumnDefinition Width="5*"/>
85127
<ColumnDefinition Width="5*"/>
86128
</Grid.ColumnDefinitions>
87-
<Path x:Name="heartRate" Stretch="Uniform" Fill="#FFFFFFFF" Width="60" Height="60" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top">
129+
<Path x:Name="heartRate" Style="{StaticResource iconStyle}">
88130
<Path.RenderTransform>
89131
<ScaleTransform x:Name="HeartScaleTransform" ScaleX="1" ScaleY="1"/>
90132
</Path.RenderTransform>
91133
</Path>
92-
<TextBlock Text="now" FontSize="16" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="White"/>
134+
<TextBlock Text="now" Style="{StaticResource timeIndicatorTextStyle}"/>
93135
<StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Vertical">
94-
<TextBlock Text="{Binding HeartRate}" FontSize="28" FontWeight="Bold" Foreground="#2ac145" TextAlignment="Right"/>
95-
<TextBlock Text="Heart Rate" FontSize="16" FontWeight="Bold" Foreground="#e3e2df" TextAlignment="Right"/>
136+
<TextBlock Text="{Binding HeartRate}" Style="{StaticResource bindingTextStyle}"/>
137+
<TextBlock Text="Heart Rate" Style="{StaticResource staticTextStyle}"/>
96138
</StackPanel>
97139
<Grid.Triggers>
98140
<!-- Animation for heartbeat effect -->
@@ -115,59 +157,59 @@
115157
</Border>
116158

117159
<!-- PR Interval Panel -->
118-
<Border BorderBrush="#e3e2df" BorderThickness="2" Background="#0a1f53" CornerRadius="10" Padding="20" Margin="0,0,10,10">
160+
<Border Margin="0,0,10,10" Style="{StaticResource borderStyle}">
119161
<Grid>
120162
<Grid.ColumnDefinitions>
121163
<!-- Define columns for icon and text -->
122164
<ColumnDefinition Width="5*"/>
123165
<ColumnDefinition Width="5*"/>
124166
</Grid.ColumnDefinitions>
125-
<Path x:Name="PrInterval" Stretch="Uniform" Fill="#FFFFFFFF" Width="60" Height="60" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top"/>
126-
<TextBlock Text="now" FontSize="16" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="White"/>
167+
<Path x:Name="PrInterval" Style="{StaticResource iconStyle}"/>
168+
<TextBlock Text="now" Style="{StaticResource timeIndicatorTextStyle}"/>
127169
<StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Vertical">
128-
<TextBlock Text="{Binding PRInterval}" FontSize="28" FontWeight="Bold" Foreground="#2ac145" TextAlignment="Right"/>
129-
<TextBlock Text="PR Interval" FontSize="16" FontWeight="Bold" Foreground="#e3e2df" TextAlignment="Right"/>
170+
<TextBlock Text="{Binding PRInterval}" Style="{StaticResource bindingTextStyle}"/>
171+
<TextBlock Text="PR Interval" Style="{StaticResource staticTextStyle}"/>
130172
</StackPanel>
131173
</Grid>
132174
</Border>
133175

134176
<!-- QT Interval Panel -->
135-
<Border BorderBrush="#e3e2df" BorderThickness="2" Background="#0a1f53" CornerRadius="10" Padding="20" Margin="0,0,10,10">
177+
<Border Margin="0,0,10,10" Style="{StaticResource borderStyle}">
136178
<Grid>
137179
<Grid.ColumnDefinitions>
138180
<!-- Define columns for icon and text -->
139181
<ColumnDefinition Width="5*"/>
140182
<ColumnDefinition Width="5*"/>
141183
</Grid.ColumnDefinitions>
142-
<Path x:Name="QtInterval" Stretch="Uniform" Fill="#FFFFFFFF" Width="60" Height="60" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top"/>
143-
<TextBlock Text="now" FontSize="16" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="White"/>
184+
<Path x:Name="QtInterval" Style="{StaticResource iconStyle}"/>
185+
<TextBlock Text="now" Style="{StaticResource timeIndicatorTextStyle}"/>
144186
<StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Vertical">
145-
<TextBlock Text="{Binding QTInterval}" FontSize="28" FontWeight="Bold" Foreground="#2ac145" TextAlignment="Right"/>
146-
<TextBlock Text="QT Interval" FontSize="16" FontWeight="Bold" Foreground="#e3e2df" TextAlignment="Right"/>
187+
<TextBlock Text="{Binding QTInterval}" Style="{StaticResource bindingTextStyle}"/>
188+
<TextBlock Text="QT Interval" Style="{StaticResource staticTextStyle}"/>
147189
</StackPanel>
148190
</Grid>
149191
</Border>
150192

151193
<!-- QRS Duration Panel -->
152-
<Border BorderBrush="#e3e2df" BorderThickness="2" Background="#0a1f53" CornerRadius="10" Padding="20" Margin="0,0,0,10">
194+
<Border Margin="0,0,0,10" Style="{StaticResource borderStyle}">
153195
<Grid>
154196
<Grid.ColumnDefinitions>
155197
<!-- Define columns for icon and text -->
156198
<ColumnDefinition Width="5*"/>
157199
<ColumnDefinition Width="5*"/>
158200
</Grid.ColumnDefinitions>
159-
<Path x:Name="QrsDuration" Stretch="Uniform" Fill="#FFFFFFFF" Width="60" Height="60" RenderTransformOrigin="0.5,0.5" HorizontalAlignment="Left" VerticalAlignment="Top"/>
160-
<TextBlock Text="now" FontSize="16" HorizontalAlignment="Left" VerticalAlignment="Bottom" Foreground="White"/>
201+
<Path x:Name="QrsDuration" Style="{StaticResource iconStyle}"/>
202+
<TextBlock Text="now" Style="{StaticResource timeIndicatorTextStyle}"/>
161203
<StackPanel Grid.Column="1" HorizontalAlignment="Right" VerticalAlignment="Bottom" Orientation="Vertical">
162-
<TextBlock Text="{Binding QRSDuration}" FontSize="28" FontWeight="Bold" Foreground="#2ac145" TextAlignment="Right"/>
163-
<TextBlock Text="QRS Duration" FontSize="16" FontWeight="Bold" Foreground="#e3e2df" TextAlignment="Center"/>
204+
<TextBlock Text="{Binding QRSDuration}" Style="{StaticResource bindingTextStyle}"/>
205+
<TextBlock Text="QRS Duration" Style="{StaticResource staticTextStyle}"/>
164206
</StackPanel>
165207
</Grid>
166208
</Border>
167209
</UniformGrid>
168210

169211
<!-- ECG Chart Section -->
170-
<Border Grid.Row="2" BorderBrush="#e3e2df" BorderThickness="2" Background="#0a1f53" CornerRadius="10" Padding="20" Margin="0,0,0,10">
212+
<Border Grid.Row="2" Margin="0,0,0,10" Style="{StaticResource borderStyle}">
171213
<Grid>
172214
<Grid.RowDefinitions>
173215
<!-- Rows for title and chart -->

0 commit comments

Comments
 (0)