public OnControlScrollChangedListener(
     AndroidHorizontalListViewRenderer nativeView,
     HorizontalListView element)
 {
     _weakNativeView = new WeakReference <AndroidHorizontalListViewRenderer>(nativeView);
     _element        = element;
 }
 public ResponsiveGridLayoutManager(Context context, HorizontalListView element)
     : base(context, 1)
 {
     _context          = context;
     _weakElement      = new WeakReference <HorizontalListView>(element);
     _spanNeedsCompute = true;
 }
Exemplo n.º 3
0
            public RecycleViewAdapter(HorizontalListView element, RecyclerView parentView, Context context)
            {
                _element        = element;
                _weakParentView = new WeakReference <RecyclerView>(parentView);
                _context        = context;

                _elementItemsSource = element.ItemsSource;

                _dataSource = _elementItemsSource?.Cast <object>().ToList() ?? new List <object>();

                _formsViews = new List <WeakReference <ViewCell> >();

                if (!(_element.ItemTemplate is DataTemplateSelector))
                {
                    // Cache only support single DataTemplate
                    _viewHolderQueue = new ViewHolderQueue(element.ViewCacheSize, () => CreateViewHolder());
                    _viewHolderQueue.Build();
                }

                _notifyCollectionChanged = _elementItemsSource as INotifyCollectionChanged;
                if (_notifyCollectionChanged != null)
                {
                    _notifyCollectionChanged.CollectionChanged += OnCollectionChanged;
                }
            }
        public static int ComputeSpan(int availableWidth, HorizontalListView element)
        {
            int itemSpace    = PlatformHelper.Instance.DpToPixels(element.ItemSpacing);
            int leftPadding  = PlatformHelper.Instance.DpToPixels(element.CollectionPadding.Left);
            int rightPadding = PlatformHelper.Instance.DpToPixels(element.CollectionPadding.Right);

            int itemWidth = PlatformHelper.Instance.DpToPixels(element.ItemWidth);

            int columnCount = 0;

            while (true)
            {
                columnCount++;
                int interPadding = itemSpace * (columnCount - 1);
                int totalWidth   = itemWidth * columnCount + interPadding + leftPadding + rightPadding;

                if (totalWidth > availableWidth)
                {
                    break;
                }
            }

            if (--columnCount == 0)
            {
                InternalLogger.Error(
                    "The CollectionPadding, ItemSpacing and ItemWidth specified doesn't allow a single column to be displayed");
                return(1);
            }

            return(columnCount);
        }
Exemplo n.º 5
0
        public iOSViewSource(HorizontalListView element, HashSet <DataTemplate> dataTemplates)
        {
            _weakElement   = new WeakReference <HorizontalListView>(element);
            _createdCells  = new Dictionary <long, WeakReference <iOSViewCell> >();
            _dataTemplates = dataTemplates;

            var elementItemsSource = element.ItemsSource;

            _dataSource = elementItemsSource?.Cast <object>().ToList();

            if (_dataSource == null)
            {
                return;
            }

            _multipleCellTemplates = _dataTemplates?.Any() ?? false;

            if (!_multipleCellTemplates)
            {
                // Cache only support single DataTemplate
                _viewCellHolderCellHolderQueue = new UIViewCellHolderQueue(
                    element.ViewCacheSize,
                    () => CreateViewCellHolder());
                _viewCellHolderCellHolderQueue.Build();
            }
        }
        public iOSViewSource(HorizontalListView element)
        {
            _element = element;

            var elementItemsSource = _element.ItemsSource;

            _dataSource = elementItemsSource?.Cast <object>().ToList();

            if (_dataSource == null)
            {
                return;
            }

            _viewCellHolderCellHolderQueue = new UIViewCellHolderQueue(element.ViewCacheSize, CreateViewCellHolder);
            _viewCellHolderCellHolderQueue.Build();
        }
            public RecycleViewAdapter(HorizontalListView element, Context context)
            {
                _element = element;
                _context = context;

                _elementItemsSource = element.ItemsSource;

                _dataSource = _elementItemsSource?.Cast <object>().ToList() ?? new List <object>();

                _formsViews      = new List <WeakReference <ViewCell> >();
                _viewHolderQueue = new ViewHolderQueue(element.ViewCacheSize, CreateViewHolder);
                _viewHolderQueue.Build();

                _notifyCollectionChanged = _elementItemsSource as INotifyCollectionChanged;
                if (_notifyCollectionChanged != null)
                {
                    _notifyCollectionChanged.CollectionChanged += OnCollectionChanged;
                }
            }
        private void ListLayoutChanging(object sender, CollectionLayoutChangedEventArgs e)
        {
            ColumnCountContainer.IsVisible = e.ListLayout == CollectionViewLayout.Grid;

            switch (e.ListLayout)
            {
            case CollectionViewLayout.Horizontal:
                HorizontalListView.BatchBegin();
                HorizontalListView.ItemWidth   = 260;
                HorizontalListView.ItemHeight  = 260;
                HorizontalListView.ColumnCount = 0;
                HorizontalListView.BatchCommit();
                HorizontalListView.DragAndDropDirection = DragAndDropDirection.HorizontalOnly;
                HorizontalListView.Margin = Device.RuntimePlatform == Device.Android
                        ? new Thickness(0, 60, 0, 0)
                        : new Thickness(0, -60, 0, 0);

                break;

            case CollectionViewLayout.Grid:
                HorizontalListView.BatchBegin();
                HorizontalListView.ItemWidth  = 120;
                HorizontalListView.ItemHeight = 120;
                HorizontalListView.BatchCommit();
                HorizontalListView.Margin = new Thickness(0);
                HorizontalListView.DragAndDropDirection = DragAndDropDirection.Free;

                HorizontalListView.ColumnCount = ColumnPicker.SelectedIndex == 0 ? -1 : ColumnPicker.SelectedIndex;
                break;

            case CollectionViewLayout.Vertical:
                HorizontalListView.BatchBegin();
                HorizontalListView.ItemWidth  = 0;
                HorizontalListView.ItemHeight = 120;
                HorizontalListView.BatchCommit();
                HorizontalListView.Margin = new Thickness(0);
                HorizontalListView.DragAndDropDirection = DragAndDropDirection.VerticalOnly;
                break;
            }
        }
        public iOSViewSource(HorizontalListView element)
        {
            _weakElement = new WeakReference <HorizontalListView>(element);

            var elementItemsSource = element.ItemsSource;

            _dataSource = elementItemsSource?.Cast <object>().ToList();

            if (_dataSource == null)
            {
                return;
            }

            if (!(element.ItemTemplate is DataTemplateSelector))
            {
                // Cache only support single DataTemplate
                _viewCellHolderCellHolderQueue = new UIViewCellHolderQueue(
                    element.ViewCacheSize,
                    () => CreateViewCellHolder());
                _viewCellHolderCellHolderQueue.Build();
            }
        }
            public void UpdateUi(ViewCell viewCell, object dataContext, HorizontalListView view)
            {
                viewCell.BindingContext = dataContext;
                viewCell.Parent         = view;

                var height = (int)((view.ItemHeight + viewCell.View.Margin.Top + viewCell.View.Margin.Bottom));
                var width  = (int)((view.ItemWidth + viewCell.View.Margin.Left + viewCell.View.Margin.Right));

                viewCell.View.Layout(new Rectangle(0, 0, width, height));

                if (Platform.GetRenderer(viewCell.View) == null)
                {
                    Platform.SetRenderer(viewCell.View, Platform.CreateRenderer(viewCell.View));
                }
                var renderer = Platform.GetRenderer(viewCell.View).NativeView;

                foreach (UIView subView in ContentView.Subviews)
                {
                    subView.RemoveFromSuperview();
                }
                renderer.ContentMode = UIViewContentMode.ScaleAspectFit;
                ContentView.AddSubview(renderer);
            }
Exemplo n.º 11
0
 public void Bind(object context, HorizontalListView parent)
 {
     _viewCell.BindingContext = context;
     _viewCell.Parent         = parent;
 }
Exemplo n.º 12
0
 public void Bind(object dataContext, HorizontalListView parent)
 {
     FormsCell.BindingContext = dataContext;
     FormsCell.Parent         = parent;
 }
Exemplo n.º 13
0
        private void UpdatePlayerHand()
        {
            List <WhiteCard> playerHand;

            // Get the correct set of cards to display to the user
            if (CardsAgainstHumility.GameStarted)
            {
                if (CardsAgainstHumility.IsCardCzar)
                {
                    playerHand = (CardsAgainstHumility.ReadyToSelectWinner ? CardsAgainstHumility.PlayedCards : new List <WhiteCard>());
                }
                else
                {
                    playerHand = (CardsAgainstHumility.ReadyToSelectWinner ? CardsAgainstHumility.PlayedCards : CardsAgainstHumility.PlayerHand);
                }
            }
            else
            {
                playerHand = CardsAgainstHumility.PlayerHand;
            }

            if (_playerHandArrayAdapter == null)
            {
                _playerHandArrayAdapter      = new WhiteCardArrayAdapter(this, SelectCard, playerHand);
                PlayerHandView               = FindViewById <HorizontalListView>(Resource.Id.gv_PlayerHand);
                PlayerHandView.Adapter       = _playerHandArrayAdapter;
                PlayerHandView.ItemSelected += (sender, args) =>
                {
                    if ((args.Position >= 0) && (args.Position < CardsAgainstHumility.PlayerHand.Count))
                    {
                        SelectCard(playerHand[args.Position], args.View);
                    }
                };
            }
            else
            {
                bool completelyReplaced = _playerHandArrayAdapter.NewData(playerHand);
                if (completelyReplaced)
                {
                    PlayerHandView.ScrollTo(0);
                }

                if (_selectedCard != null && !playerHand.Select(c => c.Id).Contains(_selectedCard.Id))
                {
                    _selectedCard    = null;
                    SelectedCardView = null;
                }
                if ((!CardsAgainstHumility.IsCardCzar) && (CardsAgainstHumility.SelectedCard != null))
                {
                    PlayerHandView.Enabled = false;
                }
            }

            if (CardsAgainstHumility.GameStarted && !CardsAgainstHumility.GameOver)
            {
                if (CardsAgainstHumility.IsCardCzar)
                {
                    // If the player is card czar, only show the "hand" while they are supposed to be choosing a winner
                    if (CardsAgainstHumility.ReadyToSelectWinner && CardsAgainstHumility.WinningCard == null)
                    {
                        PlayerHandView.Visibility = ViewStates.Visible;
                    }
                    else
                    {
                        PlayerHandView.Visibility = ViewStates.Invisible;
                    }
                }
                else
                {
                    // If the player has selected their card and is waiting on the other players, don't show the hand, otherwise, show the hand
                    if (!CardsAgainstHumility.ReadyToSelectWinner && !CardsAgainstHumility.ReadyForReview && CardsAgainstHumility.SelectedCard != null)
                    {
                        PlayerHandView.Visibility = ViewStates.Invisible;
                    }
                    else
                    {
                        PlayerHandView.Visibility = ViewStates.Visible;
                    }
                }
            }
            else // Let the player view their hand if the game hasn't started yet
            {
                PlayerHandView.Visibility = ViewStates.Visible;
            }
        }
Exemplo n.º 14
0
 public DragAnDropItemTouchHelperCallback(HorizontalListView horizontalList, RecycleViewAdapter recycleViewAdapter, ICommand onDragAndDropdEnded = null)
 {
     _horizontalList      = horizontalList;
     _recycleViewAdapter  = recycleViewAdapter;
     _onDragAndDropdEnded = onDragAndDropdEnded;
 }
 public RecyclerAdapter(HorizontalListView listView, IList dataSet)
 {
     _listView = listView;
     _dataSet  = dataSet;
 }
 public ViewSource(HorizontalListView view)
 {
     _listView   = view;
     _dataSource = view.ItemsSource?.Cast <object>()?.ToList();
 }