Exemple #1
0
        private Task AddProgressIndicatorAsync(string message, bool isLast = false)
        {
            var taskSource = new TaskCompletionSource <bool>();

            var indicator = new ProgressIndicator();

            indicator.Loaded    += OnProgressIndicatorLoaded;
            indicator.Text       = message;
            indicator.IsLast     = isLast;
            indicator.Visibility = Visibility.Collapsed;
            indicator.Margin     = new Thickness(40, 0, 40, 0);

            Implicit.SetAnimations(indicator, OffsetImplicitAnimations);
            Implicit.SetShowAnimations(indicator, IndicatorShowAnimations);

            CardsPanel.Children.Add(indicator);

            void OnProgressIndicatorLoaded(object sender, RoutedEventArgs e)
            {
                indicator.Loaded -= OnProgressIndicatorLoaded;

                indicator.Visibility = Visibility.Visible;
                taskSource.TrySetResult(true);
            }

            return(taskSource.Task);
        }
        private void OnContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args)
        {
            var containerVisual = VisualExtensions.GetVisual(args.ItemContainer);

            if (args.InRecycleQueue)
            {
                containerVisual.ImplicitAnimations = null;
            }
            else
            {
                Implicit.SetAnimations(args.ItemContainer, OffsetImplicitAnimations);
            }
        }
Exemple #3
0
        private Task RenderCardElementAsync(AdaptiveCardRenderer renderer, AdaptiveCardParseResult card)
        {
            var taskSource = new TaskCompletionSource <bool>();

            // Get the RenderedAdaptiveCard from the parse result.
            var renderResult = renderer.RenderAdaptiveCard(card.AdaptiveCard);

            renderResult.Action += OnRenderResultAction;

            // Add the AdaptiveCard UIElement to the Visual Tree.
            if (renderResult.FrameworkElement is FrameworkElement cardElement)
            {
                cardElement.Loaded    += OnCardElementLoaded;
                cardElement.Visibility = Visibility.Collapsed;
                cardElement.Margin     = new Thickness(12, 0, 12, 0);

                Implicit.SetAnimations(cardElement, OffsetImplicitAnimations);
                Implicit.SetShowAnimations(cardElement, CardElementShowAnimations);
                Implicit.SetHideAnimations(cardElement, CardElementHideAnimations);

                CardsPanel.Children.Add(cardElement);
            }

            void OnCardElementLoaded(object sender, RoutedEventArgs e)
            {
                cardElement.Loaded -= OnCardElementLoaded;

                cardElement.Visibility = Visibility.Visible;
            }

            async void OnRenderResultAction(RenderedAdaptiveCard sender, AdaptiveActionEventArgs args)
            {
                renderResult.Action -= OnRenderResultAction;

                if (args.Action.ActionType == ActionType.Submit)
                {
                    sender.FrameworkElement.Visibility = Visibility.Collapsed;
                    await Task.Delay(600);

                    taskSource.TrySetResult(true);
                }
            }

            return(taskSource.Task);
        }
        private void Load()
        {
            SampleController.Current.RegisterNewCommand("Toggle Visibility", (sender, args) =>
            {
                if (_element != null)
                {
                    _element.Visibility = _element.Visibility == Visibility.Collapsed ? Visibility.Visible : Visibility.Collapsed;
                }
            });

            SampleController.Current.RegisterNewCommand("Move Element", (sender, args) =>
            {
                if (_element != null)
                {
                    Canvas.SetTop(_element, _random.NextDouble() * this.ActualHeight);
                    Canvas.SetLeft(_element, _random.NextDouble() * this.ActualWidth);
                }
            });

            SampleController.Current.RegisterNewCommand("Scale Element", (sender, args) =>
            {
                if (_element != null)
                {
                    var visual   = ElementCompositionPreview.GetElementVisual(_element);
                    visual.Scale = new Vector3(
                        (float)_random.NextDouble() * 2,
                        (float)_random.NextDouble() * 2,
                        1);
                }
            });

            SampleController.Current.RegisterNewCommand("Toggle animations", (sender, args) =>
            {
                if (_element != null)
                {
                    Implicit.SetAnimations(_element, _areAnimationsToggled ? null : _animationSet);

                    _areAnimationsToggled = !_areAnimationsToggled;
                }
            });
        }
Exemple #5
0
 private void OnAdjusterListLoaded(object sender, RoutedEventArgs e) =>
 Implicit.SetAnimations(AdjusterList, OffsetImplicitAnimations);