add command exception handling, status message clear button
This commit is contained in:
Родитель
949abd14da
Коммит
fcb1043eb3
|
@ -700,13 +700,31 @@ namespace HoloLensCommander
|
|||
this.SetIpdCommand = new Command(
|
||||
async (parameter) =>
|
||||
{
|
||||
await this.SetIpdAsync();
|
||||
try
|
||||
{
|
||||
await this.SetIpdAsync();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to set IPD ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.SetTagCommand = new Command(
|
||||
async (parameter) =>
|
||||
{
|
||||
await this.TagDeviceAsync();
|
||||
try
|
||||
{
|
||||
await this.TagDeviceAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to set the device name ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.ShowContextMenuCommand = new Command(
|
||||
|
|
|
@ -118,19 +118,55 @@ namespace HoloLensCommander
|
|||
switch((MonitorContextMenuCommandIds)command.Id)
|
||||
{
|
||||
case MonitorContextMenuCommandIds.DeviceInfo:
|
||||
t = this.ShowDeviceInfoAsync();
|
||||
try
|
||||
{
|
||||
t = this.ShowDeviceInfoAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to display device information ({0})",
|
||||
e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case MonitorContextMenuCommandIds.ManageApps:
|
||||
t = this.ManageAppsAsync();
|
||||
try
|
||||
{
|
||||
t = this.ManageAppsAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to manage applications ({0})",
|
||||
e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case MonitorContextMenuCommandIds.MixedRealityView:
|
||||
t = this.MixedRealityViewAsync();
|
||||
try
|
||||
{
|
||||
t = this.MixedRealityViewAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to display Mixed Reality view ({0})",
|
||||
e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case MonitorContextMenuCommandIds.DevicePortal:
|
||||
t = this.LaunchDevicePortalAsync();
|
||||
try
|
||||
{
|
||||
t = this.LaunchDevicePortalAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to launch the Windows Device Portal ({0})",
|
||||
e.Message);
|
||||
}
|
||||
break;
|
||||
|
||||
case MonitorContextMenuCommandIds.Disconnect:
|
||||
|
|
|
@ -300,11 +300,20 @@
|
|||
Padding="0"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.HorizontalScrollMode="Auto"/>
|
||||
</ScrollViewer>
|
||||
<TextBlock Grid.Row="2" Grid.Column="1"
|
||||
x:Name="statusMessage"
|
||||
Text="{Binding Path=StatusMessage}"
|
||||
TextWrapping="NoWrap" FontSize="16"
|
||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||
Margin="5,0,0,5"/>
|
||||
<Canvas Grid.Row="2" Grid.Column="1"
|
||||
Background="White">
|
||||
<Button
|
||||
x:Name="clearStatus"
|
||||
Content="Clear"
|
||||
Command="{Binding Path=ClearStatusMessageCommand}"
|
||||
Width="60" Height="30"
|
||||
Canvas.Left="0" Canvas.Top="5"/>
|
||||
<TextBlock
|
||||
x:Name="statusMessage"
|
||||
Text="{Binding Path=StatusMessage}"
|
||||
TextWrapping="NoWrap" FontSize="16"
|
||||
HorizontalAlignment="Stretch"
|
||||
Canvas.Left="65" Canvas.Top="7"/>
|
||||
</Canvas>
|
||||
</Grid>
|
||||
</Page>
|
||||
|
|
|
@ -157,25 +157,48 @@ namespace HoloLensCommander
|
|||
/// </summary>
|
||||
private void RegisterCommands()
|
||||
{
|
||||
this.ClearStatusMessageCommand = new Command(
|
||||
(parameter) =>
|
||||
{
|
||||
this.StatusMessage = "";
|
||||
});
|
||||
|
||||
this.CloseAllAppsCommand = new Command(
|
||||
(parameter) =>
|
||||
{
|
||||
this.CloseAllApps();
|
||||
try
|
||||
{
|
||||
this.CloseAllApps();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to close all apps on one or more devices ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.ConnectToDeviceCommand = new Command(
|
||||
async (parameter) =>
|
||||
{
|
||||
|
||||
ConnectOptions connectOptions = new ConnectOptions(
|
||||
string.Empty,
|
||||
this.UserName,
|
||||
this.Password,
|
||||
false);
|
||||
|
||||
await this.ConnectToDeviceAsync(
|
||||
connectOptions,
|
||||
string.Empty);
|
||||
|
||||
try
|
||||
{
|
||||
await this.ConnectToDeviceAsync(
|
||||
connectOptions,
|
||||
string.Empty);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to connect to the device ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.DeselectAllDevicesCommand = new Command(
|
||||
|
@ -187,43 +210,106 @@ namespace HoloLensCommander
|
|||
this.ForgetConnectionsCommand = new Command(
|
||||
async (parameter) =>
|
||||
{
|
||||
await this.ForgetAllConnectionsAsync();
|
||||
try
|
||||
{
|
||||
await this.ForgetAllConnectionsAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to unregister devices {0}",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.InstallAppCommand = new Command(
|
||||
async (parameter) =>
|
||||
{
|
||||
await this.InstallAppAsync();
|
||||
try
|
||||
{
|
||||
await this.InstallAppAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to install the app on one or more devices ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.LaunchAppCommand = new Command(
|
||||
(parameter) =>
|
||||
{
|
||||
this.LaunchApp();
|
||||
});
|
||||
|
||||
this.RefreshCommonAppsCommand = new Command(
|
||||
async (parameter) =>
|
||||
{
|
||||
await this.RefreshCommonAppsAsync();
|
||||
try
|
||||
{
|
||||
this.LaunchApp();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to launch the app on one or more devices ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.RebootDevicesCommand = new Command(
|
||||
async (parameter) =>
|
||||
{
|
||||
await this.RebootDevicesAsync();
|
||||
try
|
||||
{
|
||||
await this.RebootDevicesAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to reboot one or more devices ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.ReconnectPreviousSessionCommand = new Command(
|
||||
(parameter) =>
|
||||
{
|
||||
this.ReconnectPreviousSession();
|
||||
try
|
||||
{
|
||||
this.ReconnectPreviousSession();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to reconnect previous device session ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.RefreshCommonAppsCommand = new Command(
|
||||
async (parameter) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
await this.RefreshCommonAppsAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to refresh common applications ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.SaveMixedRealityFilesCommand = new Command(
|
||||
async (parameter) =>
|
||||
{
|
||||
await this.SaveMixedRealityFiles();
|
||||
try
|
||||
{
|
||||
await this.SaveMixedRealityFiles();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to save Mixed Reality files from one or more devices ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.SelectAllDevicesCommand = new Command(
|
||||
|
@ -241,19 +327,46 @@ namespace HoloLensCommander
|
|||
this.ShutdownDevicesCommand = new Command(
|
||||
async (parameter) =>
|
||||
{
|
||||
await this.ShutdownDevicesAsync();
|
||||
try
|
||||
{
|
||||
await this.ShutdownDevicesAsync();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to shutdown one or more devices ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.StartMixedRealityRecordingCommand = new Command(
|
||||
(parameter) =>
|
||||
{
|
||||
this.StartMixedRealityRecording();
|
||||
try
|
||||
{
|
||||
this.StartMixedRealityRecording();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to start Mixed Reality recording on one or more devices ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.StopMixedRealityRecordingCommand = new Command(
|
||||
(parameter) =>
|
||||
{
|
||||
this.StopMixedRealityRecording();
|
||||
try
|
||||
{
|
||||
this.StopMixedRealityRecording();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to stop Mixed Reality recording on one or more devices ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.UninstallAppCommand = new Command(
|
||||
|
@ -265,7 +378,16 @@ namespace HoloLensCommander
|
|||
this.UninstallAllAppsCommand = new Command(
|
||||
(parameter) =>
|
||||
{
|
||||
this.UninstallAllApps();
|
||||
try
|
||||
{
|
||||
this.UninstallApp();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to uninstall an app on one or more devices ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
|
||||
this.UseAllDevicesFilterCommand = new Command(
|
||||
|
@ -289,7 +411,16 @@ namespace HoloLensCommander
|
|||
this.WipeCameraRollCommand = new Command(
|
||||
(parameter) =>
|
||||
{
|
||||
this.WipeCameraRoll();
|
||||
try
|
||||
{
|
||||
this.WipeCameraRoll();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this.StatusMessage = string.Format(
|
||||
"Failed to clear the camera roll on one or more devices ({0})",
|
||||
e.Message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,12 @@ namespace HoloLensCommander
|
|||
UseDefaultCredentials
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Command used to clear the application status message.
|
||||
/// </summary>
|
||||
public ICommand ClearStatusMessageCommand
|
||||
{ get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Command used to close all applications on the selected devices.
|
||||
/// </summary>
|
||||
|
|
Загрузка…
Ссылка в новой задаче