public void SearchByCategories() { Global.GlobalDefinitions.wait(20); MagnifyingGlass.Click(); Global.GlobalDefinitions.wait(60); VideoAnimation.Click(); Global.GlobalDefinitions.wait(60); PromotionalVideos.Click(); Global.GlobalDefinitions.wait(60); for (var i = 1; i <= 10; i++) { var Textcode = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-search-section']/div[2]/div/section/div/div[2]/div/div[2]/div/div/div[" + i + "]/div[1]/a[2]/p")).Text; Console.WriteLine(Textcode); if (Textcode == "Animation") { Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-search-section']/div[2]/div/section/div/div[2]/div/div[2]/div/div/div[" + i + "]/div[1]/a[2]/p")).Click(); Console.WriteLine("Test Passed"); Base.test.Log(LogStatus.Info, "Successfully Searched By Categories"); return; } } }
private async void OnSourceChanged(IVideoAnimationSource newValue, IVideoAnimationSource oldValue) { var canvas = _canvas; if (canvas == null) { return; } if (newValue == null) { _source = null; Subscribe(false); return; } if (newValue?.Id == oldValue?.Id || newValue?.Id == _source?.Id) { return; } _source = newValue; var shouldPlay = _shouldPlay; var animation = await Task.Run(() => VideoAnimation.LoadFromFile(newValue, false, true)); if (animation == null || newValue?.Id != _source?.Id) { // The app can't access the file specified return; } if (_shouldPlay) { shouldPlay = true; } _animation = animation; _bitmap = null; if (AutoPlay || _shouldPlay) { _shouldPlay = false; Subscribe(true); } else if (!_unloaded) { Subscribe(false); if (_canvas.ReadyToDraw) { var buffer = ArrayPool<byte>.Shared.Rent(_animation.PixelWidth * _animation.PixelHeight * 4); _bitmap = CanvasBitmap.CreateFromBytes(_canvas, buffer, _animation.PixelWidth, _animation.PixelHeight, DirectXPixelFormat.R8G8B8A8UIntNormalized); ArrayPool<byte>.Shared.Return(buffer); } // Invalidate to render the first frame await Task.Run(Invalidate); _canvas?.Invalidate(); } }
private void OnCreateResources(CanvasControl sender, CanvasCreateResourcesEventArgs args) { args.TrackAsyncAction(Task.Run(() => { var animation = VideoAnimation.LoadFromFile(_source, false, true); if (animation == null) { return; } _animation = animation; lock (_reusableLock) { if (_reusableBuffer == null || _reusableBuffer.Length < _animation.PixelWidth * _animation.PixelHeight * 4) { _reusableBuffer = new byte[_animation.PixelWidth * _animation.PixelHeight * 4]; } } _bitmap = CanvasBitmap.CreateFromBytes(sender, _reusableBuffer, _animation.PixelWidth, _animation.PixelHeight, DirectXPixelFormat.R8G8B8A8UIntNormalized); _device = sender; // Invalidate to render the first frame if (!_subscribed) { Invalidate(); _canvas?.Invalidate(); } }).AsAsyncAction()); }
private void OnUnloaded(object sender, RoutedEventArgs e) { Subscribe(false); _canvas.CreateResources -= OnCreateResources; _canvas.Draw -= OnDraw; _canvas.Unloaded -= OnUnloaded; _canvas.RemoveFromVisualTree(); _canvas = null; Dispose(); //_animation?.Dispose(); _animation = null; //_bitmap?.Dispose(); _bitmap = null; }
private void OnCreateResources(CanvasControl sender, CanvasCreateResourcesEventArgs args) { args.TrackAsyncAction(Task.Run(() => { var animation = VideoAnimation.LoadFromFile(_source, false, true); if (animation == null) { return; } _animation = animation; var colors = new byte[_animation.PixelWidth * _animation.PixelHeight * 4]; _bitmap = CanvasBitmap.CreateFromBytes(sender, colors, _animation.PixelWidth, _animation.PixelHeight, Windows.Graphics.DirectX.DirectXPixelFormat.R8G8B8A8UIntNormalized); _device = sender; }).AsAsyncAction()); }
private void OnUnloaded(object sender, RoutedEventArgs e) { _shouldPlay = false; _unloaded = true; Subscribe(false); if (_canvas != null) { _canvas.Draw -= OnDraw; _canvas.RemoveFromVisualTree(); _canvas = null; } _source = null; //_bitmap?.Dispose(); _bitmap = null; //_animation?.Dispose(); _animation = null; }