private async void CaptureCommandHandler(bool notify) { if (SelectedScreenInfo != null) { try { IsBusy = true; SelectedScreenInfo.CaptureProcess(ShowTaskBar); _lastOperateTokenSource?.Cancel(); _lastOperateTokenSource = new CancellationTokenSource(); ColorInfos = new List <ColorInfo>(); ColorInfos = (await SelectedScreenInfo.ScanAllUniqueColors(_lastOperateTokenSource.Token)).ToList(); } catch (OperationCanceledException canceledException) { Debug.WriteLine(canceledException); } finally { IsBusy = false; } } if (notify) { await RaisePropertyChanged(nameof(SelectedScreenInfo)); } ColorInfosChangedEvent?.Invoke(this, ColorInfos.ToList()); }
private async void OnSelectedBitmapInfoChanged() { if (SelectedScreenInfo != null) { _lastMatchBitmap?.Cancel(); _lastMatchBitmap = new CancellationTokenSource(); if (SelectedBitmapInfo != null) { using (var bitmap = SelectedScreenInfo.CopyBitmap()) { var rectangle = await SelectedBitmapInfo?.Match(bitmap, _lastMatchBitmap.Token); SelectedBitmapRectangle = rectangle; } } else { SelectedBitmapRectangle = null; } } }