public async Task UseMonitorAsDecoratedFaultTest() { TaskMonitorConfiguration.LogStatistics = true; TaskMonitorConfiguration.StatisticsHandler = TaskMonitorConfiguration.DefaultStatisticsTracer; var monitor = TaskMonitor.Create(DelayFaultAsync, name: "UseMonitorAsDecoratedFaultTest"); try { await Assert.ThrowsAsync <Exception>(() => monitor.Task); } finally { TaskMonitorConfiguration.LogStatistics = false; } }
public override void Load(object parameter) { if (parameter is ObservableCollection <SillyDudeVmo> observableDudes) { SillyPeople = new ObservableCollection <SillyDudeVmo>(observableDudes) { new AddSillyDudeVmo(OnSillyDudeAddedCommand), }; RaisePropertyChanged(nameof(SillyPeople)); return; } TaskMonitor.Create(NavigationService.NavigateBackAsync(typeof(SortSillyPeopleVm))); }
private void ViewOnLongClick(object sender, View.LongClickEventArgs longClickEventArgs) { var cmd = TapCommandEffect.GetLongTap(Element); if (cmd == null) { longClickEventArgs.Handled = false; return; } TaskMonitor.Create( async() => { await Task.Delay(50); cmd.Execute(TapCommandEffect.GetLongTapParameter(Element)); longClickEventArgs.Handled = true; }); }
private void SettingsButtonOnClicked(object sender, EventArgs e) { if (!_isSettingsShown) { BlurStyleRow.Height = _isAcrylicBlurEnabled ? SettingsRowHeight : 0; SettingsFrame.IsVisible = true; TaskMonitor.Create(SettingsFrame.FadeTo(1)); _isSettingsShown = true; return; } // Hide _isSettingsShown = false; TaskMonitor.Create(async() => { await SettingsFrame.FadeTo(0); SettingsFrame.IsVisible = false; }); }
private void AnimateCell(ViewCell cell) { TaskMonitor.Create( async() => { if (_element.PreRevealAnimationAsync != null) { await _element.PreRevealAnimationAsync(cell); } if (_element.RevealAnimationAsync != null) { await _element.RevealAnimationAsync(cell); } if (_element.PostRevealAnimationAsync != null) { await _element.PostRevealAnimationAsync(cell); } }); }
private void UpdateColor() { if (!_isAttached || Control == null || Element == null) { return; } var imageView = (UIImageView)Control; var effect = (TintableImageEffect)Element.Effects.FirstOrDefault(x => x is TintableImageEffect); var color = effect?.TintColor.ToUIColor(); if (color == null) { return; } if (effect.TintColor.IsDefault) { color = UIDevice.CurrentDevice.CheckSystemVersion(13, 0) ? UIColor.LabelColor : UIColor.Black; } Control.TintColor = color; if (imageView?.Image == null) { if (_tintAttempts < 5) { TaskMonitor.Create(() => DelayedPost(500, UpdateColor)); } return; } _tintAttempts = 0; imageView.Image = imageView.Image.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); }
public async Task NominalTest() { bool isCompleted = false; bool isSuccessfullyCompleted = false; bool isFaulted = false; string monitorName = "NominalTestTask"; var monitor = TaskMonitor.Create( DelayAsync, t => isCompleted = true, t => isFaulted = true, t => isSuccessfullyCompleted = true, name: monitorName); await monitor.TaskCompleted; Assert.True(isSuccessfullyCompleted && monitor.IsSuccessfullyCompleted); Assert.False(isFaulted || monitor.IsFaulted); Assert.False(monitor.IsCanceled); Assert.True(isCompleted && monitor.IsCompleted); Assert.Equal(monitorName, monitor.Name); }
private void UpdateColor() { if (!(Control is Image)) { return; } var effect = (TintableImageEffect)Element.Effects.FirstOrDefault(x => x is TintableImageEffect); var color = effect?.TintColor; if (color == null) { return; } if (Element.Source is FontImageSource fontImageSource) { fontImageSource.Color = color.Value; return; } TaskMonitor.Create(CreateTintEffectBrushAsync(color.Value)); }
private void TabButtonOnClicked(object sender, EventArgs e) { TaskMonitor.Create(AnimateTabButton); ((HomeView)HomeLazyView.Content).LogMaterialFrameContent(); }
public static void SetBlurStyle(MaterialFrame.MaterialFrame.BlurStyle blurStyle) { string wallpaper = string.Empty; switch (blurStyle) { case MaterialFrame.MaterialFrame.BlurStyle.Light: SetDarkColors(false); switch (Device.RuntimePlatform) { case Device.iOS: wallpaper = "catalina_dark.jpg"; break; case Device.Android: wallpaper = "bing_dark.jpg"; break; default: wallpaper = "bliss_portrait.jpg"; break; } break; case MaterialFrame.MaterialFrame.BlurStyle.Dark: SetDarkColors(true); switch (Device.RuntimePlatform) { case Device.iOS: wallpaper = "catalina_light.jpg"; break; case Device.Android: wallpaper = "milky_light.jpg"; break; default: wallpaper = "windows7_portrait.png"; break; } break; case MaterialFrame.MaterialFrame.BlurStyle.ExtraLight: SetLightColors(true); switch (Device.RuntimePlatform) { case Device.iOS: wallpaper = "undersea_light.jpg"; break; case Device.Android: wallpaper = "bing_light.jpg"; break; default: wallpaper = "vista_portrait_2.jpg"; break; } break; } TaskMonitor.Create( async() => { SetDynamicResource(DynamicBackgroundImageSource, new FileImageSource { File = wallpaper }); // give some time to the big picture to load await Task.Delay(100); SetDynamicResource(DynamicBlurStyle, blurStyle); }); }
protected override void OnAppearing() { base.OnAppearing(); TaskMonitor.Create(DelayExecute); }
private void CatOnTapped(object sender, EventArgs e) { if (ShouldRepeat) { _audioPlayer.Stop(); return; } TaskMonitor.Create( async() => { _audioPlayer?.Play(); await NyanBackground.AnimateTo(0, 1, "BackgroundFadeIn", (ve, v) => ve.Opacity = v); var parentAnimation = new Animation(); foreach (var shade in CatShadows.Shades) { var offsetFirstAnimation = new Animation( v => shade.Offset = new Point(v, shade.Offset.Y), shade.Offset.X, -shade.Offset.X); parentAnimation.Add(0, 0.25, offsetFirstAnimation); var offsetSecondAnimation = new Animation( v => shade.Offset = new Point(shade.Offset.X, v), shade.Offset.Y, -shade.Offset.Y); parentAnimation.Add(0.25, 0.5, offsetSecondAnimation); var offsetThirdAnimation = new Animation( v => shade.Offset = new Point(v, shade.Offset.Y), -shade.Offset.X, shade.Offset.X); parentAnimation.Add(0.5, 0.75, offsetThirdAnimation); var offsetFourthAnimation = new Animation( v => shade.Offset = new Point(shade.Offset.X, v), -shade.Offset.Y, shade.Offset.Y); parentAnimation.Add(0.75, 1, offsetFourthAnimation); } parentAnimation.Commit( CatShadows, "CatShadowsAnimation", length: 1000, repeat: () => ShouldRepeat, finished: (value, end) => { if (!ShouldRepeat) { TaskMonitor.Create( NyanBackground.AnimateTo( 1, 0, "BackgroundFadeIn", (ve, v) => ve.Opacity = v)); } }); }); }
private void CommandsOnClicked(object sender, EventArgs e) { TaskMonitor.Create(_navigationService.NavigateToViewAsync <CommandsPage>(GamePlatform.Computer)); }
private void ButtonCustomLayoutOnClicked(object sender, EventArgs e) { TaskMonitor.Create(_navigationService.NavigateToViewAsync <UserViewsPage>(GamePlatform.Computer)); }
private void ButtonDefaultLayoutOnClicked(object sender, EventArgs e) { // TaskMonitor.Create(_navigationService.NavigateToViewAsync<DefaultIsBusyViewsPage>(GamePlatform.Console)); TaskMonitor.Create(_navigationService.NavigateToViewAsync <DefaultViewsPage>(GamePlatform.Console)); }
private void OnClickedExpander() { if (_initialHeight == 0) { _initialHeight = Container.Height - 15; _expandedHeight = _initialHeight * 2; } bool isExpanded = ButtonExpand.Rotation == 180; var from = isExpanded ? _expandedHeight : _initialHeight; var to = isExpanded ? _initialHeight : _expandedHeight; Easing easing = Easing.SpringOut; uint length = 500; switch (_counter) { case 0: easing = new Easing(t => 9 * t * t * t - 13.5 * t * t + 5.5 * t); EasingLabel.Text = "Hula Hoop Easing"; break; case 1: easing = new Easing(t => 1 - Math.Cos(10 * Math.PI * t) * Math.Exp(-5 * t)); EasingLabel.Text = "Shaking Easing"; break; case 2: easing = Easing.SpringOut; EasingLabel.Text = "Spring Out Easing"; break; case 3: easing = Easing.SpringIn; EasingLabel.Text = "Spring In Easing"; break; } TaskMonitor.Create( async() => { var easingLabelTask = EasingLabel.RotateTo(isExpanded ? 0 : 360, length, easing); var rotateTask = ButtonExpand.RotateTo(isExpanded ? 0 : 180, length, easing); var heightAnimation = Container.DoubleTo( from, to, h => Container.HeightRequest = h, length, easing); await Task.WhenAll(rotateTask, heightAnimation, easingLabelTask); if (isExpanded) { EasingLabel.Text = "Show more details"; } ButtonExpand.Rotation = isExpanded ? 0 : 180; EasingLabel.Rotation = isExpanded ? 0 : 360; }); }
private void TabButtonOnClicked(object sender, EventArgs e) { TaskMonitor.Create(AnimateTabButton); }
private void ButtonLottieLayoutOnClicked(object sender, EventArgs e) { TaskMonitor.Create(_navigationService.NavigateToViewAsync <LottieViewsPage>(GamePlatform.Console)); }
public void Build() { TaskMonitor.Create(BuildViewsAsync); }
private void SkeletonLoadingOnClicked(object sender, EventArgs e) { TaskMonitor.Create(_navigationService.NavigateToViewAsync <DefaultViewsSkeletonPage>(GamePlatform.Computer)); }
protected override void OnInitialized() { InitializeComponent(); TaskMonitor.Create(NavigationService.NavigateAsync($"/{nameof(MainPage)}")); }
private void InitCommands() { OnDragAndDropEndCommand = new Command( () => System.Diagnostics.Debug.WriteLine("SortSillyPeopleVm: OnDragAndDropEndCommand")); OnSillyDudeAddedCommand = new Command(() => TaskMonitor.Create(AddSillyDudeAsync)); }
private void TapAction() { TaskMonitor.Create(TapAnimationAsync(0.3, _alpha, 0)); }