コード例 #1
0
        public DashWidgetView(DashSquare square)
        {
            RelativeLayout layout = new RelativeLayout();

            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (s, e) => {
                EventHandler <WidgetTappedEventArgs> handler = Tapped;
                handler?.Invoke(this, new WidgetTappedEventArgs(square));
            };

            layout.GestureRecognizers.Add(tapGestureRecognizer);

            var backgroundImage = new CachedImage()
            {
                Source = new UriImageSource
                {
                    CachingEnabled = true,
                    CacheValidity  = new TimeSpan(5, 0, 0, 0),
                    Uri            = new Uri(square.PreviewImage)
                },
                Aspect           = Aspect.AspectFill,
                InputTransparent = false,

                CacheDuration      = new TimeSpan(5, 0, 0, 0),
                LoadingPlaceholder = "placeholder.jpg"
            };

            layout.Children.Add(backgroundImage,
                                Constraint.Constant(0),
                                Constraint.Constant(0),
                                Constraint.RelativeToParent((parent) => parent.Width),
                                Constraint.RelativeToParent((parent) => parent.Height));

            this.Padding = new Thickness(10, 10);
            Content      = layout;
        }
コード例 #2
0
        public ActionPage()
        {
            InitializeComponent();
            NavigationPage.SetHasNavigationBar(this, false);

            var returnComman = new Command(() =>
            {
                Navigation.PopAsync(true);
            });

            ImageStackLayout.GestureRecognizers.Add(new TapGestureRecognizer
            {
                Command = returnComman
            });

            RelativeLayout layout = new RelativeLayout();

            var backgroundImage = new CachedImage()
            {
                Aspect            = Aspect.AspectFit,
                InputTransparent  = false,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,

                CacheDuration      = new TimeSpan(5, 0, 0, 0),
                LoadingPlaceholder = "placeholder.jpg"
            };

            layout.Children.Add(backgroundImage,
                                Constraint.Constant(0),
                                Constraint.Constant(0),
                                Constraint.RelativeToParent((parent) => parent.Width),
                                Constraint.RelativeToParent((parent) => parent.Height));

            ImageStackLayout.Children.Add(layout);

            MessagingCenter.Subscribe <ActionPage, DashSquare>(this, "Hi", (page, dashSquare) =>
            {
                CurrentItem = dashSquare;

                backgroundImage.Source = new UriImageSource
                {
                    CachingEnabled = true,
                    CacheValidity  = new TimeSpan(5, 0, 0, 0),
                    Uri            = new Uri(CurrentItem.BigImage)
                };

                var indicator = new ActivityIndicator
                {
                    Color             = Color.FromHex("#009d48"),
                    BackgroundColor   = Color.Transparent,
                    VerticalOptions   = LayoutOptions.CenterAndExpand,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                };
                layout.Children.Add(indicator,
                                    Constraint.Constant(0),
                                    Constraint.Constant(0),
                                    Constraint.RelativeToParent((parent) => parent.Width),
                                    Constraint.RelativeToParent((parent) => parent.Height));

                indicator.SetBinding(ActivityIndicator.IsRunningProperty, "IsLoading");
                indicator.BindingContext = backgroundImage;
            });
        }
コード例 #3
0
        private async Task LoadViewData()
        {
            isBysi = true;

            App.PhotoBoothEntities = await GetPhotoBoothEntitys();

            if (Settings.PhotoBoothId == Guid.Empty)
            {
                await Navigation.PushModalAsync(new SelectPhotoBoothPage(), true);

                return;
            }

            var photoEvents = await GetPhotoEvent(Settings.PhotoBoothId);

            if (photoEvents == null)
            {
                await DisplayAlert("Нет события", "Сейчас не происходит ни одно событие.", "OK");

                if (Device.OS == TargetPlatform.iOS)
                {
                    throw new ExitAppException("known crash to exit app");
                }

                return;
            }

            var itemsCount = photoEvents.Photos.Count;

            if (App.DashSquares != null && itemsCount == App.DashSquares.Count)
            {
                return;
            }

            dashboards = new List <Grid>();
            var dashboard = new Grid()
            {
                ColumnSpacing   = 0,
                RowSpacing      = 0,
                VerticalOptions = LayoutOptions.FillAndExpand,
            };

            Enumerable.Range(0, rowIndexMax + 1).ToList().ForEach(x =>
                                                                  dashboard.RowDefinitions.Add(
                                                                      new RowDefinition
            {
                Height = new GridLength(1, GridUnitType.Star)
            }
                                                                      ));

            Enumerable.Range(0, colIndexMax + 1).ToList().ForEach(x =>
                                                                  dashboard.ColumnDefinitions.Add(new ColumnDefinition
            {
                Width = new GridLength(1, GridUnitType.Star)
            }));

            var colIndex = 0;
            var rowIndex = 0;

            App.DashSquares = new List <DashSquare>();
            foreach (var p in photoEvents.Photos.OrderByDescending(p => p.Created))
            {
                if (p.IsDeleted)
                {
                    continue;
                }

                var item = new DashSquare
                {
                    BigImage     = "http://joyenjoy.me/EventImages/" + p.PhotoEventId + "/" + p.ImageName,
                    PreviewImage = "http://joyenjoy.me/EventImages/" + p.PhotoEventId + "/" + p.PreviewImageName,
                    Id           = p.Id,
                    Column       = colIndex,
                    Row          = rowIndex,
                    Page         = pageIndex,
                    PhotoBoothId = photoEvents.PhotoBoothEntityId,
                    BlobPath     = p.BlobPathToImage
                };

                var widget = new DashWidgetView(item);
                widget.Tapped += (sender, e) =>
                {
                    var page = new ActionPage();
                    Navigation.PushAsync(page, true);

                    MessagingCenter.Send <ActionPage, DashSquare>(page, "Hi", e.ImageObject);
                };

                dashboard.Children.Add(widget, colIndex, rowIndex);
                App.DashSquares.Add(item);

                colIndex++;

                if (colIndex > colIndexMax)
                {
                    colIndex = 0;
                    rowIndex++;
                }

                if (rowIndex > rowIndexMax)
                {
                    rowIndex = 0;
                    pageIndex++;

                    dashboards.Add(dashboard);
                    dashboard = new Grid()
                    {
                        ColumnSpacing   = 0,
                        RowSpacing      = 0,
                        VerticalOptions = LayoutOptions.FillAndExpand,
                    };
                }
            }

            if (itemsCount % ((colIndexMax + 1) * (rowIndexMax + 1)) != 0)
            {
                dashboards.Add(dashboard);
            }

            currentPageIndex = dashboards.Count - 1;
            if (currentPageIndex < 0)
            {
                currentPageIndex = 0;
            }

            var grid = dashboards.ElementAtOrDefault(currentPageIndex);

            if (grid != null)
            {
                ImageStackLayout.Children.Clear();
                ImageStackLayout.Children.Add(grid);
            }

            isFirstLoad = true;
            isBysi      = false;
        }
コード例 #4
0
 public WidgetTappedEventArgs(DashSquare imageObject)
 {
     ImageObject = imageObject;
 }