Skip to content

Commit

Permalink
add clear status on selected devices, forget honors selection
Browse files Browse the repository at this point in the history
  • Loading branch information
David Kline committed Jun 1, 2017
1 parent 41962a4 commit cf3e50f
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
Height="22" Width="32"
Canvas.Left="750" Canvas.Top="22">
<Button.RenderTransform>
<CompositeTransform ScaleX="1.0" ScaleY="0.8"/>
<CompositeTransform ScaleX="0.8" ScaleY="0.8"/>
</Button.RenderTransform>
</Button>
</Canvas>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ public void Dispose()
GC.SuppressFinalize(this);
}

/// <summary>
/// Clears the status message for this device.
/// </summary>
internal void ClearStatusMessage()
{
if (this.ViewModel.IsSelected)
{
this.ViewModel.ClearStatusMessage();
}
}

/// <summary>
/// Closes all applications running on this device.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ private void RegisterCommands()
this.ClearStatusMessageCommand = new Command(
(parameter) =>
{
this.StatusMessage = string.Empty;
this.ClearStatusMessage();
});

this.DisconnectCommand = new Command(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ private enum MonitorContextMenuCommandIds
public ICommand ClearStatusMessageCommand
{ get; private set; }

/// <summary>
/// Implementation of the clear status message command.
/// </summary>
internal void ClearStatusMessage()
{
this.StatusMessage = string.Empty;
}

/// <summary>
/// Command used to disconnect from the device.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,5 @@
Width="50" Height="40"
Canvas.Left="400" Canvas.Top="115"/>
</Canvas>
<ScrollViewer
Width="450" Height="75">
<TextBlock
x:Name="status"
Text="{Binding Path=StatusMessage}"
TextWrapping="WrapWholeWords"
FontSize="16"
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</ScrollViewer>
</StackPanel>
</ContentDialog>
20 changes: 14 additions & 6 deletions HoloLensCommander/HoloLensCommander/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,10 @@
<Canvas
x:Name="deviceControls"
HorizontalAlignment="Left" VerticalAlignment="Top"
Width="280" Height="115" Margin="10,0,0,0">
Width="280" Height="170" Margin="10,0,0,0">
<Border
BorderBrush="Black" BorderThickness="1"
Width="280" Height="105">
Width="280" Height="165">
</Border>
<TextBlock
x:Name="deviceControl"
Expand All @@ -232,17 +232,26 @@
HorizontalAlignment="Right" VerticalAlignment="Top"
FontFamily="Segoe MDL2 Assets" FontSize="20"
Width="70" Height="50"
Canvas.Left="107" Canvas.Top="42"/>
Canvas.Left="105" Canvas.Top="42"/>
<Button
x:Name="forgetDevices"
Content="&#xE74D;"
ToolTipService.ToolTip="Unregister ALL connected devices"
ToolTipService.ToolTip="Unregister the selected devices"
Command="{Binding Path=ForgetConnectionsCommand}"
IsEnabled="{Binding Path=HaveRegisteredDevices}"
HorizontalAlignment="Right" VerticalAlignment="Top"
Width="70" Height="50"
FontFamily="Segoe MDL2 Assets" FontSize="20"
Canvas.Left="200" Canvas.Top="42"/>
<Button
Content="&#xEA99;"
ToolTipService.ToolTip="Clear status messages for the selected devices"
Command="{Binding ClearDeviceStatusCommand}"
IsEnabled="{Binding HaveRegisteredDevices}"
HorizontalAlignment="Right" VerticalAlignment="Top"
Width="70" Height="50"
FontFamily="Segoe MDL2 Assets" FontSize="20"
Canvas.Left="10" Canvas.Top="105"/>
</Canvas>
</StackPanel>
</ScrollViewer>
Expand All @@ -258,7 +267,6 @@
FontFamily="Segoe MDL2 Assets"
Width="50" Height="40"
Canvas.Top="5"/>
<!-- TODO -->
<Button
Content="&#xE28F;"
ToolTipService.ToolTip="Save device session file"
Expand Down Expand Up @@ -320,7 +328,7 @@
Background="White">
<Button
x:Name="clearStatus"
Content="&#xE947;"
Content="&#xEA99;"
ToolTipService.ToolTip="Clear status message"
Command="{Binding Path=ClearStatusMessageCommand}"
FontFamily="Segoe MDL2 Assets"
Expand Down
24 changes: 8 additions & 16 deletions HoloLensCommander/HoloLensCommander/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,11 @@ public MainWindowViewModel(CoreDispatcher coreDispatcher)
/// </remarks>
public void Dispose()
{
this.ClearRegisteredDevices();
GC.SuppressFinalize(this);
}

/// <summary>
/// Bulk removes devices from application management.
/// </summary>
private void ClearRegisteredDevices()
{
List<DeviceMonitorControl> monitors = GetCopyOfRegisteredDevices();

foreach (DeviceMonitorControl monitor in monitors)
foreach (DeviceMonitorControl monitor in this.GetCopyOfRegisteredDevices())
{
monitor.Dispose();
}

monitors.Clear();

this.RegisteredDevices.Clear();
GC.SuppressFinalize(this);
}

/// <summary>
Expand Down Expand Up @@ -204,6 +190,12 @@ private void NotifyPropertyChanged(string propertyName)
/// </summary>
private void RegisterCommands()
{
this.ClearDeviceStatusCommand = new Command(
async (parameter) =>
{
await this.ClearDeviceStatus();
});

this.ClearStatusMessageCommand = new Command(
(parameter) =>
{
Expand Down
39 changes: 33 additions & 6 deletions HoloLensCommander/HoloLensCommander/MainWindowViewModelCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,30 @@ private enum ConnectContextMenuCommandIds
UseDefaultCredentials
}

/// <summary>
/// Command used to clear the delected devices status messages.
/// </summary>
public ICommand ClearDeviceStatusCommand
{ get; private set; }

/// <summary>
/// Implementation of the clear device status command.
/// </summary>
private async Task ClearDeviceStatus()
{
YesNoMessageDialog messageDialog = new YesNoMessageDialog(
"Are you sure you want to clear the status for the selected devices?");
if (MessageDialogButtonId.Yes != await messageDialog.ShowAsync())
{
return;
}

foreach (DeviceMonitorControl monitor in this.GetCopyOfRegisteredDevices())
{
monitor.ClearStatusMessage();
}
}

/// <summary>
/// Command used to clear the application status message.
/// </summary>
Expand Down Expand Up @@ -140,19 +164,19 @@ private void DeselectAllDevices()
}

/// <summary>
/// Command used to forget all of the registered devices.
/// Command used to forget registered devices.
/// </summary>
public ICommand ForgetConnectionsCommand
{ get; private set; }

/// <summary>
/// Implementation of the forget all connections command.
/// Implementation of the forget connections command.
/// </summary>
/// <returns>Task object used for tracking method completion.</returns>
private async Task ForgetAllConnectionsAsync()
{
YesNoMessageDialog messageDialog = new YesNoMessageDialog(
"Are you sure you want to remove all connected devices?");
"Are you sure you want to unregister the selected devices?");
if (MessageDialogButtonId.Yes != await messageDialog.ShowAsync())
{
return;
Expand All @@ -162,13 +186,16 @@ private async Task ForgetAllConnectionsAsync()

foreach (DeviceMonitorControl monitor in this.GetCopyOfRegisteredDevices())
{
monitor.Disconnect();
DeviceMonitorControlViewModel viewModel = (DeviceMonitorControlViewModel)monitor.DataContext;
if (viewModel.IsSelected)
{
monitor.Disconnect();
this.RegisteredDevices.Remove(monitor);
}
}

this.suppressSave = false;

this.ClearRegisteredDevices();

await this.SaveConnectionsAsync();

this.StatusMessage = string.Empty;
Expand Down

0 comments on commit cf3e50f

Please sign in to comment.