/// <summary>
        /// Handles the PointerPressed event
        /// </summary>
        /// <param name="sender">FluidBanner</param>
        /// <param name="e">PointerRoutedEventArgs</param>
        private async void OnPointerPressed(object sender, PointerRoutedEventArgs e)
        {
            if ((ItemsSource == null) || (!ItemsSource.Any()) ||
                _isExpanding || _isCollapsing)
            {
                return;
            }

            var point = e.GetCurrentPoint(this).Position;

            if (_selectedVisual == null)
            {
                _selectedVisual = _fluidItems.Where(t => t.Value.Contains(point))
                                  .Select(t => t.Key)
                                  .FirstOrDefault();

                if (_selectedVisual != null)
                {
                    ResetHover(_hoverVisual);
                    _hoverVisual = null;
                    await SelectBannerItem();
                }
            }
            else
            {
                if (_bannerBounds.Contains(point))
                {
                    ResetBannerItems();
                }
            }
        }
示例#2
0
        internal void Select(TEntityAction entityAction)
        {
            // DATA IN:
            // action.CollectionAction.ModelCollection

            entityAction.ThrowNull();

            //Registrations.Clear ();
            ItemsSource.Clear();

            var gadgets = new Collection <TActionComponent> ();

            TActionConverter.Collection(TCategory.Registration, gadgets, entityAction);

            foreach (var model in gadgets)
            {
                ItemsSource.Add(model.Models.GadgetRegistrationModel);
            }

            //foreach (var gadget in action.CollectionAction.GadgetRegistrationCollection) {
            //  if (action.CollectionAction.ModelCollection.ContainsKey (gadget.Id)) {
            //    var modelAction = action.CollectionAction.ModelCollection [gadget.Id];
            //    modelAction.GadgetRegistrationModel.CopyFrom (gadget);

            //    action.ModelAction.CopyFrom (modelAction);

            //    var item = TComponentModelItem.Create (action);

            //    Registrations.Add (item);
            //    RegistrationItemsSource.Add (item);
            //  }
            //}

            SelectedIndex = ItemsSource.Any() ? 0 : -1;
        }
示例#3
0
 protected override void OnParametersSet()
 {
     if (ItemsSource.Any() && _selectedItem == null)
     {
         _selectedItem = ItemsSource.FirstOrDefault();
     }
 }
示例#4
0
        private void PositionMap()
        {
            if (ItemsSource == null || !ItemsSource.Any())
            {
                return;
            }

            var centerPosition = new Position(ItemsSource.Average(x => x.Latitude), ItemsSource.Average(x => x.Longitude));

            var minLongitude = ItemsSource.Min(x => x.Longitude);
            var minLatitude  = ItemsSource.Min(x => x.Latitude);

            var maxLongitude = ItemsSource.Max(x => x.Longitude);
            var maxLatitude  = ItemsSource.Max(x => x.Latitude);

            var distance = MapHelper.CalculateDistance(minLatitude, minLongitude,
                                                       maxLatitude, maxLongitude, 'M') / 2;

            AssociatedObject.MoveToRegion(MapSpan.FromCenterAndRadius(centerPosition, Distance.FromMiles(distance)));

            Device.StartTimer(TimeSpan.FromMilliseconds(500), () =>
            {
                AssociatedObject.MoveToRegion(MapSpan.FromCenterAndRadius(centerPosition, Distance.FromMiles(distance)));
                return(false);
            });
        }
        private void FolderBrowser_FoundMediaItem(object sender, MediaItemEventArgs e)
        {
            if (!ItemsSource.Any(m => m.Parts.Any(p => p.Location == e.MediaItem.Parts[0].Location)))
            {
                List <MediaItem> items = new List <MediaItem>(ItemsSource);
                items.Add(e.MediaItem);

                ItemsSource = new ObservableCollection <MediaItem>(items);
            }
        }
        /// <summary>
        /// Handles the PointerMoved event
        /// </summary>
        /// <param name="sender">FluidBanner</param>
        /// <param name="e">PointerRoutedEventArgs</param>
        private void OnPointerMoved(object sender, PointerRoutedEventArgs e)
        {
            if ((ItemsSource == null) || (!ItemsSource.Any()) ||
                _isExpanding || _isCollapsing || _selectedVisual != null)
            {
                return;
            }

            var point = e.GetCurrentPoint(this).Position;

            HandlePointerPosition(point);
        }
        private void SvScrollView_Scrolled(object sender, ScrolledEventArgs e)
        {
            double scrollingSpace = svScrollView.ContentSize.Height - svScrollView.Height - 20;

            if (scrollingSpace <= e.ScrollY && !IsRefreshing)
            {
                if (ItemsSource.Any())
                {
                    ItemAppearing?.Invoke(this, new ItemVisibilityEventArgs(ItemsSource[ItemsSource.Count - 1]));
                }
            }
        }
示例#8
0
        void Search()
        {
            if (!string.IsNullOrWhiteSpace(SearchQuery) && ItemsSource.Any())
            {
                var query = SearchQuery.Trim().ToLower();

                ItemsSource = new ObservableCollection <PublicationModel>(AllItemsSource.Where((arg) => arg.Title.ToLower().Trim().Contains(query)));
            }
            else
            {
                ItemsSource = AllItemsSource;
            }
        }
示例#9
0
        private void LoadItems()
        {
            Loading.ShowLoading(ListView);

            if (!ItemsSource.Any())
            {
                Loading.HideLoading(ListView);
                return;
            }

            var databaseUri = ItemsSource.First().DatabaseUri;

            var itemList = new StringBuilder();

            foreach (var itemUri in ItemsSource)
            {
                if (itemList.Length > 0)
                {
                    itemList.Append('|');
                }

                itemList.Append(itemUri.ItemId);
            }

            ExecuteCompleted completed = delegate(string response, ExecuteResult executeresult)
            {
                Debug.ArgumentNotNull(response, nameof(response));
                Debug.ArgumentNotNull(executeresult, nameof(executeresult));

                Loading.HideLoading(ListView);
                ListView.ItemsSource = null;

                if (!DataService.HandleExecute(response, executeresult))
                {
                    return;
                }

                var root = response.ToXElement();
                if (root == null)
                {
                    return;
                }

                ParseItems(root, databaseUri);

                RenderItems();
            };

            databaseUri.Site.DataService.ExecuteAsync("Items.GetDependencies", completed, databaseUri.DatabaseName.Name, itemList.ToString());
        }
示例#10
0
 private void EntryBoxPreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Down)
     {
         if (ItemsSource.Any() && !String.IsNullOrWhiteSpace(EntryBox.Text))
         {
             SuggestionPopup.IsOpen = true;
         }
     }
     else if (e.Key == Key.Escape)
     {
         SuggestionPopup.IsOpen = false;
     }
 }
示例#11
0
        private void OnNewCommand()
        {
            if (!CanNewCommand())
            {
                return;
            }

            if (!ItemsSource.Any(p => p.IsNewRow))
            {
                var item = new PmConfiguratorData(this);
                item.AcceptChanges(true);
                ItemsSource.Add(item);
            }
            OnNewRowAdded();
        }
示例#12
0
        private void InitView()
        {
            if (UserBorder)
            {
                segmentControlFrame.Margin       = new Thickness(20);
                segmentControlFrame.CornerRadius = 10;
            }
            else
            {
                segmentControlFrame.BackgroundColor = Color.Transparent;
                segmentControlFrame.BorderColor     = Color.Transparent;
                segmentControlFrame.CornerRadius    = 0;
                segmentControlFrame.HasShadow       = false;
            }

            segmentControlItems.Children.Clear();
            segmentControlItems.ColumnDefinitions.Clear();

            if (ItemsSource?.Any() != true)
            {
                return;
            }

            for (int i = 0; i < ItemsSource.Count; i++)
            {
                if (UseAutoSize)
                {
                    segmentControlItems.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = GridLength.Auto
                    });
                }
                else
                {
                    segmentControlItems.ColumnDefinitions.Add(new ColumnDefinition());
                }

                var item = ItemsSource[i];

                var view = GetView(item);

                Grid.SetColumn(view, i);

                segmentControlItems.Children.Add(view);
            }
        }
示例#13
0
        private void Init()
        {
            SegmentItems.Children.Clear();
            SegmentItems.RowDefinitions.Clear();
            SegmentItems.ColumnDefinitions.Clear();
            SegmentItems.ColumnSpacing = this.SectionSpacing;
            SegmentItems.RowSpacing    = this.SectionSpacing;

            if (ItemsSource?.Any() != true)
            {
                return;
            }

            for (int i = 0; i < ItemsSource.Count; i++)
            {
                var item = ItemsSource[i];

                // Check if selected
                item.IsSelected = item.IsSelected || (SelectedTag != null && SelectedTag?.ToString() == item.Tag?.ToString());

                var view = GetView(item, i);

                // If selected we display content
                if (item.IsSelected)
                {
                    this.MainContent = item.Content;
                }

                if (SectionOrientation == StackOrientation.Horizontal)
                {
                    SegmentItems.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = SectionHorizontalayout.Alignment == LayoutAlignment.Fill ? GridLength.Star : GridLength.Auto
                    });
                }
                else
                {
                    SegmentItems.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = GridLength.Auto
                    });
                }

                SegmentItems.Children.Add(view);
            }
        }
示例#14
0
        private bool ShouldAllBeSelected()
        {
            if (SubGroupSelector == null)
            {
                return(Selection.SelectedItems.Count() == ItemsSource.Count() && ItemsSource.Any());
            }
            else
            {
                //source is grouped... need to recursively select them all.
                var flattenedItems = ItemsSource?.SelectManyRecursive(x => SubGroupSelector(x));
                if (flattenedItems == null)
                {
                    return(false);
                }

                return(flattenedItems.Count() == Selection.SelectedItems.Count() && flattenedItems.Any());
            }
        }
示例#15
0
        /// <summary>
        /// Creates CompositionImages based on the URIs in ItemsSource
        /// </summary>
        private void CreateImages()
        {
            _images.Clear();
            var options = new CompositionImageOptions
            {
                DecodeWidth  = DecodeWidth,
                DecodeHeight = DecodeHeight
            };

            if ((ItemsSource == null) || !ItemsSource.Any())
            {
                return;
            }

            foreach (var uri in ItemsSource)
            {
                _images.Add(_imageFactory.CreateImageFromUri(uri, options));
            }
        }
示例#16
0
        private void EntryBoxTextChanged(object sender, TextChangedEventArgs e)
        {
            if (m_blockEntryBoxTextChanged)
            {
                return;
            }

            SelectedItem = null;

            EntryTextChanged?.Invoke(this, new RoutedEventArgs());

            if (!ItemsSource.Any() || String.IsNullOrWhiteSpace(EntryBox.Text))
            {
                SuggestionPopup.IsOpen = false;
            }
            else if (!m_blockPopup)
            {
                SuggestionPopup.IsOpen = true;
            }
        }
示例#17
0
        internal void Select(Collection <TActionComponent> gadgets)
        {
            gadgets.ThrowNull();

            ItemsSource.Clear();

            foreach (var component in gadgets)
            {
                if (component.IsCategory(TCategory.Test))
                {
                    ItemsSource.Add(component.Models.GadgetTestModel);
                }
            }

            if (ItemsSource.Any())
            {
                SelectedIndex = 0;
                Current.CopyFrom(ItemsSource [0]);
            }
        }
示例#18
0
        internal void Select(TEntityAction entityAction)
        {
            entityAction.ThrowNull();

            ItemsSource.Clear();

            var gadgets = new Collection <TActionComponent> ();

            TActionConverter.Collection(TCategory.Material, gadgets, entityAction);

            foreach (var model in gadgets)
            {
                ItemsSource.Add(model.Models.GadgetMaterialModel);
            }

            if (ItemsSource.Any())
            {
                SelectedIndex = 0;
            }
        }
示例#19
0
        private void PositionMap()
        {
            if (ItemsSource == null || !ItemsSource.Any())
            {
                return;
            }

            var centerPosition = new Position(ItemsSource.Average(x => x.Latitude), ItemsSource.Average(x => x.Longitude));

            var distance = 0.5;

            _map.MoveToRegion(MapSpan.FromCenterAndRadius(centerPosition, Distance.FromMiles(distance)));

            Device.StartTimer(TimeSpan.FromMilliseconds(500), () =>
            {
                _map.MoveToRegion(MapSpan.FromCenterAndRadius(centerPosition, Distance.FromMiles(distance)));

                return(false);
            });
        }
示例#20
0
    public void Select (TEntityAction action)
    {
      ItemsSource.Clear ();
      m_SelectionAllCollection.Clear ();

      if (action.NotNull ()) {
        foreach (var item in action.SupportAction.SelectionCollection) {
          if (item.Enabled) {
            var selectionItem = TSelectionItem.Create (item.Name, item.Tag, item.GetImage (), item.Enabled);

            ItemsSource.Add (selectionItem);

            m_SelectionAllCollection.Add (selectionItem);
          }
        }
      }

      if (ItemsSource.Any ()) {
        SelectedIndex = 0;
      }
    }
示例#21
0
        internal void RegistrationChanged(GadgetRegistration gadget)
        {
            if (gadget.NotNull())
            {
                ItemsSource.Clear();

                foreach (var item in GadgetResultDictionary)
                {
                    var gadgetResult = item.Value;

                    if (gadgetResult.IsRegistrationContent(gadget.Id))
                    {
                        ItemsSource.Add(gadgetResult);
                    }
                }

                if (ItemsSource.Any())
                {
                    ResultSelectedIndex = 0;
                }
            }
        }
示例#22
0
        void BuildInternalActions()
        {
            _actions.Clear();

            if (ItemsSource?.Any() == true)
            {
                IAction lastAction = null;
                foreach (var item in ItemsSource)
                {
                    IAction current = null;

                    // Inserts a blank action if a hole exists between two actions
                    if (lastAction != null && item.Start != lastAction.AssociatedItem.Finish)
                    {
                        _actions.Add(new BlankAction(this, lastAction.AssociatedItem.Finish, item.Start));
                    }

                    // Inserts the action with or without video
                    if (item.HasVideo)
                    {
                        current = new PlayVideoAction(this, item);
                    }
                    else
                    {
                        current = new BlankAction(this, item);
                    }

                    _actions.Add(current);

                    lastAction = current;
                }

                // Sets the last one as the last one
                _actions.Last().IsLast = true;
            }
        }
        /// <summary>
        /// Creates the SurfaceImages based on the ItemsSource
        /// </summary>
        /// <returns>Task</returns>
        private async Task CreateSurfaceImagesAsync()
        {
            if (_surfaceImagesCreated)
            {
                return;
            }

            var padding = Padding;

            // Clear previous visuals
            _surfaceVisuals.Clear();
            _fluidItems.Clear();
            _bgLayer.Children.RemoveAll();
            _topLayer.Children.RemoveAll();
            _selectedVisual = null;
            // Dispose the surface images
            for (var i = 0; i < _surfaceImages.Count; i++)
            {
                var surfaceImage = _surfaceImages.ElementAt(i);
                surfaceImage.Dispose();
            }
            _surfaceImages.Clear();

            if ((ItemsSource == null) || !ItemsSource.Any())
            {
                return;
            }

            var options = ImageSurfaceOptions.Default;

            options.SurfaceBackgroundColor = Colors.Transparent;

            var availableSize = new Size(_availableWidth, _availableHeight);

            for (var i = 0; i < ItemsSource.Count(); i++)
            {
                // Create the surface image
                var surfaceImage = await _generator.CreateImageSurfaceAsync(ItemsSource.ElementAt(i), availableSize, options);

                _surfaceImages.Add(surfaceImage);

                // Add a visual for the background
                var containerVisual = _compositor.CreateSpriteVisual();
                containerVisual.Size   = availableSize.ToVector2();
                containerVisual.Brush  = _compositor.CreateColorBrush(ItemBackground);
                containerVisual.Offset = new Vector3((float)padding.Left, (float)padding.Top, 0);

                // Create the visual for the content
                var contentVisual = _compositor.CreateSpriteVisual();
                contentVisual.Size = availableSize.ToVector2();
                var surfaceBrush = _compositor.CreateSurfaceBrush(surfaceImage.Surface);
                surfaceBrush.UpdateSurfaceBrushOptions(Stretch, AlignX, AlignY);
                contentVisual.Brush = surfaceBrush;

                // Calculate the Inset Clip
                var left  = i * (_itemWidth + ItemGap.Single());
                var right = _availableWidth - (left + _itemWidth);
                containerVisual.Properties.InsertScalar("LeftInset", left);
                containerVisual.Properties.InsertScalar("RightInset", right);
                containerVisual.Clip = _compositor.CreateInsetClip(left, 0, right, 0);

                // Center Point
                containerVisual.CenterPoint        = new Vector3(left + (_itemWidth / 2f), (float)padding.Top + (_itemHeight / 2f), 0);
                contentVisual.CenterPoint          = containerVisual.CenterPoint;
                containerVisual.ImplicitAnimations = _implicitAnimationCollection;
                contentVisual.ImplicitAnimations   = _implicitAnimationCollection;

                // Set the container content
                containerVisual.Children.InsertAtTop(contentVisual);

                // Add to Background Layer
                _bgLayer.Children.InsertAtTop(containerVisual);

                // Add Visual to the fluid items
                _fluidItems[containerVisual]  = new Rect(padding.Left + left, padding.Top, _itemWidth, _itemHeight);
                _surfaceVisuals[surfaceImage] = containerVisual;
            }
        }
        /// <summary>
        /// Handles the Arrange pass during Layout
        /// </summary>
        /// <param name="finalSize">Final Size of the control</param>
        /// <returns>Total size occupied by all the Children</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            if ((ItemsSource == null) || !ItemsSource.Any())
            {
                return(finalSize);
            }

            // Resize the rootContainer
            _rootContainer.Size = finalSize.ToVector2();

            var padding = Padding;

            var paddingSize = padding.CollapseThickness();
            var width       = finalSize.Width;
            var height      = finalSize.Height;

            _itemCount = ItemsSource.Count();

            _availableWidth  = (width - paddingSize.Width).Single();
            _availableHeight = (height - paddingSize.Height).Single();
            var gapCount              = _itemCount - 1;
            var totalGap              = (gapCount * ItemGap).Single();
            var availableNonGapWidth  = _availableWidth - totalGap;
            var availableNonGapHeight = _availableHeight;

            _itemWidth    = availableNonGapWidth / _itemCount;
            _itemHeight   = availableNonGapHeight;
            _bannerBounds = new Rect(padding.Left, padding.Top, _availableWidth, _availableHeight);

            // Update Visual sizes and surfaceImages
            var availableSize = new Vector2(_availableWidth, _availableHeight);

            _rootContainer.Size  = availableSize;
            _bgLayer.Size        = availableSize;
            _bgLayer.CenterPoint = new Vector3(_bgLayer.Size * 0.5f, 0);
            _topLayer.Size       = availableSize;

            // Check if any visual is currently selected. If yes then obtain its index.
            // The new visual at that index should be selected and added to the toplayer
            var selectedVisualIndex = -1;

            if (_selectedVisual != null)
            {
                foreach (var item in _fluidItems)
                {
                    selectedVisualIndex++;
                    if (ReferenceEquals(item.Key, _selectedVisual))
                    {
                        break;
                    }
                }
            }

            for (var index = 0; index < _surfaceImages.Count; index++)
            {
                // Get the surfaceImage
                var surfaceImage = _surfaceImages.ElementAt(index);

                // Get the visual corresponding to this surfaceImage
                var itemVisual = _surfaceVisuals[surfaceImage];

                if (itemVisual == null)
                {
                    continue;
                }

                itemVisual.Size        = availableSize;
                itemVisual.CenterPoint = new Vector3(itemVisual.Size * 0.5f, 0);
                var contentVisual = itemVisual.Children.ElementAt(0) as SpriteVisual;
                if (contentVisual == null)
                {
                    continue;
                }

                contentVisual.Size        = availableSize;
                contentVisual.CenterPoint = itemVisual.CenterPoint;
                (contentVisual.Brush as CompositionSurfaceBrush)?.UpdateSurfaceBrushOptions(Stretch, AlignX, AlignY);

                // Calculate the Inset Clip
                var left  = index * (_itemWidth + ItemGap.Single());
                var right = _availableWidth - (left + _itemWidth);
                itemVisual.Properties.InsertScalar("LeftInset", left);
                itemVisual.Properties.InsertScalar("RightInset", right);
                itemVisual.Clip = (index == selectedVisualIndex)
                    ? _compositor.CreateInsetClip(0, 0, 0, 0)
                    : _compositor.CreateInsetClip(left, 0, right, 0);

                // Center Point
                itemVisual.CenterPoint    = new Vector3(left + (_itemWidth / 2f), (float)padding.Top + (_itemHeight / 2f), 0);
                contentVisual.CenterPoint = itemVisual.CenterPoint;

                // Update Fluid Items
                _fluidItems[itemVisual] = new Rect(padding.Left + left, padding.Top, _itemWidth, _itemHeight);
            }

            // Update Animations' keyframes
            _expandRightInset.InsertKeyFrame(1f, _availableWidth - _itemWidth);
            _collapseInsetClip.InsertKeyFrame(1f, _availableWidth - _itemWidth);

            return(finalSize);
        }
示例#25
0
        /// <summary>
        /// Handles the Arrange pass during Layout
        /// </summary>
        /// <param name="finalSize">Final Size of the control</param>
        /// <returns>Total size occupied by all the Children</returns>
        protected override Size ArrangeOverride(Size finalSize)
        {
            if ((ItemsSource == null) || (!ItemsSource.Any()))
            {
                return(finalSize);
            }

            var padding     = Padding;
            var paddingSize = padding.CollapseThickness();
            var width       = finalSize.Width;
            var height      = finalSize.Height;
            var itemCount   = ItemsSource.Count();

            _availableWidth  = (width - paddingSize.Width).Single();
            _availableHeight = (height - paddingSize.Height).Single();
            var gapCount              = itemCount - 1;
            var totalGap              = (gapCount * ItemGap).Single();
            var availableNonGapWidth  = _availableWidth - totalGap;
            var availableNonGapHeight = _availableHeight;

            _itemWidth    = availableNonGapWidth / itemCount;
            _itemHeight   = availableNonGapHeight;
            _bannerBounds = new Rect(padding.Left, padding.Top, _availableWidth, _availableHeight);

            // Check if any visual is currently selected. If yes then obtain its index.
            // The new visual at that index should be selected and added to the toplayer
            var selectedVisualIndex = -1;

            if (_selectedVisual != null)
            {
                foreach (var item in _fluidItems)
                {
                    selectedVisualIndex++;
                    if (ReferenceEquals(item.Key, _selectedVisual))
                    {
                        break;
                    }
                }
            }

            // Clear previous visuals
            _fluidItems.Clear();
            _rootContainer.Children.RemoveAll();
            _rootContainer.Size = finalSize.ToVector2();

            // Background Layer
            _bgLayer      = _compositor.CreateLayerVisual();
            _bgLayer.Size = _rootContainer.Size;
            _rootContainer.Children.InsertAtBottom(_bgLayer);
            _bgLayer.CenterPoint = new Vector3(_bgLayer.Size * 0.5f, 0);

            // Top Layer
            _topLayer      = _compositor.CreateLayerVisual();
            _topLayer.Size = _rootContainer.Size;
            _rootContainer.Children.InsertAtTop(_topLayer);

            // Create Visuals
            for (var i = 0; i < itemCount; i++)
            {
                // Add a visual for the background
                var bgVisual = _compositor.CreateSpriteVisual();
                bgVisual.Size  = new Vector2(_availableWidth, _availableHeight);
                bgVisual.Brush = _compositor.CreateColorBrush(ItemBackground);

                // Create the visual for the content
                var contentVisual = _compositor.CreateSpriteVisual();
                contentVisual.Offset = Vector3.Zero;
                contentVisual.Size   = new Vector2(_availableWidth, _availableHeight);

                // Load image from the Uri
                contentVisual.Brush = _compositor.CreateSurfaceBrush(_images.ElementAt(i).Surface);

                // Create the container for the content
                var container = _compositor.CreateContainerVisual();
                container.Offset = new Vector3((float)padding.Left, (float)padding.Top, 0);
                container.Size   = new Vector2(_availableWidth, _availableHeight);

                // Calculate the Inset Clip
                var left  = i * (_itemWidth + ItemGap.Single());
                var right = _availableWidth - (left + _itemWidth);
                container.Properties.InsertScalar("LeftInset", left);
                container.Properties.InsertScalar("RightInset", right);
                // If the current value of 'i' same as the index of the previously selected visual
                // then the InsetClip value should be appropriately set
                container.Clip = (i == selectedVisualIndex) ?
                                 _compositor.CreateInsetClip(0, 0, 0, 0) : _compositor.CreateInsetClip(left, 0, right, 0);

                // Center Point
                container.CenterPoint            = new Vector3(left + (_itemWidth / 2f), (float)padding.Top + (_itemHeight / 2f), 0);
                contentVisual.CenterPoint        = container.CenterPoint;
                container.ImplicitAnimations     = _implicitAnimationCollection;
                contentVisual.ImplicitAnimations = _implicitAnimationCollection;

                // Set the container content
                container.Children.InsertAtTop(contentVisual);
                container.Children.InsertAtBottom(bgVisual);

                // Is the current value of 'i' same as the index of the previously selected visual
                if (i == selectedVisualIndex)
                {
                    // Add to the Top Layer
                    _topLayer.Children.InsertAtTop(container);
                    _selectedVisual = container;
                }
                else
                {
                    // Add to Background Layer
                    _bgLayer.Children.InsertAtTop(container);
                }

                // Add Visual to the fluid items
                _fluidItems[container] = new Rect(padding.Left + left, padding.Top, _itemWidth, _itemHeight);
            }

            // If there was a previously selected visual then Scale back
            // and fade the other visuals in the banner
            if (selectedVisualIndex > -1)
            {
                //
                foreach (var child in _bgLayer.Children)
                {
                    child.Scale   = new Vector3(ScaleDownFactor, ScaleDownFactor, 1);
                    child.Opacity = TargetOpacity;
                }
            }

            // Update Animations' keyframes
            _expandRightInset.InsertKeyFrame(1f, _availableWidth - _itemWidth);
            _collapseInsetClip.InsertKeyFrame(1f, _availableWidth - _itemWidth);

            // Add the rootContainer to the visual tree
            ElementCompositionPreview.SetElementChildVisual(this, _rootContainer);

            return(base.ArrangeOverride(finalSize));
        }
示例#26
0
 private void EvaluateIsEmpty()
 {
     IsEmpty = !ItemsSource?.Any() ?? true;
 }