/// <summary> /// Initializes a new instance of the <see cref="ManageAppsDialog" /> class. /// </summary> /// <param name="monitor">The DeviceMonitor that is responsible for communication with the device.</param> /// <param name="monitorControl">The DeviceMonitorControl that launched this dialog.</param> public ManageAppsDialog( DeviceMonitor monitor, DeviceMonitorControl monitorControl) { this.DataContext = new ManageAppsDialogViewModel( monitor, monitorControl); this.InitializeComponent(); }
/// <summary> /// Removes the specified device from monitoring. /// </summary> /// <param name="monitorControl">The DeviceMonitorControl tracking the device to be removed.</param> /// <returns>Task object used for tracking method completion.</returns> private async Task UnregisterDeviceAsync(DeviceMonitorControl monitorControl) { this.RegisteredDevices.Remove(monitorControl); if (this.RegisteredDevices.Count == 0) { this.HaveRegisteredDevices = false; } await this.SaveConnectionsAsync(); }
/// <summary> /// Handles the SelectedChanged event. /// </summary> /// <param name="sender">The object which sent this event.</param> private void DeviceMonitorControl_SelectedChanged(DeviceMonitorControl sender) { if (this.suppressRefreshCommonApps) { return; } // Assigning the return value of UnregisterDeviceAsync to a Task object to avoid // warning 4014 (call is not awaited). Task t = this.RefreshCommonAppsAsync(); }
/// <summary> /// Initializes a new instance of the <see cref="ManageAppsDialogViewModel" /> class. /// </summary> /// <param name="monitor">The DeviceMonitor responsible for communication with this device.</param> /// <param name="monitorControl">Instance of the control that launched this dialog.</param> public ManageAppsDialogViewModel( DeviceMonitor monitor, DeviceMonitorControl monitorControl) { this.deviceMonitor = monitor; this.deviceMonitorControl = monitorControl; this.deviceMonitor.AppInstallStatus += DeviceMonitor_AppInstallStatus; this.InstalledApps = new ObservableCollection <string>(); this.RunningApps = new ObservableCollection <string>(); this.RegisterCommands(); // Assigning the return value of the following methods to a Task object to avoid // warning 4014 (call is not awaited). Task t = this.RefreshInstalledAppsAsync(); t = this.RefreshRunningAppsAsync(); }
/// <summary> /// Initializes a new instance of the <see cref="DeviceMonitorControlViewModel" /> class. /// </summary> /// <param name="control">The DeviceMonitorControl to which this object is registered.</param> /// <param name="monitor">The DeviceMonitor responsible for communication with this device.</param> public DeviceMonitorControlViewModel( DeviceMonitorControl control, DeviceMonitor monitor) { this.deviceMonitorControl = control; this.RegisterCommands(); this.deviceMonitor = monitor; this.deviceMonitor.HeartbeatLost += Device_HeartbeatLost; this.deviceMonitor.HeartbeatReceived += Device_HeartbeatReceived; this.deviceMonitor.AppInstallStatus += DeviceMonitor_AppInstallStatus; this.SetFilter(); this.IsConnected = true; this.Address = deviceMonitor.Address; this.IsSelected = true; }
/// <summary> /// Registers the DeviceMonitor with the application. /// </summary> /// <param name="monitor">Device to register.</param> /// <param name="name">Descriptive name of the device.</param> /// <returns>Task object used for tracking method completion.</returns> private async Task RegisterDeviceAsync( DeviceMonitor monitor, string name) { DeviceMonitorControl deviceMonitorControl = new DeviceMonitorControl(monitor); deviceMonitorControl.AppInstalled += DeviceMonitorControl_AppInstalled; deviceMonitorControl.AppUninstalled += DeviceMonitorControl_AppUninstalled; deviceMonitorControl.DeviceDisconnected += DeviceMonitorControl_Disconnected; deviceMonitorControl.SelectedChanged += DeviceMonitorControl_SelectedChanged; deviceMonitorControl.TagChanged += DeviceMonitorControl_TagChanged; DeviceMonitorControlViewModel viewModel = deviceMonitorControl.DataContext as DeviceMonitorControlViewModel; viewModel.Name = name; // We want a sorted list of devices. List <DeviceMonitorControl> currentDevices = this.GetCopyOfRegisteredDevices(); currentDevices.Add(deviceMonitorControl); currentDevices.Sort(new DeviceMonitorControlComparer()); this.RegisteredDevices.Clear(); foreach (DeviceMonitorControl monitorControl in currentDevices) { this.RegisteredDevices.Add(monitorControl); } if (this.RegisteredDevices.Count > 0) { this.HaveRegisteredDevices = true; } currentDevices.Clear(); currentDevices = null; await this.SaveConnectionsAsync(); }
/// <summary> /// Registers the DeviceMonitor with the application. /// </summary> /// <param name="monitor">Device to register.</param> /// <param name="name">Descriptive name of the device.</param> /// <returns>Task object used for tracking method completion.</returns> private async Task RegisterDeviceAsync( DeviceMonitor monitor, string name) { DeviceMonitorControl deviceMonitorControl = new DeviceMonitorControl(monitor); deviceMonitorControl.AppInstalled += DeviceMonitorControl_AppInstalled; deviceMonitorControl.AppUninstalled += DeviceMonitorControl_AppUninstalled; deviceMonitorControl.DeviceDisconnected += DeviceMonitorControl_Disconnected; deviceMonitorControl.SelectedChanged += DeviceMonitorControl_SelectedChanged; deviceMonitorControl.TagChanged += DeviceMonitorControl_TagChanged; DeviceMonitorControlViewModel viewModel = deviceMonitorControl.DataContext as DeviceMonitorControlViewModel; viewModel.Name = name; this.RegisteredDevices.Add(deviceMonitorControl); if (this.RegisteredDevices.Count > 0) { this.HaveRegisteredDevices = true; } await this.SaveConnectionsAsync(); }
/// <summary> /// Handles the TagChanged event. /// </summary> /// <param name="sender">The object which sent this event.</param> private void DeviceMonitorControl_TagChanged(DeviceMonitorControl sender) { // Assigning the return value of SaveConnectionsAsync to a Task object to avoid // warning 4014 (call is not awaited). Task t = this.SaveConnectionsAsync(); }
/// <summary> /// Handles the Disconnected event. /// </summary> /// <param name="sender">The object which sent this event.</param> private void DeviceMonitorControl_Disconnected(DeviceMonitorControl sender) { // Assigning the return value of UnregisterDeviceAsync to a Task object to avoid // warning 4014 (call is not awaited). Task t = this.UnregisterDeviceAsync(sender); }
/// <summary> /// Handles the AppUninstalled event. /// </summary> /// <param name="sender">The object which sent this event.</param> private void DeviceMonitorControl_AppUninstalled(DeviceMonitorControl sender) { // Assigning the return value of RefreshCommonAppsAsync to a Task object to avoid // warning 4014 (call is not awaited). Task t = this.RefreshCommonAppsAsync(); }