Пример #1
0
        public override void Run(Box parent)
        {
            var collectionView = new Ext.CollectionView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
            };

            collectionView.Show();

            var items = new List <string>();

            for (int i = 0; i < 100; i++)
            {
                items.Add($"Items {i}");
            }
            var adaptor = new MyAdaptor(items);

            collectionView.Adaptor       = adaptor;
            collectionView.LayoutManager = new Ext.GridLayoutManager(false, 3, Ext.ItemSizingStrategy.MeasureAllItems, 10, 10);

            parent.PackEnd(collectionView);
        }
Пример #2
0
 public static void UpdateItemsLayout(this TCollectionView platformView, StructuredItemsView view)
 {
     if (view.ItemsLayout != null)
     {
         var itemSizingStrategy = view.ItemSizingStrategy.ToPlatform();
         if (view.ItemsLayout is GridItemsLayout grid)
         {
             var orientation           = grid.Orientation == ItemsLayoutOrientation.Horizontal;
             var verticalItemSpacing   = DPExtensions.ConvertToScaledPixel(grid.VerticalItemSpacing);
             var horizontalItemSpacing = DPExtensions.ConvertToScaledPixel(grid.HorizontalItemSpacing);
             platformView.LayoutManager = new GridLayoutManager(orientation, grid.Span, itemSizingStrategy, verticalItemSpacing, horizontalItemSpacing);
         }
         else if (view.ItemsLayout is LinearItemsLayout linear)
         {
             var orientation = linear.Orientation == ItemsLayoutOrientation.Horizontal;
             var itemSpacing = DPExtensions.ConvertToScaledPixel(linear.ItemSpacing);
             platformView.LayoutManager = new LinearLayoutManager(orientation, itemSizingStrategy, itemSpacing);
         }
         else
         {
             platformView.LayoutManager = new LinearLayoutManager(false);
         }
         platformView.SnapPointsType = (view.ItemsLayout as ItemsLayout).SnapPointsType.ToPlatform();
         platformView.SelectionMode  = (view as SelectableItemsView).SelectionMode.ToPlatform();
     }
 }
Пример #3
0
        public static void UpdateItemsSource(this TCollectionView platformView, ItemsView view)
        {
            if (view.ItemsSource is INotifyCollectionChanged collectionChanged)
            {
                if (_observableSource != null)
                {
                    _observableSource.CollectionChanged -= OnCollectionChanged;
                }
                _observableSource = collectionChanged;
                _observableSource.CollectionChanged += OnCollectionChanged;
            }
            UpdateAdaptor(platformView, view);

            void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
            {
                if (view.ItemsSource == null || !view.ItemsSource.Cast <object>().Any())
                {
                    platformView.Adaptor = EmptyItemAdaptor.Create(view);
                }
                else
                {
                    if (platformView.Adaptor is EmptyItemAdaptor)
                    {
                        platformView.UpdateAdaptor(view);
                    }
                }
            }
        }
        EvasObject CreateContent(EvasObject parent)
        {
            var collectionView = new Ext.CollectionView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
            };

            collectionView.Show();

            var items = new List <string>();

            for (int i = 0; i < 100; i++)
            {
                items.Add($"Items {i}");
            }
            var adaptor = new MyAdaptor(items);

            collectionView.Adaptor       = adaptor;
            collectionView.LayoutManager = new Ext.LinearLayoutManager(false, Ext.ItemSizingStrategy.MeasureAllItems, 10);

            return(collectionView);
        }
Пример #5
0
        public ShellView(EvasObject parent) : base(parent)
        {
            NativeParent                   = parent;
            _navigationDrawer              = CreateNavigationDrawer();
            _navigationView                = CreateNavigationView();
            _navigationView.LayoutUpdated += OnNavigationViewLayoutUpdated;
            _navigationView.Content        = _itemsView = CreateItemsView();

            _navigationDrawer.NavigationView = _navigationView.TargetView;
            _navigationDrawer.Toggled       += OnDrawerToggled;

            _navigationDrawer.TargetView.SetAlignment(-1.0, -1.0);
            _navigationDrawer.TargetView.SetWeight(1.0, 1.0);
            _navigationDrawer.TargetView.Show();
            PackEnd(_navigationDrawer.TargetView);
        }
Пример #6
0
 public static void UpdateAdaptor(this TCollectionView platformView, ItemsView view)
 {
     if (view.ItemsSource == null || !view.ItemsSource.Cast <object>().Any())
     {
         platformView.Adaptor = EmptyItemAdaptor.Create(view);
     }
     else if (view.ItemTemplate == null)
     {
         platformView.Adaptor = new ItemDefaultTemplateAdaptor(view);
     }
     else
     {
         platformView.Adaptor = new ItemTemplateAdaptor(view);
     }
     platformView.Adaptor.ItemSelected += OnItemSelected;
 }
Пример #7
0
        public ShellView(EvasObject parent) : base(parent)
        {
            PlatformParent                 = parent;
            _navigationDrawer              = CreateNavigationDrawer();
            _navigationView                = CreateNavigationView();
            _navigationView.LayoutUpdated += OnNavigationViewLayoutUpdated;
            _navigationView.Content        = _itemsView = CreateItemsView();
            _navigationDrawer.DrawerWidth  = ThemeConstants.Shell.Resources.DefaultFlyoutItemWidth;

            _navigationDrawer.NavigationView = _navigationView.TargetView;
            _navigationDrawer.Toggled       += OnDrawerToggled;

            _navigationDrawer.TargetView.SetAlignment(-1.0, -1.0);
            _navigationDrawer.TargetView.SetWeight(1.0, 1.0);
            _navigationDrawer.TargetView.Show();

            Show();
            PackEnd(_navigationDrawer.TargetView);
        }