internal void SelectDevice(IAndroidLogcatDevice device, bool notifyListeners = true) { if (m_SelectedDevice == device) return; if (device != null && device.State != IAndroidLogcatDevice.DeviceState.Connected) { AndroidLogcatInternalLog.Log("Trying to select device which is not connected: " + device.Id); if (m_SelectedDevice == null) return; m_SelectedDevice = null; } else { m_SelectedDevice = device; } if (m_SelectedDevice != null && !m_Devices.Keys.Contains(m_SelectedDevice.Id)) throw new Exception("Selected device is not among our listed devices"); m_Runtime.UserSettings.LastSelectedDeviceId = m_SelectedDevice != null ? m_SelectedDevice.Id : ""; if (notifyListeners) DeviceSelected?.Invoke(m_SelectedDevice); }
// Raises the DeviceSelected event internal void OnDeviceSelected(DeviceInformation device) { DeviceSelected?.Invoke(this, new DeviceSelectedEventArgs() { SelectedDevice = device }); }
protected void IntegrateQueryDevices(IAndroidLogcatTaskResult resut) { var deviceIdsResult = ((AndroidLogcatRetrieveDeviceIdsResult)resut); var deviceInfos = deviceIdsResult.deviceInfo; foreach (var d in m_Devices) { d.Value.UpdateState(IAndroidLogcatDevice.DeviceState.Disconnected); } foreach (var info in deviceInfos) { GetOrCreateDevice(info.id).UpdateState(info.state); } // If our selected device was removed, deselect it if (m_SelectedDevice != null && m_SelectedDevice.State != IAndroidLogcatDevice.DeviceState.Connected) { m_SelectedDevice = null; if (deviceIdsResult.notifyListeners) DeviceSelected?.Invoke(m_SelectedDevice); } if (m_SelectedDevice != null) { if (m_SelectedDevice != m_Devices[m_SelectedDevice.Id]) throw new Exception("The selected device is not among our list of devices"); } DevicesUpdated?.Invoke(); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { var device = _devices[indexPath.Row]; DeviceSelected?.Invoke(this, device); StopDiscovery(); }
/*-----------------------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------ПРОЦЕДУРЫ------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------------------------------*/ /// <summary> /// Добавление графического представление устройства на CvsWorkspace /// </summary> /// <param name="e">Параметры нажатия мышки</param> private void CvsWorkspace_AddDevice(MouseButtonEventArgs e) { //Возвращает в переменную созданный канвас CanvasDevice canvasDevice = CanvasDevice.CreateObject(LastId++, (DeviceType)CurrentDeviceSelected); //Присваение событий canvasDevice.CanvasObject.MouseLeftButtonDown += CanvasObject_LeftMouseDown; canvasDevice.CanvasObject.MouseDown += CanvasObject_MouseDown; canvasDevice.CanvasObject.MouseUp += CanvasObject_MouseUp; //Добавление на рабочую область CvsWorkspace.Children.Add(canvasDevice.CanvasObject); Canvas.SetLeft(canvasDevice.CanvasObject, e.GetPosition(CvsWorkspace).X - 25); Canvas.SetTop(canvasDevice.CanvasObject, e.GetPosition(CvsWorkspace).Y - 25); Canvas.SetZIndex(canvasDevice.CanvasObject, 1); //Добавление в логику программы CanvasDeviceList.Add(canvasDevice); SelectedCanvasObjectId = canvasDevice.DeviceObject.Id; //Возвращение настроек интерфейса LbObjects.SelectedIndex = -1; CurrentDeviceSelected = DeviceSelected.Nothing; this.Cursor = Cursors.Arrow; //Установка прозрачного фона для объекта канваса foreach (var CvsObjj in CanvasDeviceList) { if (CvsObjj.DeviceObject.Id != SelectedCanvasObjectId) { CvsObjj.CanvasObject.Background = (Brush)System.ComponentModel.TypeDescriptor.GetConverter(typeof(Brush)).ConvertFromInvariantString("Transparent"); } } }
/// <summary> /// Изменение ToolMode в зависимости от выбранного объекта в LbTools /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LbTools_SelectionChanged(object sender, SelectionChangedEventArgs e) { switch (LbTools.SelectedIndex) { case 0: { this.Cursor = Cursors.Arrow; CurrentMode = ToolMode.Cursor; LbObjects.IsEnabled = true; break; } case 3: { this.Cursor = Cursors.No; CurrentMode = ToolMode.Delete; LbObjects.IsEnabled = false; LbObjects.SelectedIndex = -1; CurrentDeviceSelected = DeviceSelected.Nothing; break; } } }
/// <summary> /// Save the playlist and display the dialogue /// </summary> /// <param name="manager"></param> public static void ShowFragment(FragmentManager manager, DeviceSelected callback, BindDialog bindCallback) { // Save the parameters so that they are available after a configuration change reporter = callback; binder = bindCallback; new SelectDeviceDialogFragment().Show(manager, "fragment_device_selection"); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { DeviceEventArgs args = new DeviceEventArgs(); args.Device = devices [indexPath.Row]; DeviceSelected?.Invoke(this, args); }
public double StartLocationX, StartLocationY; //Хранят начальные координаты передвижения объекта канваса /*-----------------------------------------------------------------------------------------------------------------------------*/ /*--------------------------------------------------------------СОБЫТИЯ--------------------------------------------------------*/ /*-----------------------------------------------------------------------------------------------------------------------------*/ /// <summary> /// Конструктор главного окна, срабатывает при запуске программы /// </summary> public MainWindow() { InitializeComponent(); //Инициализация логики окна LbTools.SelectedIndex = 0; CurrentMode = ToolMode.Cursor; CurrentDeviceSelected = DeviceSelected.Nothing; AddWireState = AddWire.StartPoint; }
/// <summary> /// Завершение добавления провода на канвас и в логику программы /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CvsWorkspace_AddWire_LastPoint(object sender, MouseEventArgs e) { foreach (var CvsObj in CanvasDeviceList) { if (CvsObj.CanvasObject.Equals(sender)) { foreach (var Port in CvsObj.DeviceObject.DataPorts) { if (Port.Device == null) { AddWireAccess = true; break; } } if (AddWireAccess) { foreach (var Port in CvsObj.DeviceObject.DataPorts) { if (Port.Device == null) { double PointX = Canvas.GetLeft((UIElement)sender) + 25; double PointY = Canvas.GetTop((UIElement)sender) + 25; Point EndPoint = new Point(PointX, PointY); LineGeometry lineGeometry = new LineGeometry(CashStartPoint, EndPoint); CashWire.Stroke = (Brush)System.ComponentModel.TypeDescriptor.GetConverter(typeof(Brush)).ConvertFromInvariantString("Black"); CashWire.StrokeThickness = 3; CashWire.Data = lineGeometry; CanvasWireList.Add(new CanvasWire(CashWire, (CanvasDevice)CashDeciceFisrt, CvsObj)); CanvasDevice CashDeciceFisrt1 = (CanvasDevice)CashDeciceFisrt; Port.Device = CashDeciceFisrt1; Port Port1 = (Port)CashPort; Port1.Device = CvsObj; this.Cursor = Cursors.Arrow; LbObjects.SelectedIndex = -1; CurrentDeviceSelected = DeviceSelected.Nothing; AddWireState = AddWire.StartPoint; AddWireAccess = false; break; } } } else { CvsWorkspace.Children.Remove(CashWire); AddWireState = AddWire.StartPoint; AddWireAccess = false; MessageBox.Show("Отсутствуют свободные порты!"); } } } }
/// <summary> /// Runs the scan activity. /// </summary> /// <returns>The result of the activity.</returns> public PluginExecutionResult RunScanActivity() { PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Automation Execution Failure", "Device workflow error."); try { var devices = ExecutionData.Assets.OfType <IDeviceInfo>(); var assetTokens = devices.Select(n => new AssetLockToken(n, ScanOptions.LockTimeouts)); //If there is no device to run if (assetTokens.Count() == 0) { //Skip When there are no device to execute on. return(new PluginExecutionResult(PluginResult.Skipped, "No Asset available to run.")); } RecordEvent(DeviceWorkflowMarker.DeviceLockBegin); ExecutionServices.CriticalSection.Run(assetTokens, selectedToken => { IDeviceInfo deviceInfo = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo; DeviceSelected?.Invoke(this, new StatusChangedEventArgs(deviceInfo.AssetId)); // Log the device and server used for this activity ScanLog.DeviceId = deviceInfo.AssetId; ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(ExecutionData, deviceInfo)); if (_serverName != null) { ExecutionServices.DataLogger.Submit(new ActivityExecutionServerUsageLog(ExecutionData, _serverName)); } using (IDevice device = CreateAutomationDevice(deviceInfo)) { var retryManager = new PluginRetryManager(ExecutionData, this.UpdateStatus); result = retryManager.Run(() => ExecuteScan(device, deviceInfo)); } } ); RecordEvent(DeviceWorkflowMarker.DeviceLockEnd); } catch (AcquireLockTimeoutException) { result = new PluginExecutionResult(PluginResult.Skipped, "Could not obtain lock on specified device(s).", "Device unavailable."); } catch (HoldLockTimeoutException) { result = new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {ScanOptions.LockTimeouts.HoldTimeout}.", "Automation timeout exceeded."); } LogDebug("Scan activity complete."); return(result); }
/// <summary> /// Изменение в CurrentDeviceSelected в зависимости от выбранного объекта в LbObjects /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LbObjects_SelectionChanged(object sender, SelectionChangedEventArgs e) { switch (LbObjects.SelectedIndex) { case -1: CurrentDeviceSelected = DeviceSelected.Nothing; break; case 0: CurrentDeviceSelected = DeviceSelected.Computer; break; case 1: CurrentDeviceSelected = DeviceSelected.Router; break; case 2: CurrentDeviceSelected = DeviceSelected.Switch; break; case 3: CurrentDeviceSelected = DeviceSelected.Wire; break; } }
/// <summary> /// Отменить добавление на канвас /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CvsWorkspace_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { if (!CurrentDeviceSelected.Equals(DeviceSelected.Nothing)) { LbObjects.SelectedIndex = -1; CurrentDeviceSelected = DeviceSelected.Nothing; this.Cursor = Cursors.Arrow; } if (AddWireState.Equals(AddWire.LastPoint)) { CvsWorkspace.Children.Remove(CashWire); AddWireState = AddWire.StartPoint; AddWireAccess = false; } foreach (var CvsObj in CanvasDeviceList) { CvsObj.CanvasObject.Background = (Brush)System.ComponentModel.TypeDescriptor.GetConverter(typeof(Brush)).ConvertFromInvariantString("Transparent"); } SelectedCanvasObjectId = -1; }
/// <summary> /// Called when [device selected]. /// </summary> /// <param name="deviceId">The device identifier.</param> protected void OnDeviceSelected(string deviceId) { DeviceSelected?.Invoke(this, new StatusChangedEventArgs(deviceId)); }
/// <summary> /// Runs the scan activity. /// </summary> /// <returns>The result of the activity.</returns> public PluginExecutionResult RunLinkPrintActivity() { PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Automation Execution Failure", "Device workflow error."); try { var devices = ExecutionData.Assets.OfType <IDeviceInfo>(); var assetTokens = devices.Select(n => new AssetLockToken(n, _lockTimeoutData)); RecordEvent(DeviceWorkflowMarker.DeviceLockBegin); ExecutionServices.CriticalSection.Run(assetTokens, selectedToken => { IDeviceInfo deviceInfo = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo; DeviceSelected?.Invoke(this, new StatusChangedEventArgs(deviceInfo.AssetId)); if (_linkPrintOptions != null) { AppNameSelected?.Invoke(this, new StatusChangedEventArgs(_linkPrintOptions.AppName)); } else { AppNameSelected?.Invoke(this, new StatusChangedEventArgs(LinkJobType)); } ConnectorLog.DeviceId = deviceInfo.AssetId; ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(ExecutionData, deviceInfo)); if (_serverName != null) { ExecutionServices.DataLogger.Submit(new ActivityExecutionServerUsageLog(ExecutionData, _serverName)); } using (IDevice device = CreateAutomationDevice(deviceInfo)) { var retryManager = new PluginRetryManager(ExecutionData, this.UpdateStatus); result = retryManager.Run(() => ExecuteLinkPrint(device, deviceInfo)); } } ); RecordEvent(DeviceWorkflowMarker.DeviceLockEnd); } catch (ArgumentException ex) { result = new PluginExecutionResult(PluginResult.Skipped, ex.Message, "Device automation error."); } catch (InvalidOperationException ex) { result = new PluginExecutionResult(PluginResult.Skipped, ex.Message, "Device automation error."); } catch (AcquireLockTimeoutException) { result = new PluginExecutionResult(PluginResult.Skipped, "Could not obtain lock on specified device(s).", "Device unavailable."); } catch (HoldLockTimeoutException) { result = new PluginExecutionResult(PluginResult.Error, $"Automation did not complete within {_lockTimeoutData.HoldTimeout}.", "Automation timeout exceeded."); } LogDebug($"Print activity complete. Result is {result.Result.ToString()}: {result.Message}"); return(result); }
private void InvokeDeviceSelected(VideoCaptureDeviceInfo device) { var args = new VideoDeviceSelectedEventArgs(device); DeviceSelected?.Invoke(this, args); }