Skip to content

Commit

Permalink
Change UI event handler setup method to use loaded event
Browse files Browse the repository at this point in the history
  • Loading branch information
DJDavid98 committed Dec 31, 2024
1 parent d10c9c3 commit 416cd1b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions BluetoothHeartrateModule/BluetoothHeartrateModule.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<TargetFramework>net8.0-windows10.0.22621.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>2.0.16.0</Version>
<AssemblyVersion>2.0.16.0</AssemblyVersion>
<FileVersion>2.0.16.0</FileVersion>
<Version>2.0.17.0</Version>
<AssemblyVersion>2.0.17.0</AssemblyVersion>
<FileVersion>2.0.17.0</FileVersion>
<Authors>DJDavid98</Authors>
<Product>Bluetooth Heartrate</Product>
<ApplicationIcon>logo\logo.ico</ApplicationIcon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
x:Class="BluetoothHeartrateModule.UI.BluetoothHeartrateRuntimeView"
>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Vertical" Loaded="OnLoad">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Image x:Name="BluetoothIcon" Width="32" Height="32" HorizontalAlignment="Left"/>
<TextBlock
Expand Down
18 changes: 11 additions & 7 deletions BluetoothHeartrateModule/UI/BluetoothHeartrateRuntimeView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
Expand Down Expand Up @@ -26,13 +27,6 @@ public BluetoothHeartrateRuntimeView(BluetoothHeartrateModule module)
InitializeComponent();

DataContext = this;

this.Module.DeviceDataManager.OnDeviceListUpdate += HandleDeviceListUpdate;
this.Module.DeviceDataManager.OnBluetoothAvailabilityChange += HandleBluetoothAvailabilityChange;
this.Module.DeviceDataManager.OnConnectionStatusChange += HandleConnectionStatusChange;
HandleDeviceListUpdate();
HandleBluetoothAvailabilityChange();
HandleConnectionStatusChange();
}

private void HandleDeviceListUpdate()
Expand Down Expand Up @@ -153,5 +147,15 @@ private void DeviceSelection_LostMouseCapture(object sender, MouseEventArgs e)
{

}

private void OnLoad(object sender, RoutedEventArgs e)
{
this.Module.DeviceDataManager.OnDeviceListUpdate += HandleDeviceListUpdate;
this.Module.DeviceDataManager.OnBluetoothAvailabilityChange += HandleBluetoothAvailabilityChange;
this.Module.DeviceDataManager.OnConnectionStatusChange += HandleConnectionStatusChange;
HandleDeviceListUpdate();
HandleBluetoothAvailabilityChange();
HandleConnectionStatusChange();
}
}
}

0 comments on commit 416cd1b

Please sign in to comment.