1
0
Fork 0
Browse Source

change LogToggle to stop logging and clear log area.

The tablet I'm using most of the time to monitor the system (with Eyes and Ears) is under powered (too many Windows 10 updates at this point by I digress). So, it doesn't handle the increase in RAM needed for this feature very well. I change the LogToggle to provide a way to clear the log area alongside stopping the program logging (reducing RAM usage and processing cycles).
stable
Craig Oates 3 years ago
parent
commit
01ae38a354
  1. 6
      src/EyesAndEars.UWP/EyesAndEars.UWP/EyesAndEars.UWP.csproj
  2. 39
      src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml
  3. 14
      src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml.cs
  4. 4
      src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs

6
src/EyesAndEars.UWP/EyesAndEars.UWP/EyesAndEars.UWP.csproj

@ -19,9 +19,9 @@
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview> <WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled> <AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile> <GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<PackageCertificateKeyFile>EyesAndEars.UWP_TemporaryKey.pfx</PackageCertificateKeyFile> <PackageCertificateKeyFile>
<PackageCertificateThumbprint> </PackageCertificateKeyFile>
</PackageCertificateThumbprint> <PackageCertificateThumbprint>DAE20EE5240091F7E98C03948A35781171CB1005</PackageCertificateThumbprint>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm> <AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision> <AppxAutoIncrementPackageRevision>False</AppxAutoIncrementPackageRevision>
<GenerateTestArtifacts>True</GenerateTestArtifacts> <GenerateTestArtifacts>True</GenerateTestArtifacts>

39
src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml

@ -7,9 +7,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" mc:Ignorable="d"
Background="{ThemeResource SystemControlAcrylicWindowBrush}"> Background="{ThemeResource SystemControlAcrylicWindowBrush}">
<Grid Margin="12"> <Grid Margin="12">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="96"/> <RowDefinition Height="96"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
@ -42,7 +42,7 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<Grid Grid.Row="1" Margin="0,12"> <Grid Grid.Row="1" Margin="0,12,0,0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
@ -129,8 +129,8 @@
<TextBlock Text="Dashboard updates at slower rate than devices." <TextBlock Text="Dashboard updates at slower rate than devices."
FontSize="18" Margin="0" Foreground="SlateGray" FontSize="18" Margin="0" Foreground="SlateGray"
VerticalAlignment="Center"/> VerticalAlignment="Center"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
<!-- This device is not in use. Uncomment if becomes available. --> <!-- This device is not in use. Uncomment if becomes available. -->
<!--<Grid x:Name="Factory3Grid" Grid.Row="0" Grid.Column="2" <!--<Grid x:Name="Factory3Grid" Grid.Row="0" Grid.Column="2"
@ -204,26 +204,25 @@
</Grid> </Grid>
<Grid Grid.Row="2" Margin="0,0,0,0"> <Grid Grid.Row="2" Margin="0,0,0,8">
<ScrollViewer x:Name="LogViewer" Visibility="Visible" <ScrollViewer x:Name="LogViewer" VerticalScrollBarVisibility="Visible"
VerticalScrollBarVisibility="Visible" HorizontalScrollMode="Disabled" Margin="0"
HorizontalScrollMode="Disabled" VerticalScrollMode="Enabled">
VerticalScrollMode="Enabled" Margin="0,20"> <RichTextBlock x:Name="Logs" FontSize="16" FontFamily="Consolas">
<RichTextBlock x:Name="Logs" FontSize="16"
FontFamily="Consolas">
</RichTextBlock> </RichTextBlock>
</ScrollViewer> </ScrollViewer>
</Grid> </Grid>
<Grid Grid.Row="3" Margin="0"> <Grid Grid.Row="3" Margin="0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="113"/>
<ColumnDefinition Width="45"/>
<ColumnDefinition Width="*" MinWidth="350"/> <ColumnDefinition Width="*" MinWidth="350"/>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<StackPanel Orientation="Horizontal" Grid.Column="0"> <StackPanel Orientation="Horizontal" Grid.Column="0" Grid.ColumnSpan="2">
<ToggleButton x:Name="LogToggle" FontFamily="Segoe MDL2 Assets" <ToggleButton x:Name="LogToggle" FontFamily="Segoe MDL2 Assets"
Content="&#xE8BC;" HorizontalAlignment="Right" Content="&#xE8BC;" HorizontalAlignment="Right"
@ -242,17 +241,15 @@
ToolTipService.ToolTip="This is a link to a webpage with information about Nicola and the project."/> ToolTipService.ToolTip="This is a link to a webpage with information about Nicola and the project."/>
</StackPanel> </StackPanel>
<TextBox x:Name="WebAddressBox" Grid.Column="1" FontSize="26" <TextBox x:Name="WebAddressBox" Grid.Column="2" FontSize="26"
Text="{x:Bind _vm.BaseURL , Mode=TwoWay}" Text="{x:Bind _vm.BaseURL, Mode=TwoWay}"
Padding="20" TextAlignment="Left" Padding="20" TextAlignment="Left" TextWrapping="NoWrap" VerticalAlignment="Center"
HorizontalAlignment="Stretch" TextWrapping="NoWrap"
Margin="0" VerticalAlignment="Center"
HorizontalContentAlignment="Left" HorizontalContentAlignment="Left"
ToolTipService.Placement="Mouse" ToolTipService.Placement="Mouse"
ToolTipService.ToolTip="The base U.R.L. used to form the A.P.I. queries." ToolTipService.ToolTip="The base U.R.L. used to form the A.P.I. queries."
PlaceholderText="Enter the base U.R.L. here..." /> PlaceholderText="Enter the base U.R.L. here..." />
<StackPanel Orientation="Horizontal" Grid.Column="2"> <StackPanel Orientation="Horizontal" Grid.Column="3">
<ToggleButton x:Name="PlayButton" FontFamily="Segoe MDL2 Assets" <ToggleButton x:Name="PlayButton" FontFamily="Segoe MDL2 Assets"
Content="&#xE71A;" Height="79" Width="79" Content="&#xE71A;" Height="79" Width="79"
VerticalAlignment="Center" FontSize="28" VerticalAlignment="Center" FontSize="28"

14
src/EyesAndEars.UWP/EyesAndEars.UWP/MainPage.xaml.cs

@ -12,6 +12,7 @@ namespace EyesAndEars.UWP {
MainPageVM _vm = new MainPageVM(); MainPageVM _vm = new MainPageVM();
DispatcherTimer _dispatcherTimer = new DispatcherTimer(); DispatcherTimer _dispatcherTimer = new DispatcherTimer();
bool _logData;
public MainPage() { public MainPage() {
InitializeComponent(); InitializeComponent();
@ -52,14 +53,14 @@ namespace EyesAndEars.UWP {
if (!string.IsNullOrEmpty(url)) { if (!string.IsNullOrEmpty(url)) {
// Devices 3 and 6 are not in use. // Devices 3 and 6 are not in use.
_vm.Device1 = await DataServices.UpdateDevice _vm.Device1 = await DataServices.UpdateDevice
(url, 1, Logs, _vm.Device1.LatestStatus.status, AudioUpdater); (url, 1, Logs, _vm.Device1.LatestStatus.status, AudioUpdater, _logData);
_vm.Device2 = await DataServices.UpdateDevice _vm.Device2 = await DataServices.UpdateDevice
(url, 2, Logs, _vm.Device2.LatestStatus.status, AudioUpdater); (url, 2, Logs, _vm.Device2.LatestStatus.status, AudioUpdater, _logData);
// _vm.Device3 = await DataServices.UpdateDevice(url, 3); // _vm.Device3 = await DataServices.UpdateDevice(url, 3);
_vm.Device4 = await DataServices.UpdateDevice _vm.Device4 = await DataServices.UpdateDevice
(url, 4, Logs, _vm.Device4.LatestStatus.status, AudioUpdater); (url, 4, Logs, _vm.Device4.LatestStatus.status, AudioUpdater, _logData);
_vm.Device5 = await DataServices.UpdateDevice _vm.Device5 = await DataServices.UpdateDevice
(url, 5, Logs, _vm.Device5.LatestStatus.status, AudioUpdater); (url, 5, Logs, _vm.Device5.LatestStatus.status, AudioUpdater, _logData);
// _vm.Device6 = await DataServices.UpdateDevice(url, 6); // _vm.Device6 = await DataServices.UpdateDevice(url, 6);
_vm.CurrentTime = DateTime.UtcNow.ToShortTimeString(); _vm.CurrentTime = DateTime.UtcNow.ToShortTimeString();
} }
@ -83,11 +84,12 @@ namespace EyesAndEars.UWP {
} }
private void LogToggle_Unchecked(object sender, RoutedEventArgs e) { private void LogToggle_Unchecked(object sender, RoutedEventArgs e) {
LogViewer.Visibility = Visibility.Collapsed; _logData = false;
Logs.Blocks.Clear();
} }
private void LogToggle_Checked(object sender, RoutedEventArgs e) { private void LogToggle_Checked(object sender, RoutedEventArgs e) {
LogViewer.Visibility = Visibility.Visible; _logData = true;
} }
} }
} }

4
src/EyesAndEars.UWP/EyesAndEars.UWP/Services/DataServices.cs

@ -16,7 +16,7 @@ namespace EyesAndEars.UWP.Services {
static SpeechSynthesizer _synth = new SpeechSynthesizer(); static SpeechSynthesizer _synth = new SpeechSynthesizer();
public static async Task<Device> UpdateDevice(string url, int deviceId, public static async Task<Device> UpdateDevice(string url, int deviceId,
RichTextBlock logs, string currentStatus, MediaElement audioUpdater) { RichTextBlock logs, string currentStatus, MediaElement audioUpdater, bool _logData) {
try { try {
var id = MapFactoryDeviceToGalleyDevice(deviceId); // Has note. var id = MapFactoryDeviceToGalleyDevice(deviceId); // Has note.
var readingAPI = $"{url}/api/readings/latest/{id}"; var readingAPI = $"{url}/api/readings/latest/{id}";
@ -27,7 +27,7 @@ namespace EyesAndEars.UWP.Services {
var s = MapToDeviceStatus(statusJSON); var s = MapToDeviceStatus(statusJSON);
var c = UpdateStatusColour(deviceId, s.status, r.reading); var c = UpdateStatusColour(deviceId, s.status, r.reading);
var dev = new Device(deviceId, r, s, c); var dev = new Device(deviceId, r, s, c);
LogUpdate(logs, dev); if(_logData == true) LogUpdate(logs, dev);
NotifyAnyStatusChanges(currentStatus, dev, audioUpdater); NotifyAnyStatusChanges(currentStatus, dev, audioUpdater);
return dev; return dev;
} }