コード例 #1
0
        private void ImageGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var item      = e.ClickedItem;
            var container = ImageGridView.ContainerFromItem(item) as FrameworkElement;
            var rootGrid  = (container as GridViewItem).ContentTemplateRoot as Grid;

            Canvas.SetZIndex(container, ++_zindex);

            _containerVisual = ElementCompositionPreview.GetElementVisual(container);

            var unsplashImg = item as UnsplashImageBase;

            var maskBorder = rootGrid.Children[2] as FrameworkElement;
            var img        = rootGrid.Children[1] as FrameworkElement;

            ToggleItemPointAnimation(maskBorder, img, false);

            OnClickItemStarted?.Invoke(unsplashImg, container);
        }
コード例 #2
0
        private async Task TapItemAsync(ImageItem image)
        {
            if (!(await CheckListImageDownloadedAsync(image)))
            {
                return;
            }

            _tappedContainer = ImageGridView.ContainerFromItem(image) as GridViewItem;

            var rootGrid = _tappedContainer.ContentTemplateRoot as Grid;

            _tappedContainerVisual = ElementCompositionPreview.GetElementVisual(_tappedContainer);

            var maskBorder = rootGrid.Children[2] as FrameworkElement;
            var img        = rootGrid.Children[1] as FrameworkElement;

            ToggleItemPointOverAnimation(maskBorder, img, false);

            OnClickItemStarted?.Invoke(image, rootGrid);
        }
コード例 #3
0
        private void TapItem(UnsplashImageBase image)
        {
            if (string.IsNullOrEmpty(image.ListImageBitmap.LocalPath))
            {
                return;
            }

            var container = ImageGridView.ContainerFromItem(image) as FrameworkElement;
            var rootGrid  = (container as GridViewItem).ContentTemplateRoot as Grid;

            Canvas.SetZIndex(container, ++_zindex);

            _containerVisual = ElementCompositionPreview.GetElementVisual(container);

            var maskBorder = rootGrid.Children[2] as FrameworkElement;
            var img        = rootGrid.Children[1] as FrameworkElement;

            ToggleItemPointAnimation(maskBorder, img, false);

            OnClickItemStarted?.Invoke(image, container);
        }
コード例 #4
0
        public GalleryGridViewControl()
        {
            InitializeComponent();
            _isLoaded = false;

            #region 模糊特效

            // Get the current compositor
            _compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
            // Create the destinatio sprite, sized to cover the entire list
            _destinationSprite      = _compositor.CreateSpriteVisual();
            _destinationSprite.Size = new Vector2((float)GalleryGridView.ActualWidth,
                                                  (float)GalleryGridView.ActualHeight);
            // Start out with the destination layer invisible to avoid any cost until necessary
            _destinationSprite.IsVisible = false;
            ElementCompositionPreview.SetElementChildVisual(GalleryGridView, _destinationSprite);
            if (_compositor != null)
            {
                IGraphicsEffect graphicsEffect = new GaussianBlurEffect
                {
                    BlurAmount   = 20,
                    Source       = new CompositionEffectSourceParameter("ImageSource"),
                    Optimization = EffectOptimization.Balanced,
                    BorderMode   = EffectBorderMode.Hard
                };

                // Create the effect factory and instantiate a brush
                var effectFactory = _compositor.CreateEffectFactory(graphicsEffect, null);
                var brush         = effectFactory.CreateBrush();

                // Set the destination brush as the source of the image content
                brush.SetSourceParameter("ImageSource", _compositor.CreateBackdropBrush());

                // Update the destination layer with the fully configured brush
                _destinationSprite.Brush = brush;
            }

            #endregion

            GalleryGridView.ItemClick += (sender, e) =>
            {
                var thumbnail = (ImageModel)e.ClickedItem;

                // If we're in the middle of an animation, cancel it now
                if (_scopeBatch != null)
                {
                    CleanupScopeBatch();
                }

                // We're starting our transition, show the destination sprite
                _destinationSprite.IsVisible = true;

                // Animate from transparent to fully opaque
                var showAnimation = _compositor.CreateScalarKeyFrameAnimation();
                showAnimation.InsertKeyFrame(0f, 0f);
                showAnimation.InsertKeyFrame(1f, 1f);
                showAnimation.Duration = TimeSpan.FromMilliseconds(1500);
                _destinationSprite.StartAnimation("Opacity", showAnimation);

                OnClickItemStarted?.Invoke(thumbnail);
            };
            GalleryGridView.SizeChanged += (sender, e) =>
            {
                if (_destinationSprite != null)
                {
                    _destinationSprite.Size = e.NewSize.ToVector2();
                }
            };
            AddSourcesButton.Click += (sender, args) =>
            {
                var rootFrame = Window.Current.Content as Frame;
                rootFrame?.Navigate(typeof(SettingPage));
                Window.Current.Content = rootFrame;
            };
        }